通知列表排序

master
shijie 4 years ago
parent 05ee3ff6b3
commit 3625ec04d2
  1. 30
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java

@ -618,7 +618,6 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
public List notice() { public List notice() {
//获取当前用户id //获取当前用户id
String userId = dgApplyAmountInfoController.getUserId(); String userId = dgApplyAmountInfoController.getUserId();
//根据角色查询资产部调查列表 //根据角色查询资产部调查列表
String roleIds = RedisUtil.get("dq:userRole:" + userId); String roleIds = RedisUtil.get("dq:userRole:" + userId);
PageUtils data = null; PageUtils data = null;
@ -707,6 +706,35 @@ public class DgEfficiencyServiceImpl extends ServiceImpl<DgEfficiencyMapper, DgA
res.setModelId(10); res.setModelId(10);
list.add(res); list.add(res);
} }
List<DgNoticeListResponse> nowList = this.ListSort(list);
return nowList;
}
/**
* 根据时间排序其他排序如根据id排序也类似
* @param list
*/
public List<DgNoticeListResponse> ListSort(List<DgNoticeListResponse> list) {
//用Collections这个工具类传list进来排序
Collections.sort(list, new Comparator<DgNoticeListResponse>() {
@Override
public int compare(DgNoticeListResponse o1, DgNoticeListResponse o2) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date dt1 = format.parse(format.format(o1.getCreateTime()));
Date dt2 = format.parse(format.format(o2.getCreateTime()));
if (dt1.getTime() > dt2.getTime()) {
return -1;//大的放前面
}else {
return 1;
}
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
});
return list; return list;
} }
} }
Loading…
Cancel
Save