@RequestMapping(value = "/getBaseCodess", method = RequestMethod.GET)
public ModelAndView getBaseCodess(HttpServletRequest request, HttpServletResponse response) {
List<Map<String,Object>> depts = new ArrayList<>();
try {
Integer range = PageUtil.getRangSize(request);
Integer pageNum = PageUtil.getStartPageIndex(request);
IBaseCodeManager baseCodeManager = TCFrameworkFactory.getTCFramework().getModuleService(IBaseCodeManager.class);
// todo 查询某种分类编码
List<BaseCodeBean> pageInfo = baseCodeManager.findBaseCodes();
for (BaseCodeBean baseCodeBean : pageInfo){
Map<String, Object> result = new HashMap<String, Object>();
result.put("id", baseCodeBean.getId());
result.put("type", baseCodeBean.getType());
result.put("key",baseCodeBean.getKey());
result.put("value",baseCodeBean.getValue());
result.put("status",baseCodeBean.getStatus());
result.put("createDate",baseCodeBean.getCreateDate());
result.put("updateDate",baseCodeBean.getUpdateDate());
result.put("sort",baseCodeBean.getSort());
depts.add(result);
}
// todo 中文排序,depts需要排序的字段
Collections.sort(depts, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> column_1, Map<String, Object> column_2) {
// 取出需要排序的字段
String name1=(String) column_1.get("value");
String name2=(String) column_2.get("value");
// 排序
Collator instance = Collator.getInstance(Locale.CHINA);
return instance.compare(name1, name2);
}
});
//JsonUtil.toJSON(depts)
RespUtil.returnResult(request,response, JsonUtil.toJSON(depts));
} catch (Exception e) {
logger.error(ExceptionUtil.printExceptionStackTrace(e));
}
return null;
}