McOperationLogMapper.xml
7.68 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
<?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.chinagas.modules.schsf.mapper.McOperationLogMapper">
<resultMap type="com.chinagas.modules.schsf.domain.McOperationLog" id="McOperationLogResult">
<result property="id" column="id" />
<result property="dataForm" column="data_form" />
<result property="dataId" column="data_id" />
<result property="procRole" column="proc_role" />
<result property="procUser" column="proc_user" />
<result property="procTime" column="proc_time" />
<result property="procAccount" column="proc_account" />
<result property="opName" column="op_name" />
<result property="opType" column="op_type" />
<result property="opRemark" column="op_remark" />
<result property="beforeDataJson" column="before_data_json" />
<result property="afterDataJson" column="after_data_json" />
<result property="procId" column="proc_id" />
</resultMap>
<sql id="selectMcOperationLogVo">
select id,
data_form,
data_id,
proc_role,
proc_user,
proc_time,
proc_account,
op_name,
op_type,
op_remark,
before_data_json,
after_data_json,
proc_id
from mc_operation_log
</sql>
<select id="selectMcOperationLogList" parameterType="com.chinagas.modules.schsf.domain.McOperationLog" resultMap="McOperationLogResult">
<include refid="selectMcOperationLogVo"/>
<where>
<if test="dataForm != null and dataForm != ''"> and data_form = #{dataForm}</if>
<if test="dataId != null "> and data_id = #{dataId}</if>
<if test="procRole != null and procRole != ''"> and proc_role = #{procRole}</if>
<if test="procUser != null and procUser != ''"> and proc_user = #{procUser}</if>
<if test="procTime != null "> and proc_time = #{procTime}</if>
<if test="procAccount != null and procAccount != ''"> and proc_account = #{procAccount}</if>
<if test="opName != null and opName != ''"> and op_name like concat('%', #{opName}, '%')</if>
<if test="opType != null and opType != ''"> and op_type = #{opType}</if>
<if test="opRemark != null and opRemark != ''"> and op_remark = #{opRemark}</if>
<if test="beforeDataJson != null and beforeDataJson != ''"> and before_data_json = #{beforeDataJson}</if>
<if test="afterDataJson != null and afterDataJson != ''"> and after_data_json = #{afterDataJson}</if>
<if test="procId != null and procId != ''"> and proc_id = #{procId}</if>
</where>
order by proc_time desc
</select>
<insert id="insertMcOperationLog" parameterType="com.chinagas.modules.schsf.domain.McOperationLog">
insert into mc_operation_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="dataForm != null and dataForm != ''">data_form,</if>
<if test="dataId != null">data_id,</if>
<if test="procRole != null">proc_role,</if>
<if test="procUser != null and procUser != ''">proc_user,</if>
<if test="procTime != null">proc_time,</if>
<if test="procAccount != null and procAccount != ''">proc_account,</if>
<if test="opName != null">op_name,</if>
<if test="opType != null">op_type,</if>
<if test="opRemark != null">op_remark,</if>
<if test="beforeDataJson != null">before_data_json,</if>
<if test="afterDataJson != null">after_data_json,</if>
<if test="procId != null">proc_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="dataForm != null and dataForm != ''">#{dataForm},</if>
<if test="dataId != null">#{dataId},</if>
<if test="procRole != null">#{procRole},</if>
<if test="procUser != null and procUser != ''">#{procUser},</if>
<if test="procTime != null">#{procTime},</if>
<if test="procAccount != null and procAccount != ''">#{procAccount},</if>
<if test="opName != null">#{opName},</if>
<if test="opType != null">#{opType},</if>
<if test="opRemark != null">#{opRemark},</if>
<if test="beforeDataJson != null">#{beforeDataJson},</if>
<if test="afterDataJson != null">#{afterDataJson},</if>
<if test="procId != null">#{procId},</if>
</trim>
</insert>
<select id="getUserMenuPermsByRoles" resultType="String" parameterType="String">
SELECT DISTINCT r.role_name as roleName FROM (
SELECT role.role_name
FROM sys_menu menu
INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id
INNER JOIN sys_role role on role.role_id= roleMenu.role_id
INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id
INNER JOIN sys_user us on us.user_id = userRole.user_id
WHERE role.data_scope='1'
and menu.perms= #{menuPerms}
AND us.user_id= #{userId}
UNION
SELECT role.role_name
FROM sys_menu menu
INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id
INNER JOIN sys_role role on role.role_id= roleMenu.role_id
INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id
INNER JOIN sys_user us on us.user_id = userRole.user_id
INNER JOIN sys_user_dept userDept on userDept.user_id=us.user_id and userDept.dept_id = (SELECT company_code FROM mc_visit WHERE id= #{dataId} )
INNER JOIN mc_visit visit on visit.company_code =userDept.dept_id
WHERE role.data_scope='3'
and menu.perms= #{menuPerms}
AND us.user_id= #{userId}
UNION
SELECT role.role_name
FROM sys_menu menu
INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id
INNER JOIN sys_role role on role.role_id= roleMenu.role_id
INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id
INNER JOIN sys_user us on us.user_id = userRole.user_id
INNER JOIN sys_user_dept userDept on userDept.user_id=us.user_id
INNER JOIN sys_dept dept on dept.dept_id =userDept.dept_id
INNER JOIN sys_dept dept2 on dept2.dept_id in (SELECT a.dept_id FROM sys_dept a WHERE a.dept_id = dept.dept_id or find_in_set(dept.parent_id , ancestors ) )
and dept2.dept_id =(SELECT company_code FROM mc_visit WHERE id= #{dataId} )
WHERE role.data_scope='4'
and menu.perms= #{menuPerms}
AND us.user_id=#{userId}
UNION
SELECT role.role_name
FROM sys_menu menu
INNER JOIN sys_role_menu roleMenu on roleMenu.menu_id=menu.menu_id
INNER JOIN sys_role role on role.role_id= roleMenu.role_id
INNER JOIN sys_user_role userRole on userRole.role_id = role.role_id and userRole.user_id = (SELECT create_by FROM mc_visit WHERE id= #{dataId} )
WHERE role.data_scope='5'
and menu.perms= #{menuPerms}
AND userRole.user_id= #{userId}
) r
</select>
</mapper>