123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?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.bowintek.practice.mapper.cquery.RoleCQuery">
- <select id="selectRoleList" resultType="com.bowintek.practice.vo.system.RoleModel">
- select r.roleID,r.userTypeID,r.name,r.description,r.isDefault,r.defaultDataRange,r.recordStatus,r.createBy,r.createTime,r.updateBy,r.updateTime
- , dicUserType.Name as userTypeName,dicDataRange.Name as dataRangeName
- from sys_role r
- left join sys_dictionary_item dicUserType on r.UserTypeID = dicUserType.Value and dicUserType.DictionaryCode='UserType'
- left join sys_dictionary_item dicDataRange on r.defaultDataRange = dicDataRange.Value and dicDataRange.DictionaryCode='DataRange'
- where 1=1
- <if test="roleID!='' and roleID!=null">
- and r.roleId = #{roleID}
- </if>
- <if test="name!='' and name!=null">
- and r.name like Concat('%',#{name},'%')
- </if>
- <if test="userTypeID!=null">
- and r.userTypeID = #{userTypeID}
- </if>
- </select>
- <select id="selectFunctionCodeList" resultType="com.bowintek.practice.vo.system.FunctionCodeModel">
- select fc.functionCode,fc.functionName,fc.parentFunctionCode,fc.orderNo
- ,case when rf.FunctionCode is not null then 1 else 0 end as isPermission
- ,case when m.FunctionCode is not null then 1 else 0 end as isMenu
- ,rd.dataRangeID
- from sys_function_code fc
- left join sys_role_sys_function_code rf on fc.FunctionCode = rf.FunctionCode and rf.RoleID = #{roleID}
- left join sys_role_datarange rd on rf.FunctionCode = rd.FunctionCode and rf.RoleID = rd.RoleID
- left join (select distinct FunctionCode from sys_menu) m on fc.FunctionCode = m.FunctionCode
- where 1=1
- <if test="menuTopNo!=null and menuTopNo!=''">
- and fc.functionCode like Concat('',#{menuTopNo},'%')
- </if>
- order by fc.ParentFunctionCode,fc.orderNo
- </select>
- <insert id="batchInsertRoleUser" parameterType="java.util.List">
- insert into sys_user_sys_role(UserID, RoleID)
- values
- <foreach collection="dataList" item="userID" separator=",">
- (#{userID},#{roleID})
- </foreach>
- </insert>
- <insert id="batchInsertRoleFunctionCode" parameterType="java.util.List">
- insert into sys_role_sys_function_code(RoleID, FunctionCode)
- values
- <foreach collection="dataList" item="item" separator=",">
- (#{roleID},#{item.functionCode})
- </foreach>
- </insert>
- <insert id="batchInsertRoleDatarange" parameterType="java.util.List">
- insert into sys_role_datarange(RoleDataRangeID, RoleID,FunctionCode,DataRangeID,CreateBy,CreateTime)
- values
- <foreach collection="dataList" item="item" separator=",">
- (uuid(),#{roleID},#{item.functionCode},#{item.dataRangeID},#{userID},sysdate())
- </foreach>
- </insert>
- <delete id="deleteRoleUser">
- delete from sys_user_sys_role where 1=1
- and roleID in
- <foreach collection="roleIDList" item="roleID" index="index" open="(" close=")" separator=",">
- #{roleID}
- </foreach>
- </delete>
- <delete id="deleteRoleFunctionCode">
- delete from sys_role_sys_function_code where 1=1
- and roleID in
- <foreach collection="roleIDList" item="roleID" index="index" open="(" close=")" separator=",">
- #{roleID}
- </foreach>
- </delete>
- <delete id="deleteRoleDatarange">
- delete from sys_role_datarange where 1=1
- and roleID in
- <foreach collection="roleIDList" item="roleID" index="index" open="(" close=")" separator=",">
- #{roleID}
- </foreach>
- </delete>
- <select id="selectRoleUserList" resultType="com.bowintek.practice.vo.user.UserInfoModel">
- select u.userId,u.name,u.loginId
- from sys_role r
- inner join sys_user_sys_role ur on r.RoleID = ur.RoleID
- inner join sys_user u on ur.UserID = u.UserID
- where 1=1
- <if test="roleID!='' and roleID!=null">
- and r.roleId = #{roleID}
- </if>
- <if test="name!='' and name!=null">
- and u.name like Concat('%',#{name},'%')
- </if>
- <if test="loginID!='' and loginID!=null">
- and u.loginId like Concat('%',#{loginID},'%')
- </if>
- </select>
- <select id="selectUserForSettingList" resultType="com.bowintek.practice.vo.user.UserInfoModel">
- select u.userId,u.name,u.loginId,u.userId as 'key'
- from sys_user u
- left join sys_user_sys_role ur on u.userId = ur.userId and ur.roleID=#{roleID}
- where 1=1 and u.UserTypeID = #{userType} and ur.roleID is null
- </select>
- <select id="selectRoleUserByRolename" resultType="com.bowintek.practice.vo.user.UserInfoModel">
- select u.userId,u.name,u.loginId
- from sys_role r
- inner join sys_user_sys_role ur on r.RoleID = ur.RoleID
- inner join sys_user u on ur.UserID = u.UserID
- where 1=1
- and r.Name in
- <foreach collection="rolenameList" item="rolename" index="index" open="(" close=")" separator=",">
- #{rolename}
- </foreach>
- </select>
- </mapper>
|