| | |
| | | // @PreAuthorize("@ss.hasPermi('system:notice:query')") |
| | | @GetMapping(value = "/{noticeId}") |
| | | public AjaxResult getInfo(@PathVariable Long noticeId) { |
| | | return success(noticeService.selectNoticeById(noticeId)); |
| | | SysNotice byId = noticeService.getById(noticeId); |
| | | LambdaQueryWrapper<SysNoticeUser> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(SysNoticeUser::getNoticeId, noticeId); |
| | | List<SysNoticeUser> sysNoticeUsers = sysNoticeUserService.list(wq); |
| | | if(null != sysNoticeUsers && !sysNoticeUsers.isEmpty()){ |
| | | List<String> longList = sysNoticeUsers.stream().map(i -> i.getUserId().toString()).collect(Collectors.toList()); |
| | | byId.setUserIds(longList); |
| | | } |
| | | return success(byId); |
| | | } |
| | | |
| | | /** |
| | |
| | | public AjaxResult add(@Validated @RequestBody SysNotice notice) { |
| | | notice.setCreateBy(getUsername()); |
| | | notice.setNoticeId(IdUtil.getSnowflake().nextId()); |
| | | int insertNotice = noticeService.insertNotice(notice); |
| | | if (insertNotice > 0){ |
| | | boolean insertNotice = noticeService.save(notice); |
| | | if (insertNotice){ |
| | | if (notice.getUserIds() == null || notice.getUserIds().isEmpty()){ |
| | | if (StrUtil.isBlank(notice.getDeptId())){ |
| | | notice.setUserIds(userService.list().stream().map(i -> String.valueOf(i.getUserId())).collect(Collectors.toList())); |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysNotice notice) { |
| | | notice.setUpdateBy(getUsername()); |
| | | return toAjax(noticeService.updateNotice(notice)); |
| | | List<String> userIds = notice.getUserIds(); |
| | | if (noticeService.updateById(notice)) { |
| | | if(null !=userIds && !userIds.isEmpty()){ |
| | | LambdaQueryWrapper<SysNoticeUser> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(SysNoticeUser::getNoticeId, notice.getNoticeId()); |
| | | sysNoticeUserService.remove(wq); |
| | | for (String userId : userIds) { |
| | | SysNoticeUser user = new SysNoticeUser(); |
| | | user.setId(IdUtil.getSnowflake().nextId()); |
| | | user.setNoticeId(notice.getNoticeId()); |
| | | user.setUserId(Long.valueOf(userId)); |
| | | sysNoticeUserService.save(user); |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | /** |