Commit 48a39117 authored by Md Suleman's avatar Md Suleman

added audit to the sub status records and for resource

parent e92604f4
......@@ -276,7 +276,7 @@ public class EmployeeController {
public ResponseEntity<?> endSubStatus(@RequestBody EmployeeSubStatus employeeSubStatus, @RequestParam("loginEmpId") String loginEmpId ,HttpServletRequest request){
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Sub status end updated successfully",
"Emoployee sub status updated successfully", subStatusService.endSubStatus(employeeSubStatus) , request.getRequestURI(), "Resource details", null);
"Emoployee sub status updated successfully", subStatusService.endSubStatus(loginEmpId,employeeSubStatus) , request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
......
package com.nisum.myteam.model.dao;
import com.nisum.myteam.model.AuditFields;
import lombok.*;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
......@@ -15,7 +16,7 @@ import java.util.Date;
@NoArgsConstructor
@ToString
@Document(collection = "employeeSubStatus")
public class EmployeeSubStatus {
public class EmployeeSubStatus extends AuditFields {
@Id
private ObjectId id;
......
......@@ -5,11 +5,11 @@ import com.nisum.myteam.model.dao.EmployeeSubStatus;
public interface ISubStatusService {
public EmployeeSubStatus getLatestEmployeeSubStatus(String empId);
public EmployeeSubStatus updateExistingEmplyeeSubStatus(EmployeeSubStatus employeeSubStatusReq);
public EmployeeSubStatus updateExistingEmplyeeSubStatus(String loginnEmployeeId,EmployeeSubStatus employeeSubStatusReq);
public EmployeeSubStatus addEmployeeSubStatus(EmployeeSubStatus employeeSubStatus);
public EmployeeSubStatus addEmployeeSubStatus(String loginnEmployeeId,EmployeeSubStatus employeeSubStatus);
public EmployeeSubStatus getCurrentSubStatus(String employeeId);
public EmployeeSubStatus endSubStatus(EmployeeSubStatus subStatus);
public EmployeeSubStatus endSubStatus(String loginnEmployeeId,EmployeeSubStatus subStatus);
}
......@@ -129,14 +129,14 @@ public class EmployeeService implements IEmployeeService {
if (currentSubStatus != null) {
if (currentSubStatus.getSubStatus().equals(latestSubStatus.getSubStatus())) {
latestSubStatus.setId(currentSubStatus.getId());
subStatusService.updateExistingEmplyeeSubStatus(latestSubStatus);
subStatusService.updateExistingEmplyeeSubStatus(loginEmpId,latestSubStatus);
} else {
response.put("messege", "Employee is already " + currentSubStatus.getSubStatus() + " from " + currentSubStatus.getFromDate() + " to " + currentSubStatus.getToDate());
}
} else {
// currentSubStatus = subStatusService.getLatestEmployeeSubStatus(employeeReq.getEmployeeId());
// if(currentSubStatus == null)
subStatusService.addEmployeeSubStatus(latestSubStatus);
subStatusService.addEmployeeSubStatus(loginEmpId,latestSubStatus);
// else {
// latestSubStatus.setId(currentSubStatus.getId());
// subStatusService.updateExistingEmplyeeSubStatus(latestSubStatus);
......
......@@ -166,6 +166,7 @@ public class ResourceService implements IResourceService {
resource.setBillableStatus(resourceReq.getBillableStatus());
resource.setBillingStartDate(resourceReq.getBillingStartDate());
resource.setBillingEndDate(resourceReq.getBillingEndDate());
resource.setAuditFields(loginEmpId,MyTeamUtils.UPDATE);
this.updateExistedResource(resource);
}
......
......@@ -36,16 +36,18 @@ public class SubStatusService implements ISubStatusService {
@Override
public EmployeeSubStatus updateExistingEmplyeeSubStatus(EmployeeSubStatus employeeSubStatusReq) {
public EmployeeSubStatus updateExistingEmplyeeSubStatus(String loginnEmployeeId,EmployeeSubStatus employeeSubStatusReq) {
employeeSubStatusReq.setFromDate(MyTeamDateUtils.getDayMoreThanDate(employeeSubStatusReq.getFromDate()));
employeeSubStatusReq.setToDate(MyTeamDateUtils.getDayMoreThanDate(employeeSubStatusReq.getToDate()));
employeeSubStatusReq.setAuditFields(loginnEmployeeId,MyTeamUtils.UPDATE);
return employeeSubStatusRepo.save(employeeSubStatusReq);
}
@Override
public EmployeeSubStatus addEmployeeSubStatus(EmployeeSubStatus employeeSubStatus) {
public EmployeeSubStatus addEmployeeSubStatus(String loginnEmployeeId,EmployeeSubStatus employeeSubStatus) {
employeeSubStatus.setFromDate(MyTeamDateUtils.getDayMoreThanDate(employeeSubStatus.getFromDate()));
employeeSubStatus.setToDate(MyTeamDateUtils.getDayMoreThanDate(employeeSubStatus.getToDate()));
employeeSubStatus.setAuditFields(loginnEmployeeId,MyTeamUtils.CREATE);
return employeeSubStatusRepo.insert(employeeSubStatus);
}
......@@ -60,11 +62,12 @@ public class SubStatusService implements ISubStatusService {
}
@Override
public EmployeeSubStatus endSubStatus(EmployeeSubStatus subStatus){
public EmployeeSubStatus endSubStatus(String loginnEmployeeId,EmployeeSubStatus subStatus){
EmployeeSubStatus currentSubStatus = getCurrentSubStatus(subStatus.getEmployeeID());
if(currentSubStatus!=null){
currentSubStatus.setToDate(MyTeamDateUtils.getDayLessThanDate(new Date()));
updateExistingEmplyeeSubStatus(currentSubStatus);
currentSubStatus.setAuditFields(loginnEmployeeId,MyTeamUtils.UPDATE);
updateExistingEmplyeeSubStatus(loginnEmployeeId,currentSubStatus);
}
return null;
}
......
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