SysResSmapper.xml
6.53 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
171
172
173
<?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.zteits.sys.mapper.smapper.SysResSMapper">
<resultMap id="BaseResultMap" type="com.zteits.sys.domain.SysRes">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="res_code" property="resCode" jdbcType="VARCHAR"/>
<result column="res_name" property="resName" jdbcType="VARCHAR"/>
<result column="res_type" property="resType" jdbcType="INTEGER"/>
<result column="res_url" property="resUrl" jdbcType="VARCHAR"/>
<result column="parent_res_id" property="parentResId" jdbcType="BIGINT"/>
<result column="res_icon" property="resIcon" jdbcType="VARCHAR"/>
<result column="res_desc" property="resDesc" jdbcType="VARCHAR"/>
<result column="sort_num" property="sortNum" jdbcType="INTEGER"/>
<result column="if_display" property="ifDisplay" jdbcType="INTEGER"/>
<result column="sys_code" property="sysCode" jdbcType="VARCHAR"/>
<result column="data_state" property="dataState" jdbcType="INTEGER"/>
<result column="create_empid" property="createEmpid" jdbcType="VARCHAR"/>
<result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
<result column="modfiy_empid" property="modfiyEmpid" jdbcType="VARCHAR"/>
<result column="modfiy_date" property="modfiyDate" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, res_code, res_name, res_type, res_url, parent_res_id, res_icon, res_desc, sort_num,
if_display, sys_code, data_state, create_empid, create_date, modfiy_empid, modfiy_date
</sql>
<!-- 批量更新 -->
<update id="updateBatchSysRes">
update sys_res
<set>
<if test="sysRes.dataState != null">
data_state = #{sysRes.dataState,jdbcType=INTEGER},
</if>
<if test="sysRes.modfiyEmpid != null">
modfiy_empid = #{sysRes.modfiyEmpid,jdbcType=VARCHAR},
</if>
modfiy_date =
<choose>
<when test="sysRes.modfiyDate != null">
#{sysRes.modfiyDate,jdbcType=TIMESTAMP},
</when>
<otherwise>
NOW()
</otherwise>
</choose>
</set>
<where>
<choose>
<when test="ids==null || ids.size==0">
1==2
</when>
<otherwise>
id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id,jdbcType=BIGINT}
</foreach>
</otherwise>
</choose>
AND sys_code = #{sysCode,jdbcType=VARCHAR}
</where>
</update>
<!-- 查询菜单列表 -->
<select id="querySysResBySysCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from sys_res
<where>
sys_code = #{sysCode,jdbcType=VARCHAR}
</where>
</select>
<select id="queryPageSysResForList" resultMap="BaseResultMap" parameterType="com.zteits.sys.domain.SysRes">
select
<include refid="Base_Column_List"/>
from sys_res
<where>
sys_code = #{sysCode,jdbcType=VARCHAR}
<if test="sysRes.resName != null">
and res_name = #{sysRes.resName,jdbcType=VARCHAR}
</if>
<if test="sysRes.id != null">
and id = #{sysRes.id,jdbcType=BIGINT}
</if>
<if test="sysRes.resType != null">
and res_type = #{sysRes.resType,jdbcType=INTEGER}
</if>
<if test="sysRes.parentResId != null">
and parent_res_id = #{sysRes.parentResId,jdbcType=BIGINT}
</if>
<if test="sysRes.ifDisplay != null">
and if_display = #{sysRes.ifDisplay,jdbcType=INTEGER}
</if>
<if test="sysRes.dataState != null">
and data_state = #{sysRes.dataState,jdbcType=INTEGER}
</if>
</where>
order by sort_num asc,id desc
</select>
<select id="queryResIdsByOpId" parameterType="java.lang.Long" resultType="java.lang.Long">
select DISTINCT t3.res_id from sys_op_role t1, sys_role_jobfunc t2, sys_res_jobfunc t3
where t1.sys_role_id = t2.sys_role_id AND t2.sys_jobfunc_id = t3.jobfunc_id AND t1.sys_op_id = #{opId}
</select>
<select id="queryAllRes" resultMap="BaseResultMap" >
SELECT
<include refid="Base_Column_List"/>
FROM sys_res
<where>
1=1
<if test="dataStatus != null">
AND data_state = #{dataStatus}
</if>
<if test="sysCode !=null ">
and sys_code = #{sysCode,jdbcType=VARCHAR}
</if>
<choose>
<when test="resIds != null and resIds.size > 0">
AND id IN
<foreach collection="resIds" item="resId" separator="," open="(" close=")" index="index">
#{resId}
</foreach>
</when>
</choose>
</where>
order by sort_num asc
</select>
<update id="updateSysResSortNumOfSaveOrUpdate">
update sys_res
SET sort_num = sort_num
<if test="sortNum > oldSortNum">
-1
</if>
<if test="sortNum < oldSortNum">
+1
</if>
<where>
<if test="sortNum > oldSortNum">
sort_num <= #{sortNum} AND sort_num > #{oldSortNum}
</if>
<if test="sortNum < oldSortNum">
sort_num >= #{sortNum} AND sort_num < #{oldSortNum}
</if>
AND id != #{id,jdbcType=BIGINT}
AND parent_res_id = #{parentResId}
</where>
</update>
<update id="updateSysResSortNumOfDelete">
UPDATE sys_res
SET sort_num = sort_num - 1
WHERE sort_num > (SELECT a.sort_num FROM (SELECT sort_num FROM sys_res WHERE id = #{id}) a)
AND parent_res_id = (SELECT b.parent_res_id FROM (SELECT parent_res_id FROM sys_res WHERE id = #{id}) b)
</update>
<!--查询公共服务资源ids-->
<select id="queryPublicService" resultType="java.lang.Long" >
select a.id from sys_res a where (a.id=#{resId} or a.parent_res_id=#{resId}) and a.data_state=1
</select>
</mapper>