9教练查询是否可以取消学员预约 GetMappingqueryIsCancelByUpdateTimeId public ResultObject queryIsCancelByUpdateTimeIdlong updateTimeId HttpServletRequest request 权限验证 String token = String reques
<p>@GetMapping("/queryIsCancelByUpdateTimeId")
public Result<Object> queryIsCancelByUpdateTimeId(long updateTimeId, HttpServletRequest request) {</p>
<pre><code>//权限验证
String token = (String) request.getAttribute("claims_coach");
if (token == null || "".equals(token)) {
throw new RuntimeException("权限不足!");
}
//把查询到的的对象放入map集合
Map<String, Object> map = new HashMap<>();
//查询当前课程信息
UpdateTime updateTime = updateTimeService.getById(updateTimeId);
Date today = RcqtUtils.getDay();
boolean isCancel = false;
if (updateTime.getCourseDate().before(today) && !updateTime.getCourseDate().equals(today)) {
log.info("过期1");
} else if (updateTime.getCourseDate().equals(today)) {
if (LocalTime.now().isAfter(updateTime.getEndReservationTime().toLocalTime())){
log.info("过期");
}else if (LocalTime.now().isAfter(updateTime.getStartReservationTime().toLocalTime()) && LocalTime.now().isBefore(updateTime.getEndReservationTime().toLocalTime())){
log.info("过期");
}else if (LocalTime.now().isBefore(updateTime.getStartReservationTime().toLocalTime())){
System.out.println("当前时间在开始时间之前");
log.info("可以取消");
isCancel = true;
}
} else {
log.info("可以取消");
isCancel = true;
}
map.put("isCancel", isCancel);
return new Result<>(ResultCode.SUCCESS, map);
</code></pre>
AI 优化版
原文地址:https://www.cveoy.top/t/topic/h9tX 著作权归作者所有。请勿转载和采集!