change - 通知公告关联用户、可上传下载附件

master
yinq 4 months ago
parent 2c9281be86
commit 972b968753

@ -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
* sys_notice
*
* @author ruoyi
* @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<SysUserNotice> sysUserNoticeList;
/**
*
* List
*/
private List<Long> userNoticeList;
public List<Long> getUserNoticeList() {
return userNoticeList;
}
public void setUserNoticeList(List<Long> 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<SysUserNotice> getSysUserNoticeList() {
return sysUserNoticeList;
}
public void setSysUserNoticeList(List<SysUserNotice> 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();
}
}

@ -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();
}
}

@ -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<SysUserNotice> sysUserNoticeList);
/**
*
*
* @param noticeId ID
* @return
*/
public int deleteSysUserNoticeByNoticeId(Long noticeId);
}

@ -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<SysUserNotice> sysUserNoticeList = sysNotice.getSysUserNoticeList();
Long noticeId = sysNotice.getNoticeId();
if (StringUtils.isNotNull(sysUserNoticeList))
{
List<SysUserNotice> list = new ArrayList<>();
for (SysUserNotice sysUserNotice : sysUserNoticeList)
{
sysUserNotice.setNoticeId(noticeId);
list.add(sysUserNotice);
}
if (list.size() > 0)
{
noticeMapper.batchSysUserNotice(list);
}
}
}
}

@ -5,26 +5,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.hw.system.mapper.SysNoticeMapper">
<resultMap type="SysNotice" id="SysNoticeResult">
<result property="noticeId" column="notice_id" />
<result property="noticeId" column="notice_id" />
<result property="noticeTitle" column="notice_title" />
<result property="noticeType" column="notice_type" />
<result property="noticeContent" column="notice_content" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="noticeType" column="notice_type" />
<result property="noticeContent" column="notice_content" />
<result property="status" column="status" />
<result property="stationId" column="station_id" />
<result property="userGroupId" column="user_group_id" />
<result property="attachPath" column="attach_path" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<resultMap id="SysNoticeSysUserNoticeResult" type="SysNotice" extends="SysNoticeResult">
<collection property="sysUserNoticeList" notNullColumn="sub_notice_id" javaType="java.util.List" resultMap="SysUserNoticeResult" />
<collection property="userNoticeList" ofType="java.lang.Long">
<id column="sub_user_id" property="userNoticeList" />
</collection>
</resultMap>
<resultMap type="SysUserNotice" id="SysUserNoticeResult">
<result property="noticeId" column="sub_notice_id" />
<result property="userId" column="sub_user_id" />
<result property="checkStatus" column="sub_check_status" />
<result property="checkTime" column="sub_check_time" />
<result property="downloadStatus" column="sub_download_status" />
<result property="downloadTime" column="sub_download_time" />
</resultMap>
<sql id="selectNoticeVo">
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
</sql>
<select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult">
<include refid="selectNoticeVo"/>
where notice_id = #{noticeId}
<select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeSysUserNoticeResult">
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}
</select>
<select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult">
@ -42,12 +64,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<insert id="insertNotice" parameterType="SysNotice">
<insert id="insertNotice" parameterType="SysNotice" useGeneratedKeys="true" keyProperty="noticeId">
insert into sys_notice (
<if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
<if test="noticeType != null and noticeType != '' ">notice_type, </if>
<if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
<if test="status != null and status != '' ">status, </if>
<if test="stationId != null">station_id,</if>
<if test="userGroupId != null">user_group_id,</if>
<if test="attachPath != null">attach_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
@ -56,6 +81,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
<if test="status != null and status != ''">#{status}, </if>
<if test="stationId != null">#{stationId},</if>
<if test="userGroupId != null">#{userGroupId},</if>
<if test="attachPath != null and attachPath != ''">#{attachPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
@ -69,6 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
<if test="noticeContent != null">notice_content = #{noticeContent}, </if>
<if test="status != null and status != ''">status = #{status}, </if>
<if test="stationId != null">station_id = #{stationId},</if>
<if test="userGroupId != null">user_group_id = #{userGroupId},</if>
<if test="attachPath != null">attach_path = #{attachPath},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
@ -86,4 +117,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<delete id="deleteSysUserNoticeByNoticeIds" parameterType="String">
delete from sys_user_notice where notice_id in
<foreach item="noticeId" collection="array" open="(" separator="," close=")">
#{noticeId}
</foreach>
</delete>
<delete id="deleteSysUserNoticeByNoticeId" parameterType="Long">
delete from sys_user_notice where notice_id = #{noticeId}
</delete>
<insert id="batchSysUserNotice">
insert into sys_user_notice( notice_id, user_id) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.noticeId}, #{item.userId})
</foreach>
</insert>
</mapper>

@ -143,7 +143,7 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-col :span="12">
<el-form-item label="状态">
<el-radio-group v-model="form.status">
<el-radio
@ -154,9 +154,22 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="通知用户" >
<el-select v-model="form.userNoticeList" placeholder="请选择通知用户" multiple>
<el-option
v-for="item in userList"
:key="item.userId"
:label="item.nickName"
:value="item.userId"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="内容">
<editor v-model="form.noticeContent" :min-height="192"/>
<fileUpload v-model="form.attachPath"/>
</el-form-item>
</el-col>
</el-row>
@ -171,6 +184,7 @@
<script>
import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice";
import {findUserList} from "@/api/system/user";
export default {
name: "Notice",
@ -213,7 +227,9 @@ export default {
noticeType: [
{ required: true, message: "公告类型不能为空", trigger: "change" }
]
}
},
//List
userList: []
};
},
created() {
@ -241,6 +257,8 @@ export default {
noticeTitle: undefined,
noticeType: undefined,
noticeContent: undefined,
sysUserNoticeList: [],
userNoticeList: [],
status: "0"
};
this.resetForm("form");
@ -264,12 +282,18 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
findUserList({}).then(response => {
this.userList = response.data;
});
this.open = true;
this.title = "添加公告";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
findUserList({}).then(response => {
this.userList = response.data;
});
const noticeId = row.noticeId || this.ids
getNotice(noticeId).then(response => {
this.form = response.data;
@ -279,6 +303,9 @@ export default {
},
/** 提交按钮 */
submitForm: function() {
if (this.form.userNoticeList.length > 0){
this.form.sysUserNoticeList = this.form.userNoticeList.map(userId => ({ userId }));
}
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.noticeId != undefined) {

Loading…
Cancel
Save