cm-cloud/cloud-common-websocket/src/main/resources/mybatis/mapper/notice-mapper.xml
2021-03-30 13:20:25 +08:00

209 lines
6.0 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.cm.websocket.dao.INoticeDao">
<resultMap id="noticePO" type="com.cm.websocket.pojo.pos.NoticePO">
<id column="id" property="id"/>
<result column="notice_id" property="noticeId"/>
<result column="notice_title" property="noticeTitle"/>
<result column="notice_msg" property="noticeMsg"/>
<result column="notice_target" property="noticeTarget"/>
<result column="notice_system" property="noticeSystem"/>
<result column="notice_module" property="noticeModule"/>
<result column="notice_menu" property="noticeMenu"/>
<result column="notice_service_id" property="noticeServiceId"/>
<result column="user_id" property="userId"/>
<result column="is_handle" property="isHandle"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="creator" property="creator"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="modifier" property="modifier"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<!-- 保存 -->
<insert id="save" parameterType="map">
INSERT INTO socket_notice(
notice_id,
notice_title,
notice_msg,
notice_target,
notice_system,
notice_module,
notice_menu,
notice_service_id,
user_id,
is_handle,
gmt_create,
creator,
gmt_modified,
modifier,
is_delete
) VALUES(
#{noticeId},
#{noticeTitle},
#{noticeMsg},
#{noticeTarget},
#{noticeSystem},
#{noticeModule},
#{noticeMenu},
#{noticeServiceId},
#{userId},
#{isHandle},
#{gmtCreate},
#{creator},
#{gmtModified},
#{modifier},
#{isDelete}
)
</insert>
<!-- 更新已办状态 -->
<update id="updateHandle" parameterType="map">
UPDATE
socket_notice
SET
is_handle = #{isHandle},
gmt_modified = #{gmtModified},
modifier = #{modifier}
WHERE
notice_system = #{noticeSystem}
AND
notice_service_id = #{noticeServiceId}
</update>
<!-- 列表 -->
<select id="listPO" parameterType="map" resultMap="noticePO">
SELECT
notice_id,
notice_title,
notice_msg,
notice_target,
notice_system,
notice_module,
notice_menu,
notice_service_id,
user_id,
is_handle,
gmt_create,
creator,
gmt_modified,
modifier,
is_delete
FROM
socket_notice
WHERE
is_delete = 0
<if test="noticeSystem != null and noticeSystem != ''">
AND
notice_system = #{noticeSystem}
</if>
<if test="noticeModule != null and noticeModule != ''">
AND
notice_module = #{noticeModule}
</if>
<if test="noticeMenu != null and noticeMenu">
AND
notice_menu = #{noticeMenu}
</if>
<if test="userId != null and userId != ''">
AND
user_id = #{userId}
</if>
<if test="isHandle != null">
AND
is_handle = #{isHandle}
</if>
</select>
<!-- 系统列表 -->
<select id="listSystems" parameterType="map" resultType="java.lang.String">
SELECT
notice_system
FROM
socket_notice
WHERE
is_delete = 0
<if test="userId != null and userId != ''">
AND
user_id = #{userId}
</if>
GROUP BY
notice_system
</select>
<!-- 模块列表 -->
<select id="listModules" parameterType="map" resultType="java.lang.String">
SELECT
notice_module
FROM
socket_notice
WHERE
is_delete = 0
<if test="userId != null and userId != ''">
AND
user_id = #{userId}
</if>
<if test="noticeSystem != null and noticeSystem != ''">
AND
notice_system = #{noticeSystem}
</if>
GROUP BY
notice_module
</select>
<!-- 菜单列表 -->
<select id="listMenus" parameterType="map" resultType="java.lang.String">
SELECT
notice_menu
FROM
socket_notice
WHERE
is_delete = 0
<if test="userId != null and userId != ''">
AND
user_id = #{userId}
</if>
<if test="noticeSystem != null and noticeSystem != ''">
AND
notice_system = #{noticeSystem}
</if>
<if test="noticeModule != null and noticeModule != ''">
AND
notice_module = #{noticeModule}
</if>
GROUP BY
notice_menu
</select>
<!-- 统计 -->
<select id="count" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
socket_notice
WHERE
is_delete = 0
<if test="userId != null and userId != ''">
AND
user_id = #{userId}
</if>
<if test="noticeSystem != null and noticeSystem != ''">
AND
notice_system = #{noticeSystem}
</if>
<if test="noticeModule != null and noticeModule != ''">
AND
notice_module = #{noticeModule}
</if>
<if test="noticeMenu != null and noticeMenu != ''">
AND
notice_menu = #{noticeMenu}
</if>
<if test="isHandle != null">
AND
is_handle = #{isHandle}
</if>
</select>
</mapper>