diff --git a/hw-modules/hw-system/src/main/java/com/hw/system/domain/SysNotice.java b/hw-modules/hw-system/src/main/java/com/hw/system/domain/SysNotice.java index c2ef3d7..73fbdbc 100644 --- a/hw-modules/hw-system/src/main/java/com/hw/system/domain/SysNotice.java +++ b/hw-modules/hw-system/src/main/java/com/hw/system/domain/SysNotice.java @@ -1,102 +1,183 @@ package com.hw.system.domain; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; +import java.util.List; + +import com.hw.common.core.xss.Xss; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import com.hw.common.core.annotation.Excel; import com.hw.common.core.web.domain.BaseEntity; -import com.hw.common.core.xss.Xss; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; /** - * 通知公告表 sys_notice - * - * @author ruoyi + * 通知公告对象 sys_notice + * + * @author YinQ + * @date 2024-07-12 */ -public class SysNotice extends BaseEntity -{ +public class SysNotice extends BaseEntity { private static final long serialVersionUID = 1L; - /** 公告ID */ + /** + * 公告ID + */ private Long noticeId; - /** 公告标题 */ + /** + * 公告标题 + */ + @Excel(name = "公告标题") private String noticeTitle; - /** 公告类型(1通知 2公告) */ + /** + * 公告类型(1通知 2公告) + */ + @Excel(name = "公告类型", readConverterExp = "1=通知,2=公告") private String noticeType; - /** 公告内容 */ + /** + * 公告内容 + */ + @Excel(name = "公告内容") private String noticeContent; - /** 公告状态(0正常 1关闭) */ + /** + * 公告状态(0正常 1关闭) + */ + @Excel(name = "公告状态", readConverterExp = "0=正常,1=关闭") private String status; - public Long getNoticeId() - { - return noticeId; + /** + * 通知工位ID + */ + @Excel(name = "通知工位ID") + private String stationId; + + /** + * 用户组ID + */ + @Excel(name = "用户组ID") + private String userGroupId; + + /** + * 附件路径 + */ + @Excel(name = "附件路径") + private String attachPath; + + /** + * 用户和公告关联信息 + */ + private List sysUserNoticeList; + + /** + * 前端显示 + * 公告主键List + */ + private List userNoticeList; + + public List getUserNoticeList() { + return userNoticeList; + } + + public void setUserNoticeList(List userNoticeList) { + this.userNoticeList = userNoticeList; } - public void setNoticeId(Long noticeId) - { + public void setNoticeId(Long noticeId) { this.noticeId = noticeId; } - public void setNoticeTitle(String noticeTitle) - { + public Long getNoticeId() { + return noticeId; + } + + public void setNoticeTitle(String noticeTitle) { this.noticeTitle = noticeTitle; } @Xss(message = "公告标题不能包含脚本字符") @NotBlank(message = "公告标题不能为空") @Size(min = 0, max = 50, message = "公告标题不能超过50个字符") - public String getNoticeTitle() - { + public String getNoticeTitle() { return noticeTitle; } - public void setNoticeType(String noticeType) - { + public void setNoticeType(String noticeType) { this.noticeType = noticeType; } - public String getNoticeType() - { + public String getNoticeType() { return noticeType; } - public void setNoticeContent(String noticeContent) - { + public void setNoticeContent(String noticeContent) { this.noticeContent = noticeContent; } - public String getNoticeContent() - { + public String getNoticeContent() { return noticeContent; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getStatus() - { + public String getStatus() { return status; } + public void setStationId(String stationId) { + this.stationId = stationId; + } + + public String getStationId() { + return stationId; + } + + public void setUserGroupId(String userGroupId) { + this.userGroupId = userGroupId; + } + + public String getUserGroupId() { + return userGroupId; + } + + public void setAttachPath(String attachPath) { + this.attachPath = attachPath; + } + + public String getAttachPath() { + return attachPath; + } + + public List getSysUserNoticeList() { + return sysUserNoticeList; + } + + public void setSysUserNoticeList(List sysUserNoticeList) { + this.sysUserNoticeList = sysUserNoticeList; + } + @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("noticeId", getNoticeId()) - .append("noticeTitle", getNoticeTitle()) - .append("noticeType", getNoticeType()) - .append("noticeContent", getNoticeContent()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("noticeId", getNoticeId()) + .append("noticeTitle", getNoticeTitle()) + .append("noticeType", getNoticeType()) + .append("noticeContent", getNoticeContent()) + .append("status", getStatus()) + .append("stationId", getStationId()) + .append("userGroupId", getUserGroupId()) + .append("attachPath", getAttachPath()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("sysUserNoticeList", getSysUserNoticeList()) + .toString(); } } diff --git a/hw-modules/hw-system/src/main/java/com/hw/system/domain/SysUserNotice.java b/hw-modules/hw-system/src/main/java/com/hw/system/domain/SysUserNotice.java new file mode 100644 index 0000000..5130c1c --- /dev/null +++ b/hw-modules/hw-system/src/main/java/com/hw/system/domain/SysUserNotice.java @@ -0,0 +1,115 @@ +package com.hw.system.domain; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.hw.common.core.annotation.Excel; +import com.hw.common.core.web.domain.BaseEntity; + +/** + * 用户和公告关联对象 sys_user_notice + * + * @author YinQ + * @date 2024-07-12 + */ +public class SysUserNotice extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 公告ID + */ + private Long noticeId; + + /** + * 用户ID + */ + private Long userId; + + /** + * 查看状态(0未查看 1已查看) + */ + @Excel(name = "查看状态", readConverterExp = "0=未查看,1=已查看") + private String checkStatus; + + /** + * 查看时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "查看时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date checkTime; + + /** + * 下载状态(0未下载 1已下载) + */ + @Excel(name = "下载状态", readConverterExp = "0=未下载,1=已下载") + private String downloadStatus; + + /** + * 下载时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "下载时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date downloadTime; + + public void setNoticeId(Long noticeId) { + this.noticeId = noticeId; + } + + public Long getNoticeId() { + return noticeId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Long getUserId() { + return userId; + } + + public void setCheckStatus(String checkStatus) { + this.checkStatus = checkStatus; + } + + public String getCheckStatus() { + return checkStatus; + } + + public void setCheckTime(Date checkTime) { + this.checkTime = checkTime; + } + + public Date getCheckTime() { + return checkTime; + } + + public void setDownloadStatus(String downloadStatus) { + this.downloadStatus = downloadStatus; + } + + public String getDownloadStatus() { + return downloadStatus; + } + + public void setDownloadTime(Date downloadTime) { + this.downloadTime = downloadTime; + } + + public Date getDownloadTime() { + return downloadTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("noticeId", getNoticeId()) + .append("userId", getUserId()) + .append("checkStatus", getCheckStatus()) + .append("checkTime", getCheckTime()) + .append("downloadStatus", getDownloadStatus()) + .append("downloadTime", getDownloadTime()) + .toString(); + } +} diff --git a/hw-modules/hw-system/src/main/java/com/hw/system/mapper/SysNoticeMapper.java b/hw-modules/hw-system/src/main/java/com/hw/system/mapper/SysNoticeMapper.java index 78f2a53..a5c07af 100644 --- a/hw-modules/hw-system/src/main/java/com/hw/system/mapper/SysNoticeMapper.java +++ b/hw-modules/hw-system/src/main/java/com/hw/system/mapper/SysNoticeMapper.java @@ -2,6 +2,7 @@ package com.hw.system.mapper; import java.util.List; import com.hw.system.domain.SysNotice; +import com.hw.system.domain.SysUserNotice; /** * 通知公告表 数据层 @@ -57,4 +58,28 @@ public interface SysNoticeMapper * @return 结果 */ public int deleteNoticeByIds(Long[] noticeIds); + + /** + * 批量删除用户和公告关联 + * + * @param noticeIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSysUserNoticeByNoticeIds(Long[] noticeIds); + + /** + * 批量新增用户和公告关联 + * + * @param sysUserNoticeList 用户和公告关联列表 + * @return 结果 + */ + public int batchSysUserNotice(List sysUserNoticeList); + + /** + * 通过通知公告主键删除用户和公告关联信息 + * + * @param noticeId 通知公告ID + * @return 结果 + */ + public int deleteSysUserNoticeByNoticeId(Long noticeId); } \ No newline at end of file diff --git a/hw-modules/hw-system/src/main/java/com/hw/system/service/impl/SysNoticeServiceImpl.java b/hw-modules/hw-system/src/main/java/com/hw/system/service/impl/SysNoticeServiceImpl.java index 6e226c0..6c2b379 100644 --- a/hw-modules/hw-system/src/main/java/com/hw/system/service/impl/SysNoticeServiceImpl.java +++ b/hw-modules/hw-system/src/main/java/com/hw/system/service/impl/SysNoticeServiceImpl.java @@ -1,11 +1,17 @@ package com.hw.system.service.impl; +import java.util.ArrayList; import java.util.List; + +import com.hw.common.core.utils.StringUtils; +import com.hw.system.common.mapper.SysPointRouterMapper; +import com.hw.system.domain.SysUserNotice; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hw.system.domain.SysNotice; import com.hw.system.mapper.SysNoticeMapper; import com.hw.system.service.ISysNoticeService; +import org.springframework.transaction.annotation.Transactional; /** * 公告 服务层实现 @@ -18,6 +24,9 @@ public class SysNoticeServiceImpl implements ISysNoticeService @Autowired private SysNoticeMapper noticeMapper; + @Autowired + private SysPointRouterMapper pointRouterMapper; + /** * 查询公告信息 * @@ -48,10 +57,13 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @param notice 公告信息 * @return 结果 */ + @Transactional @Override public int insertNotice(SysNotice notice) { - return noticeMapper.insertNotice(notice); + int rows = noticeMapper.insertNotice(notice); + insertSysUserNotice(notice); + return rows; } /** @@ -60,9 +72,12 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @param notice 公告信息 * @return 结果 */ + @Transactional @Override public int updateNotice(SysNotice notice) { + noticeMapper.deleteSysUserNoticeByNoticeId(notice.getNoticeId()); + insertSysUserNotice(notice); return noticeMapper.updateNotice(notice); } @@ -72,9 +87,11 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @param noticeId 公告ID * @return 结果 */ + @Transactional @Override public int deleteNoticeById(Long noticeId) { + noticeMapper.deleteSysUserNoticeByNoticeId(noticeId); return noticeMapper.deleteNoticeById(noticeId); } @@ -84,9 +101,36 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @param noticeIds 需要删除的公告ID * @return 结果 */ + @Transactional @Override public int deleteNoticeByIds(Long[] noticeIds) { + noticeMapper.deleteSysUserNoticeByNoticeIds(noticeIds); return noticeMapper.deleteNoticeByIds(noticeIds); } + + /** + * 新增用户和公告关联信息 + * + * @param sysNotice 通知公告对象 + */ + public void insertSysUserNotice(SysNotice sysNotice) + { + List sysUserNoticeList = sysNotice.getSysUserNoticeList(); + Long noticeId = sysNotice.getNoticeId(); + if (StringUtils.isNotNull(sysUserNoticeList)) + { + List list = new ArrayList<>(); + for (SysUserNotice sysUserNotice : sysUserNoticeList) + { + sysUserNotice.setNoticeId(noticeId); + list.add(sysUserNotice); + } + if (list.size() > 0) + { + noticeMapper.batchSysUserNotice(list); + } + } + } + } diff --git a/hw-modules/hw-system/src/main/resources/mapper/system/SysNoticeMapper.xml b/hw-modules/hw-system/src/main/resources/mapper/system/SysNoticeMapper.xml index fa7ef91..0007371 100644 --- a/hw-modules/hw-system/src/main/resources/mapper/system/SysNoticeMapper.xml +++ b/hw-modules/hw-system/src/main/resources/mapper/system/SysNoticeMapper.xml @@ -5,26 +5,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark + select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, station_id, user_group_id, attach_path, create_by, create_time, update_by, update_time, remark from sys_notice - + select a.notice_id, a.notice_title, a.notice_type, a.notice_content, a.status, a.station_id, a.user_group_id, a.attach_path, a.create_by, a.create_time, a.update_by, a.update_time, a.remark, + b.notice_id as sub_notice_id, b.user_id as sub_user_id, b.check_status as sub_check_status, b.check_time as sub_check_time, b.download_status as sub_download_status, b.download_time as sub_download_time + from sys_notice a + left join sys_user_notice b on b.notice_id = a.notice_id + where a.notice_id = #{noticeId} - + insert into sys_notice ( notice_title, notice_type, notice_content, status, + station_id, + user_group_id, + attach_path, remark, create_by, create_time @@ -56,6 +81,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{noticeType}, #{noticeContent}, #{status}, + #{stationId}, + #{userGroupId}, + #{attachPath}, #{remark}, #{createBy}, sysdate() @@ -69,6 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" notice_type = #{noticeType}, notice_content = #{noticeContent}, status = #{status}, + station_id = #{stationId}, + user_group_id = #{userGroupId}, + attach_path = #{attachPath}, update_by = #{updateBy}, update_time = sysdate() @@ -85,5 +116,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{noticeId} + + + delete from sys_user_notice where notice_id in + + #{noticeId} + + + + + delete from sys_user_notice where notice_id = #{noticeId} + + + + insert into sys_user_notice( notice_id, user_id) values + + ( #{item.noticeId}, #{item.userId}) + + \ No newline at end of file diff --git a/hw-ui/src/views/system/notice/index.vue b/hw-ui/src/views/system/notice/index.vue index 19e25a0..78e399d 100644 --- a/hw-ui/src/views/system/notice/index.vue +++ b/hw-ui/src/views/system/notice/index.vue @@ -143,7 +143,7 @@ - + + + + + + + + + @@ -171,6 +184,7 @@ \ No newline at end of file +