JNBusinessTest/ruoyi-system/target/classes/mapper/system/SysNoticeMapper.xml

170 lines
7.3 KiB
XML
Raw Normal View History

2024-08-05 17:16:54 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysNoticeMapper">
<resultMap type="SysNotice" id="SysNoticeResult">
<result property="noticeId" column="notice_id" />
<result property="noticeTitle" column="notice_title" />
<result property="noticeType" column="notice_type" />
<result property="noticeContentBit" 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" />
</resultMap>
<sql id="selectNoticeVo">
select notice_id, notice_title, notice_type, notice_content, status, 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>
<select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult">
<include refid="selectNoticeVo"/>
<where>
<if test="noticeTitle != null and noticeTitle != ''">
AND notice_title like concat('%', #{noticeTitle}, '%')
</if>
<if test="noticeType != null and noticeType != ''">
AND notice_type = #{noticeType}
</if>
<if test="createBy != null and createBy != ''">
AND create_by like concat('%', #{createBy}, '%')
</if>
</where>
</select>
<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="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
<if test="noticeContentBit != null and noticeContentBit.length != 0">#{noticeContentBit}, </if>
<if test="status != null and status != ''">#{status}, </if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
getdate()
)
</insert>
<update id="updateNotice" parameterType="SysNotice">
update sys_notice
<set>
<if test="noticeTitle != null and noticeTitle != ''">notice_title = #{noticeTitle}, </if>
<if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
<if test="noticeContentBit != null and noticeContentBit.length != 0">notice_content = #{noticeContentBit}, </if>
<if test="status != null and status != ''">status = #{status}, </if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = getdate()
</set>
where notice_id = #{noticeId}
</update>
<delete id="deleteNoticeById" parameterType="Long">
delete from sys_notice where notice_id = #{noticeId}
</delete>
<delete id="deleteNoticeByIds" parameterType="Long">
delete from sys_notice where notice_id in
<foreach item="noticeId" collection="array" open="(" separator="," close=")">
#{noticeId}
</foreach>
</delete>
<select id="navbarNoticelist" resultType="SysNoticeUser">
select a.notice_id noticeId, a.notice_title noticeTitle, a.notice_type noticeType,b.sendUser,b.sendTime
from sys_notice a
inner join sys_user_notice b on a.notice_id = b.noticeId
<where>
and b.userId = #{userName}
and CONVERT(date, b.sendTime) = CONVERT(date, GETDATE())
and a.status = '0' and b.isRead = '0'
</where>
order by b.sendTime desc
</select>
<select id="navbarNoticeMorelist" resultType="SysNoticeUser">
select a.notice_id noticeId, a.notice_title noticeTitle, a.notice_type noticeType,b.sendUser,b.sendTime,b.isRead
from sys_notice a
inner join sys_user_notice b on a.notice_id = b.noticeId
<where>
and b.userId = #{currentUserName}
and a.notice_type = #{noticeType}
and a.status = '0'
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and datediff(d, b.sendTime, #{params.beginTime}) <![CDATA[<=]]> 0
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and datediff(d, b.sendTime, #{params.endTime}) <![CDATA[>=]]> 0
</if>
<if test="(params.beginTime == null or params.beginTime == '') and (params.endTime == null or params.endTime == '')"><!-- 结束时间检索 -->
and CONVERT(date, b.sendTime) = CONVERT(date, GETDATE())
</if>
</where>
order by b.sendTime desc
</select>
<insert id="insertNoticeUserBatch">
insert into sys_user_notice(noticeId,userId,sendUser,sendTime)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.noticeId,jdbcType=INTEGER},
#{item.userId,jdbcType=VARCHAR},
#{item.sendUser,jdbcType=VARCHAR},
#{item.sendTime,jdbcType=TIMESTAMP}
)
</foreach>
</insert>
<update id="updateSysNoticeUser" parameterType="SysNoticeUser">
update sys_user_notice set isRead = #{isRead} where noticeId = #{noticeId} and userId = #{userId}
</update>
<select id="listNoticeEventUser" resultType="NoticeUserSelect">
select a.notice_event_user_id userName, b.nick_name nickName
from sys_event_user a
inner join sys_user b on a.notice_event_user_id = b.user_name
where a.notice_event_type = #{noticeEventType}
</select>
<delete id="deleteNoticeEventUserByType" parameterType="String">
delete from sys_event_user where notice_event_type = #{noticeEventType}
</delete>
<insert id="insertNoticeEventUserBatch">
insert into sys_event_user(notice_event_type,notice_event_user_id)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.noticeEventType,jdbcType=VARCHAR},
#{item.userName,jdbcType=VARCHAR}
)
</foreach>
</insert>
<delete id="deleteNoticeEventUser" parameterType="NoticeUserSelect">
delete from sys_event_user where notice_event_type = #{noticeEventType} and notice_event_user_id = #{userName}
</delete>
<select id="getSendEmp" resultType="String">
select notice_event_user_id from sys_event_user where notice_event_type = #{msgSendEmp}
</select>
</mapper>