EmailConfigMapper.xml
4.8 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
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
<?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.ruoyi.email.mapper.EmailConfigMapper">
<resultMap type="EmailConfig" id="EmailConfigResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="email" column="email" />
<result property="sort" column="sort" />
<result property="type" column="type" />
<result property="parentId" column="parent_id" />
</resultMap>
<sql id="selectEmailConfigVo">
select id, `name`, email, sort,`type`,parent_id from email_config
</sql>
<select id="selectEmailConfigList" parameterType="EmailConfig" resultMap="EmailConfigResult">
<include refid="selectEmailConfigVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="email != null and email != ''"> and email = #{email}</if>
<if test="sort != null "> and sort = #{sort}</if>
<if test="type != null "> and type = #{type}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
</where>
order by sort
</select>
<select id="selectEmailConfigById" parameterType="Long" resultMap="EmailConfigResult">
<include refid="selectEmailConfigVo"/>
where id = #{id}
</select>
<select id="selectRecipientsEmailConfigList" resultType="com.ruoyi.email.domain.EmailConfig">
<include refid="selectEmailConfigVo"/>
where `type` = 0
</select>
<select id="selectEmailConfigListByIds" resultType="com.ruoyi.email.domain.EmailConfig">
select * from email_config
where id in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<insert id="insertEmailConfig" parameterType="EmailConfig">
insert into email_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="name != null">`name`,</if>
<if test="email != null">email,</if>
<if test="type != null">`type`,</if>
<if test="sort != null">sort,</if>
<if test="parentId != null">parentId,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="name != null">#{name},</if>
<if test="email != null">#{email},</if>
<if test="type != null">#{type},</if>
<if test="sort != null">#{sort},</if>
<if test="parentId != null">#{parentId},</if>
</trim>
</insert>
<update id="updateEmailConfig" parameterType="EmailConfig">
update email_config
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="email != null">email = #{email},</if>
<if test="type != null">`type` = #{type},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
</trim>
where id = #{id}
</update>
<update id="updateEmailConfigByEmails">
<if test="ids != null and ids.size() > 0">
update email_config set type = 1 where id in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>;
update email_config set type = 2 where id not in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>;
</if>
update email_config set type = #{config.type}, email = #{config.email}, `name` = #{config.name} , sort = #{config.sort}, parent_id = #{config.parentId} where id = #{config.id};
</update>
<update id="resetEmailConfigByEmails">
<if test="ids != null and ids.size() > 0">
update email_config set type = 2 where id in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>;
</if>
update email_config set `type` = #{config.type}, email = #{config.email} , sort = #{config.sort} , `name` = #{config.name} ,parent_id = null where id = #{config.id};
</update>
<delete id="deleteEmailConfigById" parameterType="Long">
delete from email_config where id = #{id}
</delete>
<delete id="deleteEmailConfigByIds" parameterType="String">
delete from email_config where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>