|
|
@@ -127,6 +127,50 @@ public class NoticeController extends BladeController {
|
|
|
return R.data(pages);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/myNoticePage")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入notice")
|
|
|
+ public R<IPage<NoticeVO>> myNoticePage(@ApiIgnore NoticeVO notice, Query query) {
|
|
|
+ notice.setCreateUser(AuthUtil.getUserId());
|
|
|
+ notice.setCurrentUserId(AuthUtil.getUserId());
|
|
|
+ IPage<NoticeVO> pages = noticeService.selectMyNoticePage(Condition.getPage(query), notice);
|
|
|
+
|
|
|
+ List<NoticeVO> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < pages.getRecords().size(); i++) {
|
|
|
+ Notice item = pages.getRecords().get(i);
|
|
|
+ NoticeVO noticeVO = Objects.requireNonNull(BeanUtil.copy(item, NoticeVO.class));
|
|
|
+
|
|
|
+ List<String> roleName = SysCache.getRoleNames(noticeVO.getRoleId());
|
|
|
+ List<String> deptName = SysCache.getDeptNames(noticeVO.getDeptId());
|
|
|
+ noticeVO.setRoleName(Func.join(roleName));
|
|
|
+ noticeVO.setDeptName(Func.join(deptName));
|
|
|
+ List<User> userList = userService.getUsersByIds(noticeVO.getTargetIds());
|
|
|
+ List<String> targetNames = userList.stream().map(user -> user.getName()).collect(Collectors.toList());
|
|
|
+ String join = StringUtil.join(targetNames, " | ");
|
|
|
+ noticeVO.setTargetNames(join);
|
|
|
+
|
|
|
+ Integer hadRead = 0;
|
|
|
+ if (noticeVO.getReadIds() != null && noticeVO.getReadIds().contains(AuthUtil.getUserId()+"")){
|
|
|
+ hadRead = 1;
|
|
|
+ }
|
|
|
+ noticeVO.setHadRead(hadRead);
|
|
|
+
|
|
|
+ if (noticeVO.getType().equals("0")){
|
|
|
+ noticeVO.setCreateUserName("系統");
|
|
|
+ }else{
|
|
|
+ User user = userService.getById(noticeVO.getCreateUser());
|
|
|
+ noticeVO.setCreateUserName(user.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ list.add(noticeVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ pages.setRecords(list);
|
|
|
+ return R.data(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 新增
|
|
|
*/
|
|
|
@@ -155,7 +199,6 @@ public class NoticeController extends BladeController {
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入notice")
|
|
|
public R submit(@RequestBody Notice notice) {
|
|
|
|
|
|
- notice.setReadIds(AuthUtil.getUserId()+"");
|
|
|
if (StringUtil.isBlank(notice.getTargetIds())){
|
|
|
List<String> deptIds = Func.toStrList(notice.getDeptId());
|
|
|
List<String> roleIds = Func.toStrList(notice.getRoleId());
|
|
|
@@ -178,4 +221,46 @@ public class NoticeController extends BladeController {
|
|
|
return R.status(temp);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 已讀記錄
|
|
|
+ */
|
|
|
+ @PostMapping("/setHadRead")
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
+ @ApiOperation(value = "已讀記錄", notes = "传入notice")
|
|
|
+ public R setHadRead(@ApiParam(value = "主键集合") @RequestParam String ids) {
|
|
|
+ List<Long> longs = Func.toLongList(ids);
|
|
|
+ longs.forEach(id -> {
|
|
|
+ Notice notice = noticeService.getById(id);
|
|
|
+ if (notice.getReadIds() == null){
|
|
|
+ notice.setReadIds(AuthUtil.getUserId()+"");
|
|
|
+ }else{
|
|
|
+ notice.setReadIds(notice.getReadIds() + "," + AuthUtil.getUserId());
|
|
|
+ }
|
|
|
+ noticeService.updateById(notice);
|
|
|
+ });
|
|
|
+ return R.status(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 已讀記錄
|
|
|
+ */
|
|
|
+ @PostMapping("/setAllHadRead")
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
+ @ApiOperation(value = "已讀記錄", notes = "传入notice")
|
|
|
+ public R setAllHadRead() {
|
|
|
+
|
|
|
+ List<Notice> list = noticeService.selectMyNoticeAll();
|
|
|
+
|
|
|
+ list.forEach(notice -> {
|
|
|
+ if (notice.getReadIds() == null){
|
|
|
+ notice.setReadIds(AuthUtil.getUserId()+"");
|
|
|
+ }else{
|
|
|
+ notice.setReadIds(notice.getReadIds() + "," + AuthUtil.getUserId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return R.status(noticeService.updateBatchById(list));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|