AccountFunctionRelationMapper.xml
7.02 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?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.AccountFunctionRelationMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.merchants.entity.AccountFunctionRelation">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="accounttype_id" jdbcType="INTEGER" property="accounttypeId"/>
<result column="product_id" jdbcType="INTEGER" property="productId"/>
<result column="menu_id" jdbcType="INTEGER" property="menuId"/>
<result column="function_id" jdbcType="INTEGER" property="functionId"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="function_value" jdbcType="VARCHAR" property="functionValue"/>
</resultMap>
<resultMap id="ResultMap" type="cn.com.glsx.merchants.model.response.AccountFunctionRelationResponse"
extends="BaseResultMap">
<result column="product_name" jdbcType="VARCHAR" property="productName"/>
</resultMap>
<resultMap id="MenuResultMap" type="cn.com.glsx.merchants.model.response.MerchantProTreeResponse">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="label" jdbcType="VARCHAR" property="label"/>
<result column="logo" jdbcType="VARCHAR" property="logo"/>
<result column="value" jdbcType="VARCHAR" property="value"/>
<result column="parentId" jdbcType="INTEGER" property="parentId"/>
<result column="product_id" jdbcType="INTEGER" property="superParentId"/>
</resultMap>
<sql id="Base_Column_List">
id, accounttype_id, product_id, menu_id, function_id, created_by, created_date, updated_by,
updated_date, function_value, del_flag
</sql>
<select id="selectByCondition" resultMap="ResultMap"
parameterType="cn.com.glsx.merchants.model.request.AccountFunctionRelationRequest">
select t.id, t.accounttype_id, t.product_id, t.menu_id, t.function_id, t.created_by, t.created_date,
t.updated_by,t.updated_date, t.function_value, p.product_name
from platform_merchant_accounttype_function_relation t left join platform_merchant_product p
on t.product_id = p.id where t.del_flag = 0
<if test="obj.accounttypeId != null">
and t.accounttype_id = #{obj.accounttypeId,jdbcType=INTEGER}
</if>
</select>
<select id="selectByTypeId" resultMap="BaseResultMap"
parameterType="java.lang.Integer">
select <include refid="Base_Column_List"/> from platform_merchant_accounttype_function_relation
where del_flag = 0 and accounttype_id = #{typeId,jdbcType=INTEGER}
</select>
<select id="selectMenuList" resultMap="MenuResultMap">
select m.id, m.menu_name label, "menu" logo, m.parentId parentId, t.product_id
from platform_merchant_accounttype_function_relation t
left join platform_merchant_product_menu m
on t.menu_id = m.id
where t.del_flag = 0 and t.accounttype_id = #{typeId,jdbcType=INTEGER} and t.function_id is null
<if test="parentId == null">
and m.parentId is null
</if>
<if test="parentId != null">
and m.parentId = #{parentId,jdbcType=INTEGER}
</if>
</select>
<select id="selectFunctionList" resultMap="MenuResultMap">
select f.id, f.function_name label, "function" logo, f.menu_id parentId, f.function_value value
from platform_merchant_accounttype_function_relation t
left join platform_merchant_product_function f
on t.function_id = f.id
where t.del_flag = 0 and t.accounttype_id = #{typeId,jdbcType=INTEGER}
and t.menu_id = #{menuId,jdbcType=INTEGER}
</select>
<select id="findByAccountIdAndDelFlag" resultMap="BaseResultMap">
select accounttype_id, product_id, menu_id, function_id, del_flag from platform_merchant_accounttype_function_relation where del_flag = #{delFlag} and accounttype_id in
<foreach collection="accountTypeId" item="item" index="index"
open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="findAccountTypeIdByProductId" resultType="java.lang.Integer">
select accounttype_id from platform_merchant_accounttype_function_relation where del_flag = 0 and product_id = #{productId}
</select>
<delete id="deleteByAccountId" parameterType="java.lang.Integer">
update platform_merchant_accounttype_function_relation set del_flag = -1
where 1 = 1 and accounttype_id = #{typeId,jdbcType=INTEGER}
</delete>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
insert into platform_merchant_accounttype_function_relation
(accounttype_id, product_id, menu_id, function_id, created_by, created_date, updated_by,
updated_date, del_flag, function_value)
values
<foreach collection="list" item="item" separator=",">
(#{item.accounttypeId,jdbcType=INTEGER}, #{item.productId,jdbcType=INTEGER},
#{item.menuId,jdbcType=INTEGER},
#{item.functionId,jdbcType=INTEGER}, #{item.createdBy,jdbcType=INTEGER},
#{item.createdDate,jdbcType=TIMESTAMP},
#{item.updatedBy,jdbcType=INTEGER}, #{item.updatedDate,jdbcType=TIMESTAMP},
#{item.delFlag,jdbcType=TINYINT},
#{item.functionValue,jdbcType=VARCHAR})
</foreach>
</insert>
<update id="deleteByMenuId">
update platform_merchant_accounttype_function_relation set del_flag = -1,
updated_by=#{accountFunctionRelation.createdBy},
updated_date=NOW()
where 1 = 1 and menu_id = #{accountFunctionRelation.menuId}
</update>
<update id="deleteByFunctionId">
update platform_merchant_accounttype_function_relation set del_flag = -1,
updated_by=#{accountFunctionRelation.createdBy},
updated_date=NOW()
where 1 = 1 and function_id = #{accountFunctionRelation.functionId}
</update>
<insert id="insertByFunctionId" parameterType="cn.com.glsx.merchants.entity.AccountFunctionRelation">
insert into platform_merchant_accounttype_function_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
accounttype_id,
product_id,
menu_id,
function_id,
created_by,
created_date,
function_value
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
#{accounttypeId},
#{productId},
#{menuId},
#{functionId},
#{createdBy},
#{createdDate},
#{functionValue}
</trim>
</insert>
</mapper>