Controller中RequestParam接收日期参数
一些报表的查询中经常有按时间日期查询,前端传参可以用json后端可以用对象来接收, 前端用formdata提交,后台就用@RequestParam来接收,不过这里接收的是字符串,在使用的时候需要转换一下
@PostMapping("/export")
public void export(
@RequestParam(value = "pageNo", required = false) String pageNo,
@RequestParam(value = "size", required = false) String size,
@RequestParam(value = "peopleName", required = false) String peopleName,
@RequestParam(value = "phone", required = false) String phone,
@RequestParam(value = "checkPlaceId", required = false) String checkPlaceId,
@RequestParam(value = "checkStartTime", required = false) String checkStartTime,
@RequestParam(value = "checkEndTime", required = false) String checkEndTime,
HttpServletResponse response
) {
HealthReservation healthReservation = new HealthReservation();
healthReservation.setPageNo(StrUtil.isNotBlank(pageNo) ? Integer.valueOf(pageNo) : null);
healthReservation.setSize(StrUtil.isNotBlank(size) ? Integer.valueOf(size) : null);
healthReservation.setPeopleName(StrUtil.isNotBlank(peopleName) ? peopleName : null);
healthReservation.setPhone(StrUtil.isNotBlank(phone) ? phone : null);
healthReservation.setCheckStartTime(StrUtil.isNotBlank(checkStartTime) ? DateUtil.parse(checkStartTime) : null);
healthReservation.setCheckEndTime(StrUtil.isNotBlank(checkEndTime) ? DateUtil.parse(checkEndTime) : null);
healthReservationService.export(healthReservation, response);
}
还没有评论,来说两句吧...