系统公告优化
parent
2deb45a61b
commit
535e96ed02
|
@ -6,8 +6,8 @@ import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 常用功能工具类
|
||||||
* @ClassName GtlUtil
|
* @ClassName GtlUtil
|
||||||
* @Description 常用功能工具类
|
|
||||||
* @Author gtl
|
* @Author gtl
|
||||||
*/
|
*/
|
||||||
public class GtlUtil {
|
public class GtlUtil {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.Result;
|
import com.ruoyi.common.core.domain.Result;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
@ -26,6 +27,29 @@ public class SysNoticeController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysNoticeService noticeService;
|
private SysNoticeService noticeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户的通知公告列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:notice:list")
|
||||||
|
@GetMapping
|
||||||
|
public Result<Object> listByLoginUser (String noticeType,String isReady) {
|
||||||
|
List<SysNotice> list = noticeService.getListByLoginUser(noticeType);
|
||||||
|
if(StringUtils.isNotEmpty(isReady)){
|
||||||
|
list=list.stream().filter(sysNotice -> sysNotice.getIsReady().equals(isReady)).toList();
|
||||||
|
}
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改公告为已读
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:notice:edit")
|
||||||
|
@PutMapping("/{noticeId}")
|
||||||
|
public Result<Object> edit (@PathVariable Long noticeId) {
|
||||||
|
noticeService.isReadyEdit(noticeId);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取通知公告列表
|
* 获取通知公告列表
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +77,6 @@ public class SysNoticeController extends BaseController {
|
||||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result add (@Validated @RequestBody SysNotice notice) {
|
public Result add (@Validated @RequestBody SysNotice notice) {
|
||||||
notice.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(noticeService.insertNotice(notice));
|
return toAjax(noticeService.insertNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +87,6 @@ public class SysNoticeController extends BaseController {
|
||||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Result edit (@Validated @RequestBody SysNotice notice) {
|
public Result edit (@Validated @RequestBody SysNotice notice) {
|
||||||
notice.setUpdateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(noticeService.updateNotice(notice));
|
return toAjax(noticeService.updateNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知公告表 sys_notice
|
* 通知公告表 sys_notice
|
||||||
|
@ -46,11 +47,46 @@ public class SysNotice extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String noticeContent;
|
private String noticeContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ids
|
||||||
|
*/
|
||||||
|
private String userIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门ids
|
||||||
|
*/
|
||||||
|
private String deptIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
private Date failureTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告状态(0正常 1关闭)
|
* 公告状态(0正常 1关闭)
|
||||||
*/
|
*/
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已读
|
||||||
|
*/
|
||||||
|
private String isReady="N";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总通知数量
|
||||||
|
*/
|
||||||
|
private long count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已阅读通知数量
|
||||||
|
*/
|
||||||
|
private long isReadyCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未阅读通知数量
|
||||||
|
*/
|
||||||
|
private long isNotReadyCount;
|
||||||
|
|
||||||
public Long getNoticeId () {
|
public Long getNoticeId () {
|
||||||
return noticeId;
|
return noticeId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sys_notice_user
|
||||||
|
*
|
||||||
|
* @author gtl
|
||||||
|
* @date 2024-04-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("sys_notice_user")
|
||||||
|
public class SysNoticeUser implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 编号 */
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 通知 */
|
||||||
|
private Long noticeId;
|
||||||
|
|
||||||
|
/** 用户 */
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** 是否已读 */
|
||||||
|
private String isReady;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询公告信息
|
* 查询公告信息
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ruoyi.system.domain.SysNoticeUser;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName SysNoticeUserMapper
|
||||||
|
* @Author 森静若林
|
||||||
|
* @Date 2024/4/13 17:59
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysNoticeUserMapper extends BaseMapper<SysNoticeUser> {
|
||||||
|
}
|
|
@ -3,7 +3,6 @@ package com.ruoyi.system.mapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.ruoyi.common.system.domain.SysUser;
|
import com.ruoyi.common.system.domain.SysUser;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,4 +64,16 @@ public interface SysNoticeService extends IService<SysNotice> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteNoticeByIds (Long[] noticeIds);
|
public int deleteNoticeByIds (Long[] noticeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录人的公告信息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
List<SysNotice> getListByLoginUser(String type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改为已读状态
|
||||||
|
*/
|
||||||
|
void isReadyEdit(Long noticeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.common.system.domain.SysUser;
|
import com.ruoyi.common.system.domain.SysUser;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -225,4 +224,13 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id集合
|
||||||
|
*
|
||||||
|
* @param deptIdList 部门id数据列表
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
List<Long> selectByDeptIds(List<Long> deptIdList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,26 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.system.domain.SysDept;
|
||||||
|
import com.ruoyi.common.system.domain.SysUser;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
|
import com.ruoyi.system.domain.SysNoticeUser;
|
||||||
import com.ruoyi.system.mapper.SysNoticeMapper;
|
import com.ruoyi.system.mapper.SysNoticeMapper;
|
||||||
|
import com.ruoyi.system.mapper.SysNoticeUserMapper;
|
||||||
|
import com.ruoyi.system.service.SysDeptService;
|
||||||
import com.ruoyi.system.service.SysNoticeService;
|
import com.ruoyi.system.service.SysNoticeService;
|
||||||
|
import com.ruoyi.system.service.SysUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告 服务层实现
|
* 公告 服务层实现
|
||||||
|
@ -19,6 +32,15 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysNoticeMapper noticeMapper;
|
private SysNoticeMapper noticeMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysNoticeUserMapper sysNoticeUserMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysDeptService sysDeptService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询公告信息
|
* 查询公告信息
|
||||||
*
|
*
|
||||||
|
@ -28,7 +50,24 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysNotice selectNoticeById (Long noticeId) {
|
public SysNotice selectNoticeById (Long noticeId) {
|
||||||
return noticeMapper.selectNoticeById(noticeId);
|
SysNotice sysNotice = noticeMapper.selectNoticeById(noticeId);
|
||||||
|
if(sysNotice.getNoticeType().equals("2")){
|
||||||
|
List<SysUser> sysUsers = sysUserService.selectUserList(new SysUser());
|
||||||
|
long isReadyCount = sysNoticeUserMapper.selectList(new LambdaQueryWrapper<SysNoticeUser>()
|
||||||
|
.eq(SysNoticeUser::getNoticeId, noticeId))
|
||||||
|
.stream().filter(sysNoticeUser -> sysNoticeUser.getIsReady().equals("Y")).count();
|
||||||
|
sysNotice.setCount(sysUsers.size());
|
||||||
|
sysNotice.setIsReadyCount(isReadyCount);
|
||||||
|
sysNotice.setIsNotReadyCount(sysUsers.size() - isReadyCount);
|
||||||
|
}else {
|
||||||
|
List<SysNoticeUser> list = sysNoticeUserMapper.selectList(new LambdaQueryWrapper<SysNoticeUser>()
|
||||||
|
.eq(SysNoticeUser::getNoticeId, noticeId));
|
||||||
|
sysNotice.setCount(list.size());
|
||||||
|
long isReadyCount = list.stream().filter(sysNoticeUser -> sysNoticeUser.getIsReady().equals("Y")).count();
|
||||||
|
sysNotice.setIsReadyCount(isReadyCount);
|
||||||
|
sysNotice.setIsNotReadyCount(list.size() - isReadyCount);
|
||||||
|
}
|
||||||
|
return sysNotice;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +91,56 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertNotice (SysNotice notice) {
|
public int insertNotice (SysNotice notice) {
|
||||||
return noticeMapper.insertNotice(notice);
|
notice.setCreateBy(this.spliceCreateBy());
|
||||||
|
int insert = noticeMapper.insertNotice(notice);
|
||||||
|
this.addSysNoticeUser(notice.getNoticeId(),notice.getDeptIds(),notice.getUserIds());
|
||||||
|
return insert;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼接创建者字符串
|
||||||
|
* @return createBy
|
||||||
|
*/
|
||||||
|
public String spliceCreateBy(){
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(SecurityUtils.getUserId());
|
||||||
|
String postGroup = sysUserService.selectUserPostGroup(SecurityUtils.getUsername());
|
||||||
|
SysDept sysDept = sysDeptService.selectDeptById(sysUser.getDeptId());
|
||||||
|
if(postGroup.contains(",")){
|
||||||
|
String[] split = postGroup.split(",");
|
||||||
|
postGroup=split[0];
|
||||||
|
}
|
||||||
|
return SecurityUtils.getUsername()+"("+sysDept.getDeptName()+"/"+postGroup+")";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加中间表
|
||||||
|
* @param noticeId 公告编号
|
||||||
|
* @param deptIds 部门编号字符串
|
||||||
|
* @param userIds 用户编号字符串
|
||||||
|
*/
|
||||||
|
public void addSysNoticeUser(Long noticeId,String deptIds,String userIds){
|
||||||
|
List<Long> longList=new ArrayList<>();
|
||||||
|
if(StringUtils.isNotEmpty(deptIds)){
|
||||||
|
String[] dept = deptIds.split(",");
|
||||||
|
longList = Arrays.stream(dept).map(Convert::toLong).toList();
|
||||||
|
sysUserService.selectByDeptIds(longList).stream().map(id -> {
|
||||||
|
return SysNoticeUser.builder()
|
||||||
|
.noticeId(noticeId)
|
||||||
|
.userId(id).build();
|
||||||
|
}).toList().forEach(sysNoticeUserMapper::insert);
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotEmpty(userIds)){
|
||||||
|
String[] user = userIds.split(",");
|
||||||
|
for (String userName : user) {
|
||||||
|
SysUser sysUser = sysUserService.selectUserByUserNameOrEmail(userName);
|
||||||
|
if(!longList.contains(sysUser.getDeptId())){
|
||||||
|
SysNoticeUser build = SysNoticeUser.builder()
|
||||||
|
.noticeId(noticeId)
|
||||||
|
.userId(sysUser.getUserId()).build();
|
||||||
|
sysNoticeUserMapper.insert(build);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,6 +152,15 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateNotice (SysNotice notice) {
|
public int updateNotice (SysNotice notice) {
|
||||||
|
notice.setCreateBy(this.spliceCreateBy());
|
||||||
|
notice.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
String deptIds = notice.getDeptIds();
|
||||||
|
String userIds = notice.getUserIds();
|
||||||
|
//删除中间表
|
||||||
|
sysNoticeUserMapper.delete(new LambdaQueryWrapper<SysNoticeUser>()
|
||||||
|
.in(SysNoticeUser::getNoticeId,notice.getNoticeId()));
|
||||||
|
//添加中间表
|
||||||
|
this.addSysNoticeUser(notice.getNoticeId(),deptIds,userIds);
|
||||||
return noticeMapper.updateNotice(notice);
|
return noticeMapper.updateNotice(notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,4 +187,64 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||||
public int deleteNoticeByIds (Long[] noticeIds) {
|
public int deleteNoticeByIds (Long[] noticeIds) {
|
||||||
return noticeMapper.deleteNoticeByIds(noticeIds);
|
return noticeMapper.deleteNoticeByIds(noticeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录人的公告信息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysNotice> getListByLoginUser(String type) {
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
SysNotice sysNotice = new SysNotice();
|
||||||
|
if(StringUtils.isNotEmpty(type)){
|
||||||
|
sysNotice.setNoticeType(type);
|
||||||
|
}
|
||||||
|
List<SysNotice> sysNotices = noticeMapper.selectNoticeList(sysNotice);
|
||||||
|
insertSysNoticeUser(userId,sysNotices);
|
||||||
|
if(StringUtils.isNotEmpty(type)){
|
||||||
|
return sysNotices;
|
||||||
|
}
|
||||||
|
List<SysNoticeUser> list = sysNoticeUserMapper.selectList(new LambdaQueryWrapper<SysNoticeUser>()
|
||||||
|
.eq(SysNoticeUser::getUserId, userId));
|
||||||
|
List<SysNotice> sysNoticeList=new ArrayList<>();
|
||||||
|
if(StringUtils.isNotEmpty(list)){
|
||||||
|
list.forEach(sysNoticeUser -> {
|
||||||
|
SysNotice notice = noticeMapper.selectNoticeById(sysNoticeUser.getNoticeId());
|
||||||
|
notice.setIsReady(sysNoticeUser.getIsReady());
|
||||||
|
sysNoticeList.add(notice);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return sysNoticeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void isReadyEdit(Long noticeId) {
|
||||||
|
SysNoticeUser sysNoticeUser = new SysNoticeUser();
|
||||||
|
sysNoticeUser.setNoticeId(noticeId);
|
||||||
|
sysNoticeUser.setIsReady("Y");
|
||||||
|
sysNoticeUserMapper.update(sysNoticeUser,new LambdaUpdateWrapper<SysNoticeUser>()
|
||||||
|
.eq(SysNoticeUser::getNoticeId,noticeId)
|
||||||
|
.eq(SysNoticeUser::getUserId,SecurityUtils.getUserId())
|
||||||
|
.set(SysNoticeUser::getIsReady,"Y"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否有公告的中间表,没有则添加
|
||||||
|
* @param sysNotices 公告集合
|
||||||
|
*/
|
||||||
|
public void insertSysNoticeUser(Long userId,List<SysNotice> sysNotices){
|
||||||
|
sysNotices.forEach(sysNotice -> {
|
||||||
|
Long noticeId = sysNotice.getNoticeId();
|
||||||
|
SysNoticeUser sysNoticeUser = sysNoticeUserMapper.selectOne(new LambdaQueryWrapper<SysNoticeUser>()
|
||||||
|
.eq(SysNoticeUser::getNoticeId, noticeId)
|
||||||
|
.eq(SysNoticeUser::getUserId, userId));
|
||||||
|
if(Objects.isNull(sysNoticeUser)){
|
||||||
|
SysNoticeUser noticeUser = new SysNoticeUser();
|
||||||
|
noticeUser.setUserId(userId);
|
||||||
|
noticeUser.setNoticeId(noticeId);
|
||||||
|
sysNoticeUserMapper.insert(noticeUser);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -519,4 +517,22 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
return successMsg.toString();
|
return successMsg.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id集合
|
||||||
|
*
|
||||||
|
* @param deptIdList 部门id数据列表
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Long> selectByDeptIds(List<Long> deptIdList) {
|
||||||
|
List<Long> list=new ArrayList<>();
|
||||||
|
deptIdList.stream().map(id->SysUser.builder().deptId(id).build())
|
||||||
|
.forEach(user->{
|
||||||
|
List<Long> userIdList = userMapper.selectUserList(user).stream().map(SysUser::getUserId).toList();
|
||||||
|
list.addAll(userIdList);
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,14 @@
|
||||||
<result property="noticeTitle" column="notice_title"/>
|
<result property="noticeTitle" column="notice_title"/>
|
||||||
<result property="noticeType" column="notice_type"/>
|
<result property="noticeType" column="notice_type"/>
|
||||||
<result property="noticeContent" column="notice_content"/>
|
<result property="noticeContent" column="notice_content"/>
|
||||||
|
<result property="userIds" column="user_ids"/>
|
||||||
|
<result property="deptIds" column="dept_ids"/>
|
||||||
<result property="status" column="status"/>
|
<result property="status" column="status"/>
|
||||||
<result property="createBy" column="create_by"/>
|
<result property="createBy" column="create_by"/>
|
||||||
<result property="createTime" column="create_time"/>
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="updateBy" column="update_by"/>
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="failureTime" column="failure_time"/>
|
||||||
<result property="remark" column="remark"/>
|
<result property="remark" column="remark"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
@ -21,6 +24,9 @@
|
||||||
select notice_id,
|
select notice_id,
|
||||||
notice_title,
|
notice_title,
|
||||||
notice_type,
|
notice_type,
|
||||||
|
user_ids,
|
||||||
|
dept_ids,
|
||||||
|
failure_time,
|
||||||
cast(notice_content as char) as notice_content,
|
cast(notice_content as char) as notice_content,
|
||||||
status,
|
status,
|
||||||
create_by,
|
create_by,
|
||||||
|
@ -51,7 +57,7 @@
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertNotice" parameterType="com.ruoyi.system.domain.SysNotice">
|
<insert id="insertNotice" parameterType="com.ruoyi.system.domain.SysNotice" keyProperty="noticeId" useGeneratedKeys="true">
|
||||||
insert into sys_notice (
|
insert into sys_notice (
|
||||||
<if test="noticeTitle != null and noticeTitle != '' ">notice_title,</if>
|
<if test="noticeTitle != null and noticeTitle != '' ">notice_title,</if>
|
||||||
<if test="noticeType != null and noticeType != '' ">notice_type,</if>
|
<if test="noticeType != null and noticeType != '' ">notice_type,</if>
|
||||||
|
@ -59,6 +65,9 @@
|
||||||
<if test="status != null and status != '' ">status,</if>
|
<if test="status != null and status != '' ">status,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
<if test="deptIds != null and deptIds != ''">dept_ids,</if>
|
||||||
|
<if test="userIds != null and userIds != ''">user_ids,</if>
|
||||||
|
<if test="failureTime != null ">failure_time,</if>
|
||||||
create_time
|
create_time
|
||||||
)values(
|
)values(
|
||||||
<if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle},</if>
|
<if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle},</if>
|
||||||
|
@ -67,6 +76,9 @@
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
<if test="deptIds != null and deptIds != ''">#{deptIds},</if>
|
||||||
|
<if test="userIds != null and userIds != ''">#{userIds},</if>
|
||||||
|
<if test="failureTime != null ">#{failureTime},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
@ -78,7 +90,11 @@
|
||||||
<if test="noticeType != null and noticeType != ''">notice_type = #{noticeType},</if>
|
<if test="noticeType != null and noticeType != ''">notice_type = #{noticeType},</if>
|
||||||
<if test="noticeContent != null">notice_content = #{noticeContent},</if>
|
<if test="noticeContent != null">notice_content = #{noticeContent},</if>
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
<if test="status != null and status != ''">status = #{status},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
|
<if test="deptIds != null and deptIds != ''">dept_ids = #{deptIds},</if>
|
||||||
|
<if test="userIds != null and userIds != ''">user_ids = #{userIds},</if>
|
||||||
|
<if test="failureTime != null ">failure_time = #{failureTime},</if>
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</set>
|
</set>
|
||||||
where notice_id = #{noticeId}
|
where notice_id = #{noticeId}
|
||||||
|
|
Loading…
Reference in New Issue