市北互联平台后端仓库
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.

167 lines
6.4 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.StaffRoleDao">
<resultMap type="com.epmet.entity.StaffRoleEntity" id="staffRoleMap">
<result property="id" column="ID"/>
<result property="staffId" column="STAFF_ID"/>
<result property="roleId" column="ROLE_ID"/>
<result property="orgId" column="ORG_ID"/>
<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="delStaffRoles" parameterType="com.epmet.dto.StaffRoleDTO">
update
staff_role sr inner join gov_staff_role gsr on (sr.ROLE_ID = gsr.ID and gsr.ROLE_KEY != 'root_manager')
set sr.DEL_FLAG = '1'
where sr.STAFF_ID = #{staffId}
and sr.ORG_ID = #{orgId}
and sr.DEL_FLAG = '0'
</update>
<!--查询具有某角色的staff列表-->
<select id="listStaffIdsByRoleKeyAndOrgId" resultType="com.epmet.dto.result.GovStaffRoleResultDTO">
SELECT sr.STAFF_ID, sr.ROLE_ID, r.ROLE_NAME, r.ROLE_KEY, s.REAL_NAME, s.MOBILE, s.GENDER
FROM
staff_role sr
INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID )
INNER JOIN customer_staff s ON (sr.STAFF_ID = s.USER_ID)
WHERE
r.ROLE_KEY = #{roleKey}
AND sr.ORG_ID = #{orgId}
AND sr.DEL_FLAG = '0'
AND r.DEL_FLAG = '0'
</select>
<!-- StaffRolesResultDTO的映射结果集 -->
<resultMap id="staffRolesResultMap" type="com.epmet.dto.result.StaffRolesResultDTO">
<id property="staffId" column="USER_ID"/>
<result property="enableFlag" column="ENABLE_FLAG"/>
<collection property="roleList" ofType="java.lang.String">
<constructor>
<arg column="ROLE_NAME"/>
</constructor>
</collection>
</resultMap>
<!-- 得到指定客户下的某个用户的全部角色 -->
<select id="getStaffRoles" parameterType="com.epmet.dto.form.CommonUserFormDTO" resultMap="staffRolesResultMap">
SELECT
staff.USER_ID,
staff.ENABLE_FLAG,
rolename.ROLE_NAME
FROM
STAFF_ROLE role
LEFT JOIN CUSTOMER_STAFF staff ON ( role.STAFF_ID = staff.USER_ID )
LEFT JOIN GOV_STAFF_ROLE rolename ON ( role.ROLE_ID = rolename.ID )
WHERE
role.DEL_FLAG = '0'
AND staff.DEL_FLAG = '0'
AND rolename.DEL_FLAG = '0'
AND staff.USER_ID = #{userId}
AND staff.CUSTOMER_ID = #{customerId}
</select>
<!-- 查询具有特定角色的工作人员Id -->
<select id="selectSpecificRolesStaffs" resultType="string">
SELECT
staffrole.STAFF_ID
FROM
`staff_role` staffrole
LEFT JOIN `customer_staff` staff ON staffrole.STAFF_ID = staff.USER_ID
LEFT JOIN `gov_staff_role` role ON staffrole.ROLE_ID = ROLE.ID
<where>
staffrole.DEL_FLAG = '0'
AND staff.DEL_FLAG = '0'
AND role.DEL_FLAG = '0'
AND staff.ENABLE_FLAG = 'enable'
AND staffrole.ROLE_ID IN (
SELECT
ID
FROM
GOV_STAFF_ROLE
WHERE
ROLE_KEY IN
<foreach item="roleKey" collection="roleKeys" open="(" separator="," close=")">
#{roleKey}
</foreach>
AND DEL_FLAG = '0' )
AND staffrole.STAFF_ID IN
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
#{userId}
</foreach>
<if test='null != customerId and "" != customerId'>
AND staff.CUSTOMER_ID = #{customerId}
</if>
</where>
</select>
<select id="selectStaffRoleList" resultType="com.epmet.dto.result.CustomerStaffRoleResultDTO">
SELECT
sr.staff_id AS "staffId",
gsr.role_key AS "roleKey",
gsr.role_name AS "roleName"
FROM
staff_role sr
INNER JOIN gov_staff_role gsr ON sr.role_id = gsr.id
WHERE
sr.del_flag = '0'
AND gsr.del_flag = '0'
5 years ago
<foreach item="staffId" collection="staffIdList" separator="or" open="AND (" close=")" index="">
sr.staff_id = #{staffId}
</foreach>
</select>
<select id="selectCustomerStaffRoleList" resultType="com.epmet.dto.result.CustomerStaffRoleListResultDTO">
SELECT
staff.customer_id AS "customerId",
staff.user_id AS "staffId",
staff.real_name AS "staffName",
role.role_id AS "roleId",
rolename.role_key AS "roleKey",
rolename.role_name AS "roleName"
FROM
staff_role role
LEFT JOIN customer_staff staff ON ( role.staff_id = staff.user_id )
LEFT JOIN gov_staff_role rolename ON ( role.role_id = rolename.id )
WHERE
role.del_flag = '0'
AND staff.del_flag = '0'
AND rolename.del_flag = '0'
<if test='null != customerId and "" != customerId'>
AND staff.customer_id = #{customerId}
</if>
<if test='null != staffId and "" != staffId'>
AND staff.user_id = #{staffId}
</if>
</select>
<select id="selectStaffRoles" resultType="com.epmet.dto.result.CustomerStaffRoleResultDTO">
SELECT
sr.staff_id AS "staffId",
gsr.role_key AS "roleKey",
gsr.role_name AS "roleName"
FROM
staff_role sr
INNER JOIN gov_staff_role gsr ON sr.role_id = gsr.id
WHERE
sr.del_flag = '0'
AND gsr.del_flag = '0'
AND sr.staff_id = #{staffId}
</select>
<select id="listStaffRoleEntytiesByStaffIdAndOrgId" resultType="com.epmet.entity.StaffRoleEntity">
select *
from staff_role sr
where sr.STAFF_ID = #{staffId}
and sr.ORG_ID = #{agencyId}
and sr.DEL_FLAG='0'
</select>
</mapper>