今天完成了获取预约功能的Controller、Service、Dao层代码的编写,其中我遇到了两个问题,现总结如下:
1.因为项目是前后端分离的,所以我在Dao层访问数据库的时候应该使用的是Entity作为输入参数,访问数据库,而不是Dto。如果输入参数并不属于数据库字段,我需要新建一个Entity来封装参数,同时该Entity应该继承另一个对应的数据库表的Entity.
2.在业务逻辑方面有一个分组的逻辑非常不错,值得借鉴:
//获取预约状态(指定时间范围的预约状态<以日期分组>) public AppoimentResponseDto getappoimentstatuslist(AppoimentRequestDto ard) throws Exception { int storeid=DataUtil.getCurrent().getStoreid(); HcDmsAppointmentOrderStartToEnd starttoend=new HcDmsAppointmentOrderStartToEnd(); starttoend.setStartdate(ard.getStartdate()); starttoend.setEnddate(ard.getEnddate()); //先查出指定时间范围内的所有预约状态记录 List<HcDmsAppointmentOrder> hdaolist = dmsAppointmentDao.getappoimentstatuslist(starttoend); List<AppoimentlistResponseDto> list = new ArrayList<>(); for (HcDmsAppointmentOrder hcDmsAppointmentOrder : hdaolist) { AppoimentlistResponseDto appoimentlistResponseDto = null; String appoimentdate = hcDmsAppointmentOrder.getAodate(); //