| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | */ |
| | | @ApiOperation("消息通知分页列表") |
| | | @PostMapping("/pageList") |
| | | public R<PageInfo<NotificationVO>> pageList(@RequestBody NotificationListQuery query) { |
| | | public R<PageInfo<NotificationVO>> pageList(@RequestBody NotificationListQuery query |
| | | ) { |
| | | return R.ok(oaNotificationService.pageList(query)); |
| | | } |
| | | |
| | |
| | | @DeleteMapping(value = "/delete") |
| | | public R delete(@RequestParam String ids) { |
| | | List<String> notificationIds = Arrays.asList(ids.split(",")); |
| | | List<Integer> idsList = new ArrayList<>(); |
| | | for (String notificationId : notificationIds) { |
| | | idsList.add(Integer.parseInt(notificationId)); |
| | | } |
| | | // 删除后 将已发送的消息通知一并删除 |
| | | oaNotificationService.removeBatchByIds(notificationIds); |
| | | oaNotificationService.removeBatchByIds(idsList); |
| | | oaNotifationUserService.remove(new LambdaQueryWrapper<OaNotificationUser>() |
| | | .in(OaNotificationUser::getNotificationId,notificationIds)); |
| | | .in(OaNotificationUser::getNotificationId,idsList)); |
| | | return R.ok(); |
| | | } |
| | | @Log(title = "消息通知-新增消息", businessType = BusinessType.INSERT) |
| | |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> add( @RequestBody OaNotification dto) { |
| | | oaNotificationService.save(dto); |
| | | ArrayList<OaNotificationUser> oaNotificationUsers = new ArrayList<>(); |
| | | // 发送消息通知 |
| | | if (dto.getType()){ |
| | | // 指定人员发送 |
| | | Arrays.asList(dto.getUserIds().split(",")) |
| | | .forEach(userId -> { |
| | | OaNotificationUser oaNotificationUser = new OaNotificationUser(); |
| | | oaNotificationUser.setUserId(Integer.parseInt(userId)); |
| | | oaNotificationUser.setNotificationId(dto.getId()); |
| | | oaNotificationUsers.add(oaNotificationUser); |
| | | }); |
| | | }else{ |
| | | // 所有人发送 |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | sysUsers.forEach(sysUser -> { |
| | | OaNotificationUser oaNotificationUser = new OaNotificationUser(); |
| | | oaNotificationUser.setUserId(sysUser.getUserId().intValue()); |
| | | oaNotificationUser.setNotificationId(dto.getId()); |
| | | oaNotificationUsers.add(oaNotificationUser); |
| | | }); |
| | | } |
| | | oaNotifationUserService.saveBatch(oaNotificationUsers); |
| | | return R.ok(); |
| | | } |
| | | @Log(title = "消息通知-编辑消息", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "编辑消息") |
| | | @PostMapping(value = "/edit") |
| | | public R<Boolean> edit( @RequestBody OaNotification dto) { |
| | | oaNotificationService.updateById(dto); |
| | | // 删除消息通知 |
| | | oaNotifationUserService.remove(new LambdaQueryWrapper<OaNotificationUser>() |
| | | .eq(OaNotificationUser::getNotificationId,dto.getId())); |
| | | ArrayList<OaNotificationUser> oaNotificationUsers = new ArrayList<>(); |
| | | // 发送消息通知 |
| | | if (dto.getType()){ |
| | |
| | | } |
| | | |
| | | notificationDetailVO.setNotificationUserDetailVOS(notificationUserDetailVOS); |
| | | return R.ok(); |
| | | return R.ok(notificationDetailVO); |
| | | } |
| | | } |
| | | |