cm-cloud/cloud-manager-sms/src/main/resources/mybatis/mapper/sms/sms-mapper.xml
2020-07-31 19:22:02 +08:00

132 lines
3.7 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.manager.sms.dao.sms.ISmsDao">
<resultMap id="smsDTO" type="com.cm.manager.sms.pojo.dtos.sms.SmsDTO">
<id column="sms_id" property="smsId"/>
<result column="phone" property="phone"/>
<result column="content" property="content"/>
<result column="send_status" property="sendStatus"/>
<result column="error_message" property="errorMessage"/>
</resultMap>
<!-- 新增短信 -->
<insert id="saveSms" parameterType="map">
INSERT INTO sms_sms(
sms_id,
phone,
content,
send_status,
error_message,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{smsId},
#{phone},
#{content},
#{sendStatus},
#{errorMessage},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除短信 -->
<update id="removeSms" parameterType="map">
UPDATE
sms_sms
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
sms_id IN
<foreach collection="smsIds" index="index" open="(" separator="," close=")">
#{smsIds[${index}]}
</foreach>
</update>
<!-- 修改短信 -->
<update id="updateSms" parameterType="map">
UPDATE
sms_sms
SET
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="content != null and content != ''">
content = #{content},
</if>
<if test="sendStatus != null">
send_status = #{sendStatus},
</if>
<if test="errorMessage != null and errorMessage != ''">
error_message = #{errorMessage},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
sms_id = #{smsId}
</update>
<!-- 短信详情 -->
<select id="getSms" parameterType="map" resultMap="smsDTO">
SELECT
t1.phone,
t1.content,
t1.send_status,
t1.error_message,
t1.sms_id
FROM
sms_sms t1
WHERE
t1.is_delete = 0
<if test="smsId != null and smsId != ''">
AND
t1.sms_id = #{smsId}
</if>
</select>
<!-- 短信列表 -->
<select id="listSms" parameterType="map" resultMap="smsDTO">
SELECT
t1.phone,
t1.content,
t1.send_status,
t1.error_message,
t1.sms_id
FROM
sms_sms t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.phone LIKE CONCAT('%', #{keywords}, '%')
OR
t1.content 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="smsIds != null and smsIds.size > 0">
AND
t1.sms_id IN
<foreach collection="smsIds" index="index" open="(" separator="," close=")">
#{smsIds[${index}]}
</foreach>
</if>
</select>
</mapper>