FunctionMapper.xml
7.07 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
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
<?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.dj.system.mapper.FunctionMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.system.model.Function" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="menu_code" property="menuCode" jdbcType="INTEGER" />
<result column="function_name" property="functionName" jdbcType="VARCHAR" />
<result column="function_attr_name" property="functionAttrName" jdbcType="VARCHAR" />
<result column="function_attr_type" property="functionAttrType" jdbcType="INTEGER" />
<result column="function_remark" property="functionRemark" jdbcType="VARCHAR" />
<result column="order_no" property="orderNo" jdbcType="INTEGER" />
<result column="user_limit_type" property="userLimitType"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<resultMap type="cn.com.glsx.dj.system.dto.FunctionDTO" id="BaseResultDTOMap" extends="BaseResultMap">
<result column="menu_name" property="menuName" jdbcType="VARCHAR"/>
<result column="menu_url" property="menuUrl" jdbcType="VARCHAR"/>
<collection property="valueList" ofType="cn.com.glsx.dj.system.dto.FunctionValueDTO">
<id column="v_id" property="id" jdbcType="INTEGER" />
<result column="v_function_id" property="functionId" jdbcType="INTEGER" />
<result column="v_val_text" property="valText" jdbcType="VARCHAR" />
<result column="v_val_code" property="valCode" jdbcType="VARCHAR" />
</collection>
</resultMap>
<resultMap type="cn.com.glsx.dj.system.dto.FunctionDTO" id="DetailResultMap" extends="BaseResultMap">
<result column="menu_name" property="menuName" jdbcType="VARCHAR"/>
<collection property="valueList" ofType="cn.com.glsx.dj.system.dto.FunctionValueDTO">
<id column="v_id" property="id" jdbcType="INTEGER" />
<result column="v_function_id" property="functionId" jdbcType="INTEGER" />
<result column="v_val_text" property="valText" jdbcType="VARCHAR" />
<result column="v_val_code" property="valCode" jdbcType="VARCHAR" />
</collection>
<collection property="dataIds" ofType="java.lang.Integer" >
<result column="data_id"/>
</collection>
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, menu_code, function_name, function_attr_name, function_attr_type, function_remark,
order_no,user_limit_type, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<select id="listWithPage" parameterType="cn.com.glsx.dj.system.dto.FunctionDTO" resultMap="BaseResultDTOMap">
SELECT a.*,b.name as menu_name,b.url as menu_url FROM
dj_system_function a LEFT JOIN dj_system_menu b
ON a.menu_code = b.`code` and b.deleted_flag='N'
<where>
a.deleted_flag = 'N'
<if test="id != null">
and a.id = #{id}
</if>
<if test="menuName != null and menuName != ''">
and b.name LIKE CONCAT('%',#{menuName},'%')
</if>
<if test="menuCode != null">
and a.menu_code LIKE CONCAT('%',#{menuCode},'%')
</if>
<if test="functionName != null and functionName != ''">
and a.function_name LIKE CONCAT('%',#{functionName},'%')
</if>
<if test="functionAttrType != null">
and a.function_attr_type = #{functionAttrType}
</if>
<if test="userLimitType != null">
and a.user_limit_type = #{userLimitType}
</if>
</where>
order by a.order_no desc
</select>
<select id="list" parameterType="cn.com.glsx.dj.system.dto.FunctionDTO" resultMap="DetailResultMap">
select
a.id, a.menu_code, a.function_name, a.function_attr_name, a.function_attr_type, a.function_remark,
a.user_limit_type,a.order_no,
b.id v_id, b.function_id v_function_id, b.val_text v_val_text, b.val_code v_val_code,
e.data_id
from dj_system_function a
left join dj_system_function_value b on b.function_id=a.id and b.deleted_flag='N'
left join dj_system_role_function_value d on d.function_value_id=b.id and d.deleted_flag='N'
left join dj_system_function_user_limit e on e.function_id=a.id and e.deleted_flag='N'
<where>
a.deleted_flag='N'
<if test="menuCode != null">
and a.menu_code = #{menuCode}
</if>
<if test="userLimitTypeArr != null and userLimitTypeArr.length > 0">
and a.user_limit_type in
<foreach collection="userLimitTypeArr" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="roleId != null">
and (
user_limit_type !=0 or
( user_limit_type = 0
and exists (
select 1 from dj_system_role_function rf where rf.function_id=a.id and rf.deleted_flag='N'
and rf.role_id =#{roleId} limit 1
)
and (
a.function_attr_type in (1,3,5)
or (a.function_attr_type in (2,4) and d.role_id = #{roleId} )
)
)
)
</if>
</where>
order by a.order_no desc,b.order_no desc
</select>
<select id="listRoleFunction" parameterType="cn.com.glsx.dj.system.dto.FunctionDTO" resultMap="BaseResultDTOMap">
select
a.id, a.menu_code, a.function_name, a.function_attr_name, a.function_attr_type, a.function_remark,
a.user_limit_type,a.order_no,
b.id v_id, b.function_id v_function_id, b.val_text v_val_text, b.val_code v_val_code
from dj_system_function a
left join dj_system_function_value b on b.function_id=a.id and b.deleted_flag='N'
left join dj_system_function_user_limit e on e.function_id=a.id and e.deleted_flag='N'
<where>
a.deleted_flag='N'
and a.menu_code = #{menuCode}
and (
(a.user_limit_type=1
<if test="userType != null">
and e.data_id=#{userType}
</if>
) or
(a.user_limit_type=2 and e.data_id=#{userId}) or
(a.user_limit_type=3
<if test="merchantUserType != null">
and e.data_id=#{merchantUserType}
</if>
) or
(
a.user_limit_type=0
<if test="functionIds != null and functionIds.size > 0">
and a.id in
<foreach collection="functionIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and (a.function_attr_type in (1,3,5) or (
a.function_attr_type in (2,4)
<if test="functionValueIds != null and functionValueIds.size > 0 ">
and b.id in
<foreach collection="functionValueIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
)
)
)
)
</where>
order by a.order_no desc,b.order_no desc
</select>
</mapper>