Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
97c144c6
Commit
97c144c6
authored
May 04, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provided request response format for resource controller
parent
135af26f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
35 deletions
+62
-35
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+55
-31
IResourceService.java
src/main/java/com/nisum/myteam/service/IResourceService.java
+1
-1
ProjectService.java
...in/java/com/nisum/myteam/service/impl/ProjectService.java
+0
-1
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+6
-2
No files found.
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
97c144c6
package
com
.
nisum
.
myteam
.
controller
;
package
com
.
nisum
.
myteam
.
controller
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.model.Employee
;
import
com.nisum.myteam.model.Employee
;
import
com.nisum.myteam.model.EmployeeDashboardVO
;
import
com.nisum.myteam.model.EmployeeDashboardVO
;
import
com.nisum.myteam.model.EmployeeVisa
;
import
com.nisum.myteam.model.EmployeeVisa
;
...
@@ -25,6 +11,18 @@ import com.nisum.myteam.service.IEmployeeService;
...
@@ -25,6 +11,18 @@ import com.nisum.myteam.service.IEmployeeService;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.IResourceService
;
import
com.nisum.myteam.service.IResourceService
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@RestController
@RestController
@RequestMapping
@RequestMapping
...
@@ -43,32 +41,58 @@ public class ResourceController {
...
@@ -43,32 +41,58 @@ public class ResourceController {
private
IResourceService
resourceService
;
private
IResourceService
resourceService
;
// @RequestMapping(value = "/addEmployeeToTeam"
// @RequestMapping(value = "/addEmployeeToTeam"
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Resource
>
addResourceToTeam
(
@RequestBody
Resource
resource
,
public
ResponseEntity
<?>
addResourceToTeam
(
@RequestBody
Resource
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
false
)
String
loginEmpId
)
throws
MyTeamException
{
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
resource
.
setActive
(
true
);
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
resource
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
resourceReq
.
setActive
(
true
);
Resource
resourcePersisted
=
resourceService
.
addResource
(
resource
,
loginEmpId
);
resourceReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
return
new
ResponseEntity
<>(
resourcePersisted
,
HttpStatus
.
OK
);
Resource
resourcePersisted
=
resourceService
.
addResource
(
resourceReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been created"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"details"
,
resourcePersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
}
// @RequestMapping(value = "/updateTeammate"
// @RequestMapping(value = "/updateTeammate"
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
String
>
updateResource
(
@RequestBody
Resource
resource
,
public
ResponseEntity
<?>
updateResource
(
@RequestBody
Resource
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTeamException
{
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
resource
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
String
response
=
resourceService
.
updateResource
(
resource
,
loginEmpId
);
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
return
new
ResponseEntity
<>(
response
,
HttpStatus
.
OK
);
resourceReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
String
responseMessage
=
resourceService
.
updateResource
(
resourceReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
responseMessage
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
}
// @RequestMapping(value = "/deleteTeammate"
// @RequestMapping(value = "/deleteTeammate"
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
String
>
deleteResource
(
@RequestBody
Resource
resource
,
public
ResponseEntity
<?>
deleteResource
(
@RequestBody
Resource
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTeamException
{
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
resourceService
.
deleteResource
(
resource
.
getEmployeeId
(),
resource
.
getProjectId
(),
resource
.
getId
(),
loginEmpId
);
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
return
new
ResponseEntity
<>(
"Success"
,
HttpStatus
.
OK
);
Resource
resourceDeleted
=
resourceService
.
deleteResource
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
(),
resourceReq
.
getId
(),
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been deleted"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceDeleted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
}
// @RequestMapping(value = "/getEmployeeProjectInfo"
// @RequestMapping(value = "/getEmployeeProjectInfo"
...
...
src/main/java/com/nisum/myteam/service/IResourceService.java
View file @
97c144c6
...
@@ -17,7 +17,7 @@ public interface IResourceService {
...
@@ -17,7 +17,7 @@ public interface IResourceService {
String
updateResource
(
Resource
projectTeamMate
,
String
loginEmpId
)
throws
MyTeamException
;
String
updateResource
(
Resource
projectTeamMate
,
String
loginEmpId
)
throws
MyTeamException
;
void
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
);
Resource
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
);
Resource
save
(
Resource
resource
);
Resource
save
(
Resource
resource
);
...
...
src/main/java/com/nisum/myteam/service/impl/ProjectService.java
View file @
97c144c6
...
@@ -747,5 +747,4 @@ public class ProjectService implements IProjectService {
...
@@ -747,5 +747,4 @@ public class ProjectService implements IProjectService {
}
}
}
}
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
97c144c6
...
@@ -131,9 +131,11 @@ public class ResourceService implements IResourceService {
...
@@ -131,9 +131,11 @@ public class ResourceService implements IResourceService {
// String result = null;
// String result = null;
MyTeamResultDTO
myResultDto
=
new
MyTeamResultDTO
();
MyTeamResultDTO
myResultDto
=
new
MyTeamResultDTO
();
myResultDto
.
setResultCode
(
MyTeamResultDTO
.
SUCCESS_CODE
);
myResultDto
.
setResultCode
(
MyTeamResultDTO
.
SUCCESS_CODE
);
myResultDto
.
setResultData
(
"TeamMate updated successfuly"
);
myResultDto
.
setResultData
(
"TeamMate updated successfuly"
);
Resource
existingTeammate
=
resourceRepo
.
findById
(
resource
.
getId
());
Resource
existingTeammate
=
resourceRepo
.
findById
(
resource
.
getId
());
List
<
Billing
>
listBD
=
billingService
.
getActiveBillings
(
resource
.
getEmployeeId
(),
resource
.
getProjectId
());
List
<
Billing
>
listBD
=
billingService
.
getActiveBillings
(
resource
.
getEmployeeId
(),
resource
.
getProjectId
());
Date
resEndDate
=
resource
.
getEndDate
();
Date
resEndDate
=
resource
.
getEndDate
();
...
@@ -341,7 +343,7 @@ public class ResourceService implements IResourceService {
...
@@ -341,7 +343,7 @@ public class ResourceService implements IResourceService {
}
}
@Override
@Override
public
void
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
)
{
public
Resource
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
)
{
Resource
existingResource
=
resourceRepo
.
findById
(
id
);
Resource
existingResource
=
resourceRepo
.
findById
(
id
);
existingResource
.
setActive
(
false
);
existingResource
.
setActive
(
false
);
existingResource
.
setEndDate
(
new
Date
());
existingResource
.
setEndDate
(
new
Date
());
...
@@ -387,8 +389,10 @@ public class ResourceService implements IResourceService {
...
@@ -387,8 +389,10 @@ public class ResourceService implements IResourceService {
resourceBench
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
// Setting
resourceBench
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
// Setting
// audit
// audit
// fields
// fields
resourceRepo
.
save
(
resourceBench
);
Resource
resource
=
resourceRepo
.
save
(
resourceBench
);
empShiftService
.
updateEmployeeShift
(
existingResource
,
loginEmpId
);
empShiftService
.
updateEmployeeShift
(
existingResource
,
loginEmpId
);
return
resource
;
}
}
// Update ProjectEndDate column data in ProjectTeamMate.
// Update ProjectEndDate column data in ProjectTeamMate.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment