MerchantRoleMapper.xml
5.16 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
<?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.MerchantRoleMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.merchants.entity.MerchantRole">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="role_name" jdbcType="VARCHAR" property="roleName"/>
<result column="role_code" jdbcType="VARCHAR" property="roleCode"/>
<result column="role_description" jdbcType="VARCHAR" property="roleDescription"/>
<result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
<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"/>
<result column="created_account" jdbcType="VARCHAR" property="createdAccount"/>
<result column="updated_account" jdbcType="VARCHAR" property="updatedAccount"/>
<result column="admin_flag" jdbcType="TINYINT" property="adminFlag"/>
</resultMap>
<resultMap id="ResultMap" type="cn.com.glsx.merchants.model.response.MerchantRoleResponse"
extends="BaseResultMap">
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
</resultMap>
<sql id="Base_Column_List">
id, role_name, role_code, role_description, merchant_id, created_by, created_time, updated_by,
updated_time, del_flag, created_account, updated_account
</sql>
<select id="selectById" parameterType="java.lang.Integer" resultMap="ResultMap">
select t.id, t.role_name, t.role_code, t.role_description, t.merchant_id, t.created_by, t.created_time, t.updated_by,
t.updated_time, t.del_flag, t.created_account, t.updated_account, m.merchant_name, t.admin_flag
from platform_merchant_role t left join platform_merchant m on t.merchant_id = m.id
where 1 = 1 and t.id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByCondition" resultMap="ResultMap"
parameterType="cn.com.glsx.merchants.model.request.MerchantRoleRequest">
select t.id, t.role_name, t.role_code, t.role_description, t.merchant_id, t.created_by, t.created_time,
t.updated_by, t.admin_flag,
t.updated_time, t.del_flag, t.created_account, t.updated_account, CONCAT(m.merchant_name,'(',m.merchantNo,')')
as merchant_name
from platform_merchant_role t left join platform_merchant m on t.merchant_id = m.id
where t.del_flag in (0, 1)
<if test="obj.roleName != null and obj.roleName != ''">
and t.role_name like CONCAT('%',#{obj.roleName,jdbcType=VARCHAR},'%')
</if>
<if test="obj.merchantId != null">
and t.merchant_id = #{obj.merchantId,jdbcType=INTEGER}
</if>
<if test="obj.merchantNo != null">
and m.merchantNo = #{obj.merchantNo,jdbcType=INTEGER}
</if>
<if test="obj.delFlag != null">
and t.del_flag = #{obj.delFlag,jdbcType=TINYINT}
</if>
<if test="obj.dataPermission != null and obj.dataPermission.size() > 0">
and t.merchant_id in
<foreach collection="obj.dataPermission" item="item" index="index" open="(" close=")" separator=",">
#{item,jdbcType=INTEGER}
</foreach>
</if>
order by updated_time desc
</select>
<select id="selectByNameAndMerchantId" resultMap="ResultMap">
select
<include refid="Base_Column_List"/>
from platform_merchant_role
where del_flag in (0, 1) and role_name = #{name,jdbcType=VARCHAR} and merchant_id =
#{merchantId,jdbcType=INTEGER}
</select>
<select id="findRoleByIds" resultMap="ResultMap">
select t.id, t.role_name, t.role_code, t.role_description, t.merchant_id, t.created_by, t.created_time,
t.updated_by,
t.updated_time, t.del_flag, t.created_account, t.updated_account, CONCAT(m.merchant_name,'(',m.merchantNo,')')
as merchant_name
from platform_merchant_role t left join platform_merchant m on t.merchant_id = m.id
where t.del_flag in (0, 1)
and t.merchant_id in
<foreach collection="merchantIds" item="item" index="index"
open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="findRoleIdsByMerchantIds" resultType="java.lang.Integer">
select id from platform_merchant_role where del_flag = 0 and merchant_id in
<foreach collection="merchantIds" item="item" index="index"
open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="findByIds" resultMap="BaseResultMap">
select * from platform_merchant_role where del_flag = 0 and id in
<foreach collection="ids" item="item" index="index"
open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>