232 lines
6.6 KiB
XML
232 lines
6.6 KiB
XML
<?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.jeeplus.modules.sys.dao.RoleDao">
|
|
|
|
<resultMap id="roleResult" type="Role">
|
|
<id property="id" column="id" />
|
|
<result property="name" column="name" />
|
|
<result property="areaTypeId" column="areaTypeId" />
|
|
<result property="enname" column="enname" />
|
|
<result property="roleType" column="roleType" />
|
|
<result property="dataScope" column="dataScope" />
|
|
<result property="remarks" column="remarks" />
|
|
<result property="useable" column="useable" />
|
|
<result property="office.name" column="office.name" />
|
|
<result property="sysData" column="sysData" /><!--
|
|
<collection property="userList" ofType="User">
|
|
<id property="id" column="userList.id" />
|
|
<id property="loginName" column="userList.loginName" />
|
|
<id property="name" column="userList.name" />
|
|
<id property="email" column="userList.email" />
|
|
<id property="phone" column="userList.phone" />
|
|
<id property="mobile" column="userList.mobile" />
|
|
<id property="office.name" column="userList.office.name" />
|
|
<id property="company.name" column="userList.company.name" />
|
|
</collection> -->
|
|
<collection property="menuList" ofType="Menu">
|
|
<id property="id" column="menuList.id" />
|
|
</collection>
|
|
<collection property="officeList" ofType="Office">
|
|
<id property="id" column="officeList.id" />
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<sql id="roleColumns">
|
|
a.id,
|
|
a.office_id AS "office.id",
|
|
a.area_type_id AS "areaTypeId",
|
|
a.name,
|
|
a.enname,
|
|
a.role_type AS roleType,
|
|
a.data_scope AS dataScope,
|
|
a.remarks,
|
|
a.create_by AS "createBy.id",
|
|
a.create_date,
|
|
a.update_by AS "updateBy.id",
|
|
a.update_date,
|
|
a.del_flag,
|
|
o.name AS "office.name",
|
|
o.code,
|
|
a.useable AS useable,
|
|
a.is_sys AS sysData,
|
|
a.accsess_type AS "accsessType"
|
|
</sql>
|
|
|
|
<select id="get" resultMap="roleResult">
|
|
SELECT
|
|
<include refid="roleColumns"/>,<!--
|
|
ur.user_id AS "userList.id",
|
|
u.login_name AS "userList.loginName",
|
|
u.name AS "userList.name",
|
|
u.email AS "userList.email",
|
|
u.phone AS "userList.phone",
|
|
u.mobile AS "userList.mobile",
|
|
uc.name AS "userList.company.name",
|
|
uo.name AS "userList.office.name", -->
|
|
rm.menu_id AS "menuList.id",
|
|
ro.office_id AS "officeList.id"
|
|
FROM sys_role a
|
|
LEFT JOIN sys_office o ON o.id = a.office_id<!--
|
|
LEFT JOIN sys_user_role ur ON ur.role_id = a.id
|
|
LEFT JOIN sys_user u ON u.id = ur.user_id
|
|
LEFT JOIN sys_office uc ON uc.id = u.company_id
|
|
LEFT JOIN sys_office uo ON uo.id = u.office_id -->
|
|
LEFT JOIN sys_role_menu rm ON rm.role_id = a.id
|
|
LEFT JOIN sys_role_office ro ON ro.role_id = a.id
|
|
WHERE a.id = #{id}
|
|
</select>
|
|
|
|
<select id="getByName" resultType="Role">
|
|
SELECT
|
|
<include refid="roleColumns"/>
|
|
FROM sys_role a
|
|
JOIN sys_office o ON o.id = a.office_id
|
|
WHERE a.name = #{name} AND a.del_flag = #{DEL_FLAG_NORMAL}
|
|
</select>
|
|
|
|
<select id="getByEnname" resultType="Role">
|
|
SELECT
|
|
<include refid="roleColumns"/>
|
|
FROM sys_role a
|
|
JOIN sys_office o ON o.id = a.office_id
|
|
WHERE a.enname = #{enname} AND a.del_flag = #{DEL_FLAG_NORMAL}
|
|
</select>
|
|
|
|
<select id="findList" resultMap="roleResult">
|
|
SELECT <!-- DISTINCT -->
|
|
<include refid="roleColumns"/>,
|
|
ro.office_id AS "officeList.id"
|
|
FROM sys_role a
|
|
LEFT JOIN sys_office o ON o.id = a.office_id
|
|
LEFT JOIN sys_user_role ur ON ur.role_id = a.id
|
|
LEFT JOIN sys_user u ON u.id = ur.user_id
|
|
LEFT JOIN sys_role_office ro ON ro.role_id = a.id
|
|
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
|
|
<if test="useable != null and useable != ''">
|
|
AND a.useable=#{useable}
|
|
</if>
|
|
<if test="areaTypeId != null and areaTypeId != ''">
|
|
AND a.area_type_id=#{areaTypeId}
|
|
</if>
|
|
<if test="user != null and user.id != null and user.id != ''">
|
|
AND u.id = #{user.id}
|
|
</if>
|
|
<if test="user != null and user.loginName != null and user.loginName != ''">
|
|
AND u.login_name = #{user.loginName}
|
|
</if>
|
|
<if test="name != null and name != ''">
|
|
AND a.name like
|
|
<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
|
|
<if test="dbName == 'mysql'">CONCAT('%', #{name}, '%')</if>
|
|
</if>
|
|
<if test="enname != null and enname != ''">
|
|
AND a.enname like
|
|
<if test="dbName == 'oracle'">'%'||#{enname}||'%'</if>
|
|
<if test="dbName == 'mysql'">CONCAT('%', #{enname}, '%')</if>
|
|
</if>
|
|
ORDER BY o.code, a.name
|
|
</select>
|
|
|
|
<select id="findAllList" resultType="Role">
|
|
SELECT
|
|
distinct
|
|
<include refid="roleColumns"/>
|
|
FROM sys_role a
|
|
LEFT JOIN sys_office o ON o.id = a.office_id
|
|
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
|
|
ORDER BY o.code, a.name
|
|
</select>
|
|
|
|
<insert id="insert">
|
|
INSERT INTO sys_role(
|
|
id,
|
|
office_id,
|
|
area_type_id,
|
|
name,
|
|
enname,
|
|
role_type,
|
|
data_scope,
|
|
create_by,
|
|
create_date,
|
|
update_by,
|
|
update_date,
|
|
remarks,
|
|
del_flag,
|
|
is_sys,
|
|
useable
|
|
) VALUES (
|
|
#{id},
|
|
#{office.id},
|
|
#{areaTypeId},
|
|
#{name},
|
|
#{enname},
|
|
#{roleType},
|
|
#{dataScope},
|
|
#{createBy.id},
|
|
#{createDate},
|
|
#{updateBy.id},
|
|
#{updateDate},
|
|
#{remarks},
|
|
#{delFlag},
|
|
#{sysData},
|
|
#{useable}
|
|
)
|
|
</insert>
|
|
|
|
<update id="update">
|
|
UPDATE sys_role SET
|
|
office_id = #{office.id},
|
|
area_type_id = #{areaTypeId},
|
|
name = #{name},
|
|
enname = #{enname},
|
|
role_type = #{roleType},
|
|
data_scope = #{dataScope},
|
|
update_by = #{updateBy.id},
|
|
update_date = #{updateDate},
|
|
remarks = #{remarks},
|
|
is_sys = #{sysData},
|
|
useable = #{useable}
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteRoleMenu">
|
|
DELETE FROM sys_role_menu WHERE role_id = #{id}
|
|
</delete>
|
|
|
|
<insert id="insertRoleMenu">
|
|
INSERT INTO sys_role_menu(role_id, menu_id)
|
|
<foreach collection="menuList" item="menu" separator=" union all ">
|
|
SELECT #{id}, #{menu.id} FROM dual
|
|
</foreach>
|
|
</insert>
|
|
|
|
<delete id="deleteRoleOffice">
|
|
DELETE FROM sys_role_office WHERE role_id = #{id}
|
|
</delete>
|
|
|
|
<insert id="insertRoleOffice">
|
|
INSERT INTO sys_role_office(role_id, office_id)
|
|
<foreach collection="officeList" item="office" separator=" union all ">
|
|
SELECT #{id}, #{office.id} FROM dual
|
|
</foreach>
|
|
</insert>
|
|
|
|
<update id="delete">
|
|
DELETE FROM sys_role
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<update id="deleteByLogic">
|
|
UPDATE sys_role SET
|
|
del_flag = #{DEL_FLAG_DELETE}
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<select id="getRoleByqy" resultType="Role" parameterType="java.lang.String">
|
|
SELECT
|
|
<include refid="roleColumns"/>
|
|
FROM sys_role a
|
|
LEFT JOIN sys_office o ON o.id = a.office_id
|
|
WHERE A.AREA_TYPE_ID = (select type from SYS_AREA t where id=(select area_id from sys_office where id=#{aeraId}))
|
|
</select>
|
|
</mapper> |