@RequestMapping(method=RequestMethod.POST, value= {"/LMSServer/getNoOfDaysOfApplicationBycellNo"} )
@PreAuthorize("hasAuthority('CUSTOMER_MANAGEMENT_R') OR hasAuthority('CUSTOMER_MANAGEMENT_RW')")
public BasicResponce getNoOfDaysOfApplicationBycellNo(@RequestParam(value = "cellNo") long cellNo)
{
if(LOG.isInfoEnabled()){
LOG.info("WebClientRestContoller.getNoOfDaysOfApplicationBycellNo--Start");
LOG.info("Cell NO: "+cellNo);
}
BasicResponce authResp = null;
try {
Customer fromDB= (Customer) objLMSDAO.getDetailsByCellno(cellNo);
DaysOfApplicationResponseDTO toSend= new DaysOfApplicationResponseDTO();
toSend.setCreatedAt(fromDB.getCreatedAt()+"");
toSend.setUpdatedAt(fromDB.getUpdatedAt()+"");
toSend.setRequested_Action(true);
authResp=toSend;
} catch (Exception e) {
e.printStackTrace();
}
if(LOG.isInfoEnabled()){
LOG.info("Returned Response is:");
LOG.info("Response Requested_Action: {} ",new Object[]{authResp.getRequested_Action()});
LOG.info("WebClientRestContoller.getNoOfDaysOfApplicationBycellNo--End");
}
return authResp;
}
The above is my main code. I want to print the difference of days (no. of days between createdAt
and updatedAt
). Where do I write this logic? I remember in java we use System.out.println
to display output, but here I don't know to display code on Postman.
Below is my DTO:
public class DaysOfApplicationResponseDTO extends BasicResponce{
private String createdAt;
private String updatedAt;
private String days;
public String getDays() {
return days;
}
public void setDays(String days) {
this.days = days;
}
private List<CustomerLoanSummaryResponseDTO> LoanApplicationDummyResponseList;
public String getCreatedAt() {
return createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
public String getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(String updatedAt) {
this.updatedAt = updatedAt;
}
public List<CustomerLoanSummaryResponseDTO> getLoanApplicationDummyResponseList() {
return LoanApplicationDummyResponseList;
}
public void setLoanApplicationDummyResponseList(
List<CustomerLoanSummaryResponseDTO> loanApplicationDummyResponseList) {
LoanApplicationDummyResponseList = loanApplicationDummyResponseList;
}
public DaysOfApplicationResponseDTO() {
super();
}
public DaysOfApplicationResponseDTO(String createdAt, String UpdatedAt, String days,
List<CustomerLoanSummaryResponseDTO> loanApplicationDummyResponseList) {
super();
this.createdAt = createdAt;
this.updatedAt = updatedAt;
this.days = days;
this.LoanApplicationDummyResponseList = loanApplicationDummyResponseList;
}
}
You can introduce service classes (@service annotation) to your project for domain logic. You have to break down and organize the project into a suitable project structure (so that your controllers, entities, services are in different packages for clarity). Better read on those for more information.
Here is a helpful stack-overflow question, What is the recommended project structure for spring boot rest projects?