148 lines
5.4 KiB
XML
148 lines
5.4 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.zhwl.notice.mapper.ZdyNoticeMapper">
|
|
|
|
<resultMap type="ZdyNotice" id="ZdyNoticeResult">
|
|
<result property="id" column="id"/>
|
|
<result property="from" column="from"/>
|
|
<result property="userId" column="user_id"/>
|
|
<result property="linkId" column="link_id"/>
|
|
<result property="content" column="content"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="isRead" column="is_read"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectZdyNoticeVo">
|
|
select id,
|
|
`from`,
|
|
user_id,
|
|
link_id,
|
|
content,
|
|
create_time,
|
|
update_time,
|
|
is_read
|
|
from zdy_notice
|
|
</sql>
|
|
|
|
<select id="selectZdyNoticeList" parameterType="ZdyNotice" resultMap="ZdyNoticeResult">
|
|
<include refid="selectZdyNoticeVo"/>
|
|
<where>
|
|
<if test="from != null ">
|
|
and `from` = #{from}
|
|
</if>
|
|
<if test="userId != null ">
|
|
and user_id = #{userId}
|
|
</if>
|
|
<if test="linkId != null ">
|
|
and link_id = #{linkId}
|
|
</if>
|
|
<if test="content != null and content != ''">
|
|
and content = #{content}
|
|
</if>
|
|
<if test="isRead != null ">
|
|
and is_read = #{isRead}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectZdyNoticeById" parameterType="Integer"
|
|
resultMap="ZdyNoticeResult">
|
|
<include refid="selectZdyNoticeVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertZdyNotice" parameterType="ZdyNotice" useGeneratedKeys="true"
|
|
keyProperty="id">
|
|
insert into zdy_notice
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="from != null">`from`,
|
|
</if>
|
|
<if test="userId != null">user_id,
|
|
</if>
|
|
<if test="linkId != null">link_id,
|
|
</if>
|
|
<if test="content != null">content,
|
|
</if>
|
|
<if test="createTime != null">create_time,
|
|
</if>
|
|
<if test="updateTime != null">update_time,
|
|
</if>
|
|
<if test="isRead != null">is_read,
|
|
</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="from != null">#{from},
|
|
</if>
|
|
<if test="userId != null">#{userId},
|
|
</if>
|
|
<if test="linkId != null">#{linkId},
|
|
</if>
|
|
<if test="content != null">#{content},
|
|
</if>
|
|
<if test="createTime != null">#{createTime},
|
|
</if>
|
|
<if test="updateTime != null">#{updateTime},
|
|
</if>
|
|
<if test="isRead != null">#{isRead},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateZdyNotice" parameterType="ZdyNotice">
|
|
update zdy_notice
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="from != null">`from` =
|
|
#{from},
|
|
</if>
|
|
<if test="userId != null">user_id =
|
|
#{userId},
|
|
</if>
|
|
<if test="linkId != null">link_id =
|
|
#{linkId},
|
|
</if>
|
|
<if test="content != null">content =
|
|
#{content},
|
|
</if>
|
|
<if test="createTime != null">create_time =
|
|
#{createTime},
|
|
</if>
|
|
<if test="updateTime != null">update_time =
|
|
#{updateTime},
|
|
</if>
|
|
<if test="isRead != null">is_read =
|
|
#{isRead},
|
|
</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteZdyNoticeById" parameterType="Integer">
|
|
delete from zdy_notice where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteZdyNoticeByIds" parameterType="String">
|
|
delete from zdy_notice where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
<select id="selectZdyNoticeNoRead" parameterType="Long" resultType="com.zhwl.notice.domain.vo.ZdyNoticeVo">
|
|
SELECT ti.id,
|
|
ti.link_id AS linkId,
|
|
dict.dict_label AS typeName,
|
|
IF((ue.`name` IS NOT NULL AND ue.`name` != ''), ue.`name`, ue.nickname) AS userName
|
|
FROM zdy_notice ti
|
|
LEFT JOIN zdy_cms_report re ON re.id = ti.link_id
|
|
LEFT JOIN sys_dict_data dict ON re.type = dict.dict_value
|
|
AND dict.dict_type = 'report_type'
|
|
LEFT JOIN zdy_user ue ON ue.id = re.user_id
|
|
where ti.user_id = #{userId}
|
|
and ti.is_read = 0
|
|
|
|
</select>
|
|
|
|
</mapper>
|