参数:
1.分页还是用@ModelAttribute Page<Map> page
接收
2.接收参数不用@ModelAttribute T model
,改为@RequestParam Map map
,因为Map其实也是一个对象
原来返回相同类查询结果
@RequestMapping(value = "/codePage", method = RequestMethod.GET)
public ResponseObj<Page<SubjectEnrollCertList>> codePage(@ModelAttribute Page<SubjectEnrollCertList> page,
@ModelAttribute SubjectEnrollCertList map,
HttpServletRequest request) throws Exception {
String vcode = map.getVcode();
Integer operateType = map.getOperateType();
VCodeUtil.checkVcode(verifyCode, vcode, operateType, request);
Page<SubjectEnrollCertList> pageList = serviceList.selectPage(page, queryWrapper(new EntityWrapper<>(map)));
for (SubjectEnrollCertList eachObj : pageList.getRecords()) {
queryFilter(eachObj);
}
return new ResponseObj<>(pageList, RetCode.SUCCESS);
}
修改后,返回不同类查询结果的接口
@Autowired
protected SubjectEnrollCertListService serviceList;
@Autowired
AuthHistoryGgService authHistoryGgService;
@RequestMapping(value = "/codePage", method = RequestMethod.GET)
public ResponseObj<Page<Map<String, Object>>> codePage(@ModelAttribute Page<Map> page,
@RequestParam Map map,
HttpServletRequest request) throws Exception {
String vcode = (String) map.get("vcode");
Integer operateType = Integer.parseInt((String) map.get("operateType"));
VCodeUtil.checkVcode(verifyCode, vcode, operateType, request);
Integer subjectType = Integer.parseInt((String) map.get("subjectType"));
Page<Map<String, Object>> mapPage = null;
if (subjectType == Constants.GG) {
AuthHistoryGg model = (AuthHistoryGg) MapBeanUtil.mapToBean(map, AuthHistoryGg.class);
mapPage = authHistoryGgService.selectMapsPage(page, new EntityWrapper<>(model));
} else {
SubjectEnrollCertList model = (SubjectEnrollCertList) MapBeanUtil.mapToBean(map, SubjectEnrollCertList.class);
mapPage = serviceList.selectMapsPage(page, queryWrapper(new EntityWrapper<>(model)));
}
return new ResponseObj<>(mapPage, RetCode.SUCCESS);
}
网友评论