完成用户未读消息数目接口后端实现
@GetMapping("/notice_sum")
public Result<Integer> getNoticeSum(@RequestParam Integer userId) {
Integer sum = null;
User user = userService.getUserById(userId);
Integer permission = user.getPermission();
Integer companyId = (userService.getCompanyByUserId(userId)).getCompanyId();
if (permission == 1|| permission == 2){
List<Notice> ln = noticeService.getUserNoticeListByToId(userId,false);
sum = ln.size();
}
if (permission == 3 || permission ==4){
List<Notice> ln = noticeService.getUserNoticeListByToId(userId, false);
System.out.println(ln);
sum = ln.size();
ln = noticeService.getUserNoticeListByToId(companyId, true);
sum = sum + ln.size();
}
return Result.success(sum);
}
@Override
public List<Notice> getUserNoticeListByToId (Integer toId, Boolean toType) {
return noticeRepository.findUnreadByToIdAndToTypeAndIsDealt(toId, toType, false);
}
接口:【完成】获取用户未读消息数目
└─ userId: Number (必选)
├─ code: Number
├─ errMsg: String
└─ data: Number