RoleAccountRelationMapper.xml
5 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
<?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="cn.com.glsx.merchants.mapper.RoleAccountRelationMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.merchants.entity.RoleAccountRelation">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="role_id" jdbcType="INTEGER" property="roleId"/>
<result column="accounttype_id" jdbcType="INTEGER" property="accounttypeId"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
</resultMap>
<resultMap id="ResultMap" type="cn.com.glsx.merchants.model.response.RoleAccountRelationResponse">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="role_id" jdbcType="INTEGER" property="roleId"/>
<result column="accounttype_id" jdbcType="INTEGER" property="accounttypeId"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
</resultMap>
<sql id="Base_Column_List">
id, role_id, accounttype_id, created_by, created_time, updated_by, updated_time,
del_flag
</sql>
<delete id="deleteByRoleId" parameterType="java.lang.Integer">
update platform_merchant_role_accounttype_relation set del_flag = -1
where 1 = 1 and role_id = #{roleId,jdbcType=INTEGER}
</delete>
<insert id="batchInsert" parameterType="map">
insert into platform_merchant_role_accounttype_relation
(id, role_id, accounttype_id, created_by, created_time, updated_by, updated_time,
del_flag)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=INTEGER}, #{item.roleId,jdbcType=INTEGER}, #{item.accounttypeId,jdbcType=INTEGER},
#{item.createdBy,jdbcType=INTEGER}, #{item.createdTime,jdbcType=TIMESTAMP},
#{item.updatedBy,jdbcType=INTEGER},
#{item.updatedTime,jdbcType=TIMESTAMP}, #{item.delFlag,jdbcType=TINYINT})
</foreach>
</insert>
<select id="selectByCondition" resultMap="ResultMap"
parameterType="cn.com.glsx.merchants.model.request.RoleAccountRelationRequest">
select
<include refid="Base_Column_List"/>
from platform_merchant_role_accounttype_relation
where del_flag = 0
<if test="obj.roleId != null">
and role_id = #{obj.roleId,jdbcType=INTEGER}
</if>
<if test="obj.accounttypeId != null">
and accounttype_id = #{obj.accounttypeId,jdbcType=INTEGER}
</if>
</select>
<select id="selectByRoleId" resultType="java.lang.Integer"
parameterType="java.lang.Integer">
select id from platform_merchant_role_accounttype_relation
where del_flag = 0 and role_id = #{roleId,jdbcType=INTEGER}
</select>
<select id="selectByMerchantIds"
resultType="cn.com.glsx.merchants.model.response.RoleAccountRelationResponse">
select
t1.*
from platform_merchant_role_accounttype_relation t1
left join platform_merchant_role t2 on t1.role_id=t2.id
left join platform_merchant_role_function_relation t3 on t1.id=t3.role_accounttype_id
where t1.del_flag = 0 and t2.del_flag=0 and t3.del_flag=0
<if test="obj.accounttypeId != null">
and t1.accounttype_id = #{obj.accounttypeId,jdbcType=INTEGER}
</if>
<if test="obj.productId != null">
and t3.product_id = #{obj.productId,jdbcType=INTEGER}
</if>
<if test="obj.merchantIds != null">
and t2.merchant_id in
<foreach collection="obj.merchantIds" item="item" index="index"
open="(" close=")" separator=",">
#{item}
</foreach>
</if>
group by t1.id
</select>
<select id="findIdByRoleIds" resultType="java.lang.Integer">
select id from platform_merchant_role_accounttype_relation where del_flag = 0 and role_id in
<foreach collection="roleIds" item="item" index="index"
open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="findIdsByAccountIds" resultType="java.lang.Integer">
select id from platform_merchant_role_accounttype_relation where del_flag = 0 and accounttype_id in
<foreach collection="accountTypeIds" item="item" index="index"
open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>