You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

177 lines
5.9 KiB

<?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.epmet.dao.GovStaffRoleDao">
<resultMap type="com.epmet.entity.GovStaffRoleEntity" id="govStaffRoleMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="roleKey" column="ROLE_KEY"/>
<result property="roleName" column="ROLE_NAME"/>
<result property="orgType" column="ORG_TYPE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<update id="updateColumnsById">
update gov_staff_role
set ROLE_NAME = #{roleName}
where ID = #{roleId}
</update>
<!--更新排序序号-->
<update id="updateSortById">
UPDATE gov_staff_role
SET sort = #{sort},
updated_by = #{userId},
updated_time = NOW()
WHERE
id = #{roleId}
</update>
<!--根据staffId查询具有的角色列表-->
<select id="listRolesByStaffId" resultType="com.epmet.entity.GovStaffRoleEntity">
SELECT
r.*
FROM
staff_role sr
INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID ) AND r.DEL_FLAG = '0'
WHERE
sr.STAFF_ID = #{staffId}
AND sr.ORG_ID = #{orgId}
AND sr.DEL_FLAG = '0'
AND r.DEL_FLAG = '0'
ORDER BY r.SORT asc
</select>
<select id="selectGovStaffRoleList" resultType="com.epmet.dto.GovStaffRoleDTO" parameterType="com.epmet.dto.GovStaffRoleDTO">
select
*
from
gov_staff_role
where
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
ORDER BY SORT ASC
</select>
<!--查询客户的指定roleKey的角色信息-->
<select id="getRoleByCustomerIdAndRoleKey" resultType="com.epmet.dto.GovStaffRoleDTO">
SELECT *
FROM gov_staff_role
WHERE CUSTOMER_ID = #{customerId}
AND ROLE_KEY = #{roleKey}
AND DEL_FLAG = '0'
</select>
<select id="listRolesByCustomer" resultType="com.epmet.dto.result.GovStaffRoleResultDTO">
SELECT r.ID AS roleId,
r.CUSTOMER_ID AS customerId,
r.ROLE_KEY AS roleKey,
r.ROLE_NAME AS roleName,
r.ORG_TYPE AS orgType,
r.DESCRIPTION AS description,
r.SORT AS sort
FROM gov_staff_role r
WHERE r.CUSTOMER_ID = #{customerId}
ORDER BY r.SORT asc
</select>
<select id="getDTOById" resultType="com.epmet.dto.result.GovStaffRoleResultDTO">
SELECT gsr.ID AS roleId,
gsr.ROLE_KEY AS roleKey,
gsr.ROLE_NAME AS roleName,
gsr.CUSTOMER_ID AS customerId,
gsr.ORG_TYPE AS orgType
FROM gov_staff_role gsr WHERE ID = #{roleId}
</select>
<!-- 查询用户的权限 -->
<select id="getRoleInfoList" resultType="com.epmet.dto.result.RoleResultDTO">
SELECT
gsr.role_key AS roleKey,
gsr.role_name AS roleName,
sr.staff_id AS userId
FROM
gov_staff_role gsr
LEFT JOIN staff_role sr ON sr.role_id = gsr.id
WHERE
gsr.del_flag = 0
AND sr.del_flag = 0
AND
(
<foreach collection="userIds" item="userId" separator="OR">
sr.staff_id = #{userId}
</foreach>
)
</select>
<!--根据角色key查询具有该key的所有角色列表(所有客户下该角色列表)-->
<select id="listRolesByRoleKey" resultType="com.epmet.dto.result.GovStaffRoleResultDTO">
select gsr.ID roleId, gsr.ROLE_KEY roleKey, gsr.ROLE_NAME, gsr.CUSTOMER_ID customerId
from gov_staff_role gsr
where gsr.ROLE_KEY = #{roleKey}
and gsr.DEL_FLAG=0
</select>
<select id="countRolesByCustomerId" resultType="java.lang.Integer">
select count(0)
from gov_staff_role
where CUSTOMER_ID = #{customerId}
</select>
<!-- 查询role key 和 name -->
<select id="selectRoleKeyName" resultType="com.epmet.dto.result.RoleKeyValueResultDTO">
SELECT
ROLE_KEY,
ROLE_NAME
FROM
gov_staff_role
WHERE
DEL_FLAG = 0
<if test="roleIds != null and roleIds.size() > 0">
AND (
<foreach collection="roleIds" item="roleId" separator=" OR ">
ID = #{roleId}
</foreach>
)
</if>
</select>
<select id="getStaffRoles" resultType="com.epmet.entity.GovStaffRoleEntity">
SELECT
sr.STAFF_ID AS customerId,
r.ID,
r.ROLE_KEY,
r.ROLE_NAME
FROM
staff_role sr
INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID ) AND r.DEL_FLAG = '0'
WHERE
sr.DEL_FLAG = '0'
AND sr.ORG_ID = #{orgId}
<foreach collection="staffIds" item="staffId" open="AND ( " separator=" OR " close=" ) ">
sr.STAFF_ID = #{staffId}
</foreach>
ORDER BY r.SORT asc
</select>
<update id="upNameOrDescription">
UPDATE gov_staff_role
<set>
<if test='null != roleName'>
role_name = #{roleName},
</if>
<if test='null != description'>
description = #{description},
</if>
updated_by = #{userId},
updated_time = NOW()
</set>
WHERE
id = #{roleId}
</update>
</mapper>