教练约课记录查询 API - 按日期查询
<p>///'//7.教练查询约课记录(前端传递日期)//n//t@GetMapping//(/'/queryCourseRecordsByCoachByDate///'//)/n//tpublic Result<Object> queryCourseRecordsByCoachByDate(Coach coach, String date, HttpServletRequest request) throws//n//t/t/tParseException {//n//n//t/t//权限验证//n//t/tString token = (String) request.getAttribute//(/'claims_coach///'//);//n//t/t//if (token == null || ///'///'//.equals(token)) {//n//t/t///tthrow new RuntimeException//(/'权限不足!///'//);//n//t/t//}//n//n//t/t//把查询到的的对象放入map集合//n//t/tMap<String, Object> map = new HashMap<>();//n//n//t/tif (StringUtils.isEmpty(date)) {//n//t/t/treturn new Result<>(ResultCode.FAIL);//n//t/t}//n//n//t/tDate dateNew = RcqtUtils.convertStringToDate(date);//n//t/t//查询日期对应的数据//n//t/tList<UpdateTime> updateTimeList = updateTimeService.queryUpdateTimeByDate(coach.getCoachId(), dateNew);//n//n//t/tList<UpdateTimeDto> updateTimeDtoList = new ArrayList<>();//n//t/tfor (UpdateTime updateTime : updateTimeList) {//n//t/t/tUpdateTimeDto updateTimeDto = new UpdateTimeDto();//n//t/t/tBeanUtils.copyProperties(updateTime, updateTimeDto);//n//n//t/t/tList<CourseInfo> courseInfos = courseInfoService.queryCourseByUpdateTimeId(updateTime.getUpdateTimeId());//n//t/t/t//一次性查询所有学员,减少数据库查询次数//n//t/t/tSet<Long> userIdSet = courseInfos.stream().map(CourseInfo::getUserId).collect(Collectors.toSet());//n//t/t/tList<CarUser> carUserList = carUserService.queryCarUsersByIds(userIdSet); //n//n//t/t/t// 关联约课学员//n//t/t/t// 使用 HashMap 提高查找速度//n//t/t/tMap<Long, CarUser> carUserMap = carUserList.stream().collect(Collectors.toMap(CarUser::getUserId, Function.identity()));//n//t/t/tList<CarUser> carUsersForUpdateTime = courseInfos.stream().map(courseInfo -> carUserMap.get(courseInfo.getUserId())).collect(Collectors.toList());//n//n//t/t/tupdateTimeDto.setCarUserList(carUsersForUpdateTime);//n//n//t/t/t//时间段为空的不展示//n//t/t/tif (updateTimeDto.getStartReservationTime() != null && updateTimeDto.getEndReservationTime() != null) {//n//t/t/t/tupdateTimeDtoList.add(updateTimeDto);//n//t/t/t}//n//n//t/t/tmap.put//(/'isBreakDate///', updateTime.getIsBreakDate()); //给前端总的休息状态//n//t/t}//n//n//t/tmap.put//(/'updateTimeList///', updateTimeDtoList);//n//n//t/treturn new Result<>(ResultCode.SUCCESS, map);//n//t}//n/</p>
原文地址: https://www.cveoy.top/t/topic/p4gn 著作权归作者所有。请勿转载和采集!