mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?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.dg.core.db.gen.mapper.ReplyTemplateMapper">
 
    <resultMap type="com.dg.core.db.gen.entity.ReplyTemplateEntity" id="ReplyTemplateResult">
        <id     property="id"      column="id"      />
        <id     property="name"      column="name"      />
        <id     property="handleState"      column="handle_state"      />
        <id     property="response"      column="response"      />
        <id     property="guidance"      column="guidance"      />
        <id     property="accessoryUrl"      column="accessory_url"      />
        <id     property="createTime"      column="create_time"      />
        <id     property="updateTime"      column="update_time"      />
        <id     property="accessoryName"      column="accessory_name"      />
        <id     property="videoUrl"      column="video_url"      />
        <id     property="videoName"      column="video_name"      />
        <id     property="createUserId"      column="create_user_id"      />
        <id     property="departmentId"      column="department_id"      />
        <id     property="pictureUrl"      column="picture_url"      />
        <id     property="pictureName"      column="picture_name"      />
        <id     property="accessoryId"      column="accessory_id"      />
 
    </resultMap>
 
    <sql id="selectReplyTemplateVo">
        SELECT
            id,
            name,
            create_time,
            update_time,
            handle_state,
            response,
            accessory_url,
            accessory_name,
            video_url,
            video_name,
            picture_url,
            picture_name,
            department_id,
            create_user_id,
            accessory_id,
            (select organization_name from automessage_organization_chart where automessage_organization_chart.id=automessage_reply_template.department_id) as departmentName,
            (select user_name from automessage_sys_user where automessage_sys_user.user_id=automessage_reply_template.create_user_id) as createUser,
            guidance
        FROM
            automessage_reply_template
    </sql>
 
    <select id="selectConfigList"  resultMap="ReplyTemplateResult">
        SELECT
        id,
        name,
        create_time,
        update_time,
        handle_state,
        response,
        accessory_url,
        accessory_name,
        video_url,
        video_name,
        picture_url,
        picture_name,
        department_id,
        create_user_id,
        <if test="userId!=null and userId!=''">
            (case create_user_id when  #{userId} then 1 else 0 end)isDelete,
        </if>
        <if test="userId==null or userId==''">
            1 isDelete,
        </if>
        accessory_id,
        (select organization_name from automessage_organization_chart where automessage_organization_chart.id=automessage_reply_template.department_id) as departmentName,
        (select user_name from automessage_sys_user where automessage_sys_user.user_id=automessage_reply_template.create_user_id) as createUser,
        guidance
        FROM
        automessage_reply_template
        <where>
            <if test="Name != null and Name != ''">
                AND automessage_reply_template.name like concat('%', #{Name}, '%')
            </if>
            <if test="ids != null">
                and department_id IN
                <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
        order by create_time desc
    </select>
 
 
    <select id="selectConfigData" parameterType="string" resultMap="ReplyTemplateResult">
        <include refid="selectReplyTemplateVo"/>
        where id=#{Id}
    </select>
 
 
    <insert id="insertConfig" parameterType="com.dg.core.db.gen.entity.ReplyTemplateEntity">
        insert into automessage_reply_template (
        <if test="id != null">id,</if>
        <if test="name != null and name != '' ">name,</if>
        <if test="handleState != null and handleState != '' ">handle_state,</if>
        <if test="response != null and response != '' ">response,</if>
        <if test="guidance != null and guidance != '' ">guidance,</if>
        <if test="accessoryUrl != null and accessoryUrl != '' ">accessory_url,</if>
        <if test="accessoryName != null and accessoryName != '' ">accessory_name,</if>
        <if test="videoUrl != null and videoUrl != '' ">video_url,</if>
        <if test="videoName != null and videoName != '' ">video_name,</if>
        <if test="pictureUrl != null and pictureUrl != '' ">picture_url,</if>
        <if test="pictureName != null and pictureName != '' ">picture_name,</if>
        <if test="createUserId != null and createUserId != '' ">create_user_id,</if>
        <if test="departmentId != null and departmentId != '' ">department_id,</if>
        <if test="accessoryId != null and accessoryId != '' ">accessory_id,</if>
        update_time,
        create_time
        )values(
        <if test="id != null">#{id},</if>
        <if test="name != null and name != '' ">#{name},</if>
        <if test="handleState != null and handleState != '' ">#{handleState},</if>
        <if test="response != null and response != '' ">#{response},</if>
        <if test="guidance != null and guidance != '' ">#{guidance},</if>
        <if test="accessoryUrl != null and accessoryUrl != '' ">#{accessoryUrl},</if>
        <if test="accessoryName != null and accessoryName != '' ">#{accessoryName},</if>
        <if test="videoUrl != null and videoUrl != '' ">#{videoUrl},</if>
        <if test="videoName != null and videoName != '' ">#{videoName},</if>
        <if test="pictureUrl != null and pictureUrl != '' ">#{pictureUrl},</if>
        <if test="pictureName != null and pictureName != '' ">#{pictureName},</if>
        <if test="createUserId != null and createUserId != '' ">#{createUserId},</if>
        <if test="departmentId != null and departmentId != '' ">#{departmentId},</if>
        <if test="accessoryId != null and accessoryId != '' ">#{accessoryId},</if>
        sysdate(),
        sysdate()
        )
    </insert>
 
    <update id="updateConfig" parameterType="com.dg.core.db.gen.entity.ReplyTemplateEntity">
        update automessage_reply_template
        <set>
            <if test="id != null">id=#{id},</if>
            <if test="name != null and name != '' ">name=#{name},</if>
            <if test="handleState != null and handleState != '' ">handle_state=#{handleState},</if>
            <if test="response != null and response != '' ">response=#{response},</if>
            <if test="guidance != null and guidance != '' ">guidance=#{guidance},</if>
            <if test="accessoryUrl != null and accessoryUrl != '' ">accessory_url=#{accessoryUrl},</if>
            <if test="accessoryName != null and accessoryName != '' ">accessory_name=#{accessoryName},</if>
            <if test="videoUrl != null and videoUrl != '' ">video_url=#{videoUrl},</if>
            <if test="videoName != null and videoName != '' ">video_name=#{videoName},</if>
            <if test="pictureUrl != null and pictureUrl != '' ">picture_url=#{pictureUrl},</if>
            <if test="pictureName != null and pictureName != '' ">picture_name=#{pictureName},</if>
            <if test="createUserId != null and createUserId != '' ">create_user_id=#{createUserId},</if>
            <if test="departmentId != null and departmentId != '' ">department_id=#{departmentId},</if>
            <if test="accessoryId != null and accessoryId != '' ">accessory_id=#{accessoryId},</if>
            update_time=sysdate()
        </set>
        where  id= #{id}
    </update>
 
    <delete id="deleteConfigById" parameterType="string">
        delete from automessage_reply_template where id= #{Id}
    </delete>
 
    <select id="countNum" parameterType="string" resultType="integer">
        select count(id) from automessage_reply_template
        <where>
            <if test="Name != null and Name != ''">
                AND name=#{Name}
            </if>
            <if test="ids != null">
                and department_id IN
                <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
    </select>
 
</mapper>