Commit 01fb8bfb authored by Vijay Akula's avatar Vijay Akula

Commented the ResourceController in order to take requests from new controller

parent fed165ca
package com.nisum.myteam.controller;
import java.util.List;
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.model.dao.Billing;
import com.nisum.myteam.service.IBillingService;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class BillingController {
@Autowired
private IBillingService billingService;
// @RequestMapping(value = "/addEmployeeBilling"
@RequestMapping(value = "/billing", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> addEmployeeBilling(@RequestBody Billing billing,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTeamException {
Billing billingList = billingService.addBilling(billing, loginEmpId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
// @RequestMapping(value = "/updateEmployeeBilling",
@RequestMapping(value = "/billing", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> updateEmployeeBilling(@RequestBody Billing billing,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTeamException {
Billing billingList = billingService.updateBilling(billing, loginEmpId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
// @RequestMapping(value = "/deleteEmployeeBilling"
@RequestMapping(value = "/billing", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> deleteEmployeeBilling(@RequestBody Billing billing) throws MyTeamException {
billingService.deleteBilling(billing);
return new ResponseEntity<>(null, HttpStatus.OK);
}
// @RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping(value = "/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Billing>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
throws MyTeamException {
List<Billing> billingList = billingService.getBillingsForEmployee(employeeId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
// @RequestMapping(value = "/getEmployeeBillingDetails"
@RequestMapping(value = "/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Billing>> getBillingsForProject(@PathVariable("projectId") String projectId,
@RequestParam("employeeId") String employeeId) throws MyTeamException {
List<Billing> billingList = billingService.getBillingsForProject(employeeId, projectId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
}
//package com.nisum.myteam.controller;
//
//import java.util.List;
//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.model.dao.Billing;
//import com.nisum.myteam.service.IBillingService;
//import lombok.extern.slf4j.Slf4j;
//
//@RestController
//@Slf4j
//public class BillingController {
//
// @Autowired
// private IBillingService billingService;
//
// // @RequestMapping(value = "/addEmployeeBilling"
// @RequestMapping(value = "/billing", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<Billing> addEmployeeBilling(@RequestBody Billing billing,
// @RequestParam(value = "loginEmpId") String loginEmpId) throws MyTeamException {
// Billing billingList = billingService.addBilling(billing, loginEmpId);
//
// return new ResponseEntity<>(billingList, HttpStatus.OK);
// }
//
// // @RequestMapping(value = "/updateEmployeeBilling",
// @RequestMapping(value = "/billing", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<Billing> updateEmployeeBilling(@RequestBody Billing billing,
// @RequestParam(value = "loginEmpId") String loginEmpId) throws MyTeamException {
// Billing billingList = billingService.updateBilling(billing, loginEmpId);
// return new ResponseEntity<>(billingList, HttpStatus.OK);
// }
//
// // @RequestMapping(value = "/deleteEmployeeBilling"
// @RequestMapping(value = "/billing", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<Billing> deleteEmployeeBilling(@RequestBody Billing billing) throws MyTeamException {
// billingService.deleteBilling(billing);
// return new ResponseEntity<>(null, HttpStatus.OK);
// }
//
//
//
// // @RequestMapping(value = "/getEmployeeBillingDetailsAll"
// @RequestMapping(value = "/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<List<Billing>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
// throws MyTeamException {
// List<Billing> billingList = billingService.getBillingsForEmployee(employeeId);
// return new ResponseEntity<>(billingList, HttpStatus.OK);
// }
//
// // @RequestMapping(value = "/getEmployeeBillingDetails"
// @RequestMapping(value = "/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<List<Billing>> getBillingsForProject(@PathVariable("projectId") String projectId,
// @RequestParam("employeeId") String employeeId) throws MyTeamException {
// List<Billing> billingList = billingService.getBillingsForProject(employeeId, projectId);
// return new ResponseEntity<>(billingList, HttpStatus.OK);
// }
//
//}
......@@ -25,7 +25,7 @@ public class DashboardController {
@Autowired
private IDashboardService dashboardService;
@RequestMapping(value = "/resourceAllocation/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getEmployeesDashBoard(HttpServletRequest request) throws MyTeamException {
List<EmployeeDashboardVO> employeeDashBoardList = dashboardService.getEmployeesDashBoard();
......
......@@ -41,7 +41,7 @@ public class ResourceAllocationController {
private ResourceAllocationService resourceAllocService;
//tested in all the cases.ok
@RequestMapping(value = "/resourceAllocation", 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<?> createResource(@RequestBody ResourceAllocation resourceAllocationReq,
@RequestParam(value = "loginEmpId", required = true) String loginEmpId, HttpServletRequest request) throws MyTeamException {
if (StringUtils.isNotBlank(loginEmpId)) {
......@@ -73,7 +73,7 @@ public class ResourceAllocationController {
}
//tested in all the cases.ok
@RequestMapping(value = "/resourceAllocation", 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<?> updateResource(@RequestBody ResourceAllocation resourceAllocationReq,
@RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
......@@ -95,7 +95,7 @@ public class ResourceAllocationController {
}
//Tested Ok
@RequestMapping(value = "/resourceAllocation", 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<?> deleteResource(@RequestBody ResourceAllocation resourceReq,
@RequestParam(value = "loginEmpId", required = true) String loginEmpId, HttpServletRequest request) throws MyTeamException {
if (StringUtils.isNotBlank(loginEmpId)) {
......@@ -115,7 +115,7 @@ public class ResourceAllocationController {
//Ok Tested in all of the cases
@RequestMapping(value = "/resourceAllocation/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesForProject(@PathVariable(value = "projectId", required = true) String projectId,
@RequestParam(value = "status", required = false, defaultValue = MyTeamUtils.ACTIVE) String status,
HttpServletRequest request)
......@@ -135,7 +135,7 @@ public class ResourceAllocationController {
//ok
///getMyProjectAllocations
@RequestMapping(value = "/resourceAllocation/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getMyProjectAllocations(
@RequestParam("employeeId") String employeeId, HttpServletRequest request) throws MyTeamException {
......@@ -155,7 +155,7 @@ public class ResourceAllocationController {
//ok
///resourceAllocation/projects has to be changed to /resourceAllocation/activeProjects
@RequestMapping(value = "/resourceAllocation/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesAllocatedForAllProjects(HttpServletRequest request) throws MyTeamException {
List<ResourceAllocation> resourcesList = resourceAllocService.getAllResourcesForAllActiveProjects();
......@@ -167,7 +167,7 @@ public class ResourceAllocationController {
//ok //Getting Current active resource record
@RequestMapping(value = "/resourceAllocation/employeeId/{employeeId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/employeeId/{employeeId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesSortByProjectStartDate(@PathVariable(value = "employeeId", required = true) String employeeId, HttpServletRequest request)
throws MyTeamException {
......@@ -186,7 +186,7 @@ public class ResourceAllocationController {
//ok tested
@RequestMapping(value = "/resourceAllocation/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getActiveResources(@RequestParam(value = "employeeId", required = false) String employeeId, HttpServletRequest request)
throws MyTeamException {
if (StringUtils.isNotBlank(employeeId)) {
......@@ -205,7 +205,7 @@ public class ResourceAllocationController {
//ok working
@RequestMapping(value = "/resourceAllocation/deliverylead/{deliveryLeadId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/deliverylead/{deliveryLeadId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getTeamDetails(@PathVariable(value = "deliveryLeadId", required = true) String deliveryLeadId, HttpServletRequest request)
throws MyTeamException {
......@@ -224,7 +224,7 @@ public class ResourceAllocationController {
}
//ok tested working
@RequestMapping(value = "/resourceAllocation/unAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/unAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getUnAssignedEmployees(HttpServletRequest request) throws MyTeamException {
List<Employee> employeesList = resourceAllocService.getUnAssignedEmployees();
......@@ -235,7 +235,7 @@ public class ResourceAllocationController {
//@RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping(value = "/resourceAllocation/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceAllocation>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
throws MyTeamException {
List<ResourceAllocation> resourceAllocList = resourceAllocService.getBillingsForEmployee(employeeId);
......@@ -243,7 +243,7 @@ public class ResourceAllocationController {
}
// @RequestMapping(value = "/getEmployeeBillingDetails"
@RequestMapping(value = "/resourceAllocation/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/resources/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceAllocation>> getBillingsForProject(@PathVariable("projectId") String projectId,
@RequestParam("employeeId") String employeeId) throws MyTeamException {
List<ResourceAllocation> resourceAllocList = resourceAllocService.getBillingsForProject(employeeId, projectId);
......
......@@ -24,6 +24,6 @@ public interface ResourceRepo
List<Resource> findByEmployeeIdAndProjectIdAndActive(String employeeId, String projectId, boolean status);
List<Resource> findByAccountAndActiveAndBillableStatus( String account, boolean status, String billableStatus);
Optional<List<Resource>> findByActiveAndShiftLikeOrderByEmployeeIdDesc( boolean active, String shift);
}
......@@ -76,7 +76,7 @@ public class ResourceService implements IResourceService {
resourceReq.setAuditFields(loginEmpId, MyTeamUtils.CREATE);
Resource resourcePersisted = resourceRepo.save(resourceReq);
// Get Active billings for Nisum Bench Project.
List<Billing> listBD = billingService.getActiveBillings(resourcePersisted.getEmployeeId(), "Nisum0000");
......@@ -586,23 +586,23 @@ public class ResourceService implements IResourceService {
return resourcesList;
}
@Override
public List<Resource> getResourcesUnderDeliveryLead(String deliveryLeadId) {
List<String> projectIdsList = new ArrayList<>();
List<Resource> resourcesList = new ArrayList<>();
List<Project> projectsList = projectRepo.findByDeliveryLeadIds(deliveryLeadId);
for (Project project : projectsList)
projectIdsList.add(project.getProjectId());
Query query = new Query(Criteria.where("projectId").in(projectIdsList));
List<Resource> resourcesListPersisted = mongoTemplate.find(query, Resource.class);
for (Resource resource : resourcesListPersisted) {
if (!resource.getEmployeeId().equals(deliveryLeadId))
resourcesList.add(resource);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment