186 lines
6.8 KiB
XML
186 lines
6.8 KiB
XML
<?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.muyu.system.mapper.SysNoticeMapper">
|
|
|
|
<resultMap type="com.muyu.system.domain.SysNotice" id="SysNoticeResult">
|
|
<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"/>
|
|
</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
|
|
from sys_notice
|
|
</sql>
|
|
|
|
<select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult">
|
|
<include refid="selectNoticeVo"/>
|
|
where notice_id = #{noticeId}
|
|
</select>
|
|
|
|
<select id="selectNoticeList" parameterType="com.muyu.system.domain.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>
|
|
<select id="findByName" resultType="com.muyu.common.system.domain.SysUser">
|
|
select * from sys_user where user_name = #{name}
|
|
</select>
|
|
<select id="findByAllName" resultType="com.muyu.common.system.domain.SysUser">
|
|
select * from sys_user
|
|
</select>
|
|
<select id="finByNoticList" resultType="com.muyu.system.domain.model.NoticListModel">
|
|
|
|
select
|
|
id,
|
|
user_id,
|
|
notice_id,
|
|
create_by,
|
|
start_time,
|
|
end_time,
|
|
flag
|
|
from a_test
|
|
<if test="userId != null">
|
|
where user_id =#{userId}
|
|
</if>
|
|
|
|
</select>
|
|
<select id="findByNoticeId" resultType="com.muyu.system.domain.resp.NoticDetailReadNumResp">
|
|
SELECT
|
|
notice_id,
|
|
COUNT(*) AS totalNum,
|
|
SUM(CASE WHEN flag = 1 THEN 1 ELSE 0 END) AS readNum
|
|
FROM
|
|
a_test
|
|
GROUP BY
|
|
notice_id
|
|
</select>
|
|
<select id="selectNotice" resultType="com.muyu.system.domain.SysNotice">
|
|
SELECT
|
|
*
|
|
FROM a_test a
|
|
LEFT JOIN sys_user su on a.user_id=su.user_id
|
|
LEFT JOIN sys_notice sn on a.notice_id=sn.notice_id
|
|
WHERE su.user_id =#{userId}
|
|
</select>
|
|
|
|
|
|
<insert id="insertNotice" parameterType="com.muyu.system.domain.SysNotice" keyProperty="noticeId" useGeneratedKeys="true">
|
|
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="noticeContent != null and noticeContent != ''">#{noticeContent},</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>
|
|
sysdate()
|
|
)
|
|
</insert>
|
|
<insert id="addUserNotice">
|
|
INSERT INTO `ry-cloud`.`a_test`
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null and userId != ''">
|
|
user_id,
|
|
</if>
|
|
<if test="noticeId != null and noticeId != ''">
|
|
notice_id,
|
|
</if>
|
|
<if test="createBy != null and createBy != ''">
|
|
create_by,
|
|
</if>
|
|
<if test="startTime != null">
|
|
start_time,
|
|
</if>
|
|
<if test="endTime != null">
|
|
end_time
|
|
</if>
|
|
</trim>
|
|
VALUES
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null and userId != ''">
|
|
#{userId},
|
|
</if>
|
|
<if test="noticeId != null and noticeId != ''">
|
|
#{noticeId},
|
|
</if>
|
|
<if test="createBy != null and createBy != ''">
|
|
#{createBy},
|
|
</if>
|
|
<if test="startTime != null">
|
|
#{startTime},
|
|
</if>
|
|
<if test="endTime != null">
|
|
#{endTime}
|
|
</if>
|
|
</trim>
|
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateNotice" parameterType="com.muyu.system.domain.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="noticeContent != null">notice_content = #{noticeContent},</if>
|
|
<if test="status != null and status != ''">status = #{status},</if>
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
update_time = sysdate()
|
|
</set>
|
|
where notice_id = #{noticeId}
|
|
</update>
|
|
<update id="readNotic">
|
|
update a_test set flag = 1
|
|
where notice_id = #{noticeId} and user_id = #{userId}
|
|
</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>
|
|
|
|
</mapper>
|