SmsTemplateDao.xml
2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?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.diligrp.assistant.sms.dao.SmsTemplateDao">
<resultMap id="SmsTemplateMap" type="com.diligrp.assistant.sms.model.SmsTemplateDo">
<id column="id" property="id"/>
<result column="template_id" property="templateId"/>
<result column="pipeline" property="pipeline"/>
<result column="type" property="type"/>
<result column="name" property="name"/>
<result column="content" property="content"/>
<result column="state" property="state"/>
<result column="description" property="description"/>
<result column="out_template_id" property="outTemplateId"/>
<result column="version" property="version"/>
<result column="created_time" property="createdTime"/>
<result column="modified_time" property="modifiedTime"/>
</resultMap>
<insert id="insertSmsTemplate" parameterType="com.diligrp.assistant.sms.model.SmsTemplateDo">
INSERT INTO sms_template
(template_id, pipeline, type, name, content, state, description, out_template_id, version, created_time, modified_time)
VALUES
(#{templateId}, #{pipeline}, #{type}, #{name}, #{content}, #{state}, #{description}, #{outTemplateId}, #{version}, #{createdTime}, #{modifiedTime})
</insert>
<select id="findSmsTemplateById" parameterType="string" resultMap="SmsTemplateMap">
SELECT * FROM sms_template WHERE template_id = #{templateId}
</select>
<update id="updateSmsTemplate" parameterType="com.diligrp.assistant.sms.model.SmsTemplateDo">
UPDATE sms_template SET modified_time = #{modifiedTime}
<if test="type != null">
, type = #{type}
</if>
<if test="name != null">
, name = #{name}
</if>
<if test="content != null">
, content = #{content}
</if>
<if test="state != null">
, state = #{state}
</if>
<if test="description != null">
, description = #{description}
</if>
WHERE template_id = #{templateId}
</update>
<update id="compareAndSetState" parameterType="com.diligrp.assistant.sms.domain.TemplateStateDTO">
UPDATE sms_template SET state = #{state}, version = version + 1
<if test="modifiedTime != null">
, modified_time = #{modifiedTime}
</if>
WHERE
template_id = #{templateId} AND version = #{version}
</update>
<update id="deleteSmsTemplate" parameterType="string">
DELETE FROM sms_template WHERE template_id = #{templateId}
</update>
</mapper>