cm-cloud/cloud-common-plugin-sensitive/target/classes/mybatis/mapper/mapper-sensitivewords.xml

130 lines
3.9 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.plugin.dao.ISensitiveWordsDao">
<resultMap id="sensitiveWordsDTO" type="com.cm.plugin.pojo.dtos.SensitiveWordsDTO">
<id column="sensitive_words_id" property="sensitiveWordsId"/>
<result column="name" property="name"/>
<result column="message" property="message"/>
</resultMap>
<!-- 新增敏感词 -->
<insert id="saveSensitiveWords" parameterType="map">
INSERT INTO sys_sensitive_words(
sensitive_words_id,
name,
message,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{sensitiveWordsId},
#{name},
#{message},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除敏感词 -->
<update id="removeSensitiveWords" parameterType="map">
UPDATE
sys_sensitive_words
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
sensitive_words_id IN
<foreach collection="sensitiveWordsIds" index="index" open="(" separator="," close=")">
#{sensitiveWordsIds[${index}]}
</foreach>
</update>
<!-- 修改敏感词 -->
<update id="updateSensitiveWords" parameterType="map">
UPDATE
sys_sensitive_words
SET
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="message != null and message != ''">
message = #{message},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
sensitive_words_id = #{sensitiveWordsId}
</update>
<!-- 敏感词详情 -->
<select id="getSensitiveWords" parameterType="map" resultMap="sensitiveWordsDTO">
SELECT
t1.name,
t1.message,
t1.sensitive_words_id
FROM
sys_sensitive_words t1
WHERE
t1.is_delete = 0
<if test="sensitiveWordsId != null and sensitiveWordsId != ''">
AND
t1.sensitive_words_id = #{sensitiveWordsId}
</if>
</select>
<!-- 敏感词列表 -->
<select id="listSensitiveWords" parameterType="map" resultMap="sensitiveWordsDTO">
SELECT
t1.name,
t1.message,
t1.sensitive_words_id
FROM
sys_sensitive_words t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.name LIKE CONCAT('%', #{keywords}, '%')
OR
t1.message LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="sensitiveWordsIds != null and sensitiveWordsIds.size > 0">
AND
t1.sensitive_words_id IN
<foreach collection="sensitiveWordsIds" index="index" open="(" separator="," close=")">
#{sensitiveWordsIds[${index}]}
</foreach>
</if>
</select>
<!-- 敏感词列表 -->
<select id="listSensitiveWordsForString" resultType="java.lang.String">
SELECT
t1.name
FROM
sys_sensitive_words t1
WHERE
t1.is_delete = 0
GROUP BY
t1.name
ORDER BY
t1.name
</select>
</mapper>