zjh
2025-06-20 5f1d1c462bbf49bc6a22b9e17b49733bcc1e0bc6
ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysNoticeController.java
@@ -55,6 +55,15 @@
    public TableDataInfo list(SysNotice notice) {
        startPage();
        List<SysNotice> list = noticeService.selectNoticeList(notice);
        for (SysNotice sysNotice : list) {
            LambdaQueryWrapper<SysNoticeUser> wq = new LambdaQueryWrapper<>();
            wq.eq(SysNoticeUser::getNoticeId, sysNotice.getNoticeId());
            List<SysNoticeUser> sysNoticeUsers = sysNoticeUserService.list(wq);
            if(null != sysNoticeUsers && !sysNoticeUsers.isEmpty()){
                List<String> longList = sysNoticeUsers.stream().map(i -> i.getUserId().toString()).collect(Collectors.toList());
                sysNotice.setUserIds(longList);
            }
        }
        return getDataTable(list);
    }
@@ -64,7 +73,15 @@
//    @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);
    }
    /**
@@ -77,8 +94,8 @@
    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()));
@@ -107,7 +124,24 @@
    @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();
    }
    /**