使用什么代替Java Spring Boot中的“ System.out.println”

问题描述 投票:-1回答:1
@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;

}

以上是我的主要代码。我想打印天数差异(createdAtupdatedAt之间的天数)。我在哪里写这个逻辑?我记得在Java中我们使用System.out.println显示输出,但是在这里我不知道在Postman上显示代码。

下面是我的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;

}
}
java spring-boot mysql-workbench hibernate-mapping hibernate-criteria
1个回答
-1
投票

您可以为您的项目引入服务类(@service批注)以获取域逻辑。您必须将项目分解并组织成一个合适的项目结构(为了清楚起见,您的控制器,实体,服务位于不同的程序包中)。最好阅读这些内容以获得更多信息。

这里是一个有用的堆栈溢出问题,What is the recommended project structure for spring boot rest projects?

© www.soinside.com 2019 - 2024. All rights reserved.