RoleCQuery.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.bowintek.smartsearch.mapper.cquery.RoleCQuery">
  4. <select id="selectRoleList" resultType="com.bowintek.smartsearch.vo.system.RoleModel">
  5. select r.roleID,r.userTypeID,r.name,r.description,r.isDefault,r.defaultDataRange,r.recordStatus,r.createBy,r.createTime,r.updateBy,r.updateTime
  6. , dicUserType.Name as userTypeName,dicDataRange.Name as dataRangeName
  7. from sys_role r
  8. left join sys_dictionary_item dicUserType on r.UserTypeID = dicUserType.Value and dicUserType.DictionaryCode='UserType'
  9. left join sys_dictionary_item dicDataRange on r.defaultDataRange = dicDataRange.Value and dicDataRange.DictionaryCode='DataRange'
  10. where 1=1
  11. <if test="roleID!='' and roleID!=null">
  12. and r.roleId = #{roleID}
  13. </if>
  14. <if test="name!='' and name!=null">
  15. and r.name like Concat('%',#{name},'%')
  16. </if>
  17. <if test="userTypeID!=null">
  18. and r.userTypeID = #{userTypeID}
  19. </if>
  20. </select>
  21. <select id="selectFunctionCodeList" resultType="com.bowintek.smartsearch.vo.system.FunctionCodeModel">
  22. select fc.functionCode,fc.functionName,fc.parentFunctionCode,fc.orderNo
  23. ,case when rf.FunctionCode is not null then 1 else 0 end as isPermission
  24. ,case when m.FunctionCode is not null then 1 else 0 end as isMenu
  25. ,rd.dataRangeID
  26. from sys_function_code fc
  27. left join sys_role_sys_function_code rf on fc.FunctionCode = rf.FunctionCode and rf.RoleID = #{roleID}
  28. left join sys_role_datarange rd on rf.FunctionCode = rd.FunctionCode and rf.RoleID = rd.RoleID
  29. left join (select distinct FunctionCode from sys_menu) m on fc.FunctionCode = m.FunctionCode
  30. where 1=1
  31. <if test="menuTopNo!=null and menuTopNo!=''">
  32. and fc.functionCode like Concat('',#{menuTopNo},'%')
  33. </if>
  34. order by fc.ParentFunctionCode,fc.orderNo
  35. </select>
  36. <insert id="batchInsertRoleUser" parameterType="java.util.List">
  37. insert into sys_user_sys_role(UserID, RoleID)
  38. values
  39. <foreach collection="dataList" item="userID" separator=",">
  40. (#{userID},#{roleID})
  41. </foreach>
  42. </insert>
  43. <insert id="batchInsertRoleFunctionCode" parameterType="java.util.List">
  44. insert into sys_role_sys_function_code(RoleID, FunctionCode)
  45. values
  46. <foreach collection="dataList" item="item" separator=",">
  47. (#{roleID},#{item.functionCode})
  48. </foreach>
  49. </insert>
  50. <insert id="batchInsertRoleDatarange" parameterType="java.util.List">
  51. insert into sys_role_datarange(RoleDataRangeID, RoleID,FunctionCode,DataRangeID,CreateBy,CreateTime)
  52. values
  53. <foreach collection="dataList" item="item" separator=",">
  54. (uuid(),#{roleID},#{item.functionCode},#{item.dataRangeID},#{userID},sysdate())
  55. </foreach>
  56. </insert>
  57. <delete id="deleteRoleUser">
  58. delete from sys_user_sys_role where 1=1
  59. and roleID in
  60. <foreach collection="roleIDList" item="roleID" index="index" open="(" close=")" separator=",">
  61. #{roleID}
  62. </foreach>
  63. </delete>
  64. <delete id="deleteRoleFunctionCode">
  65. delete from sys_role_sys_function_code where 1=1
  66. and roleID in
  67. <foreach collection="roleIDList" item="roleID" index="index" open="(" close=")" separator=",">
  68. #{roleID}
  69. </foreach>
  70. </delete>
  71. <delete id="deleteRoleDatarange">
  72. delete from sys_role_datarange where 1=1
  73. and roleID in
  74. <foreach collection="roleIDList" item="roleID" index="index" open="(" close=")" separator=",">
  75. #{roleID}
  76. </foreach>
  77. </delete>
  78. <select id="selectRoleUserList" resultType="com.bowintek.smartsearch.vo.user.UserInfoModel">
  79. select u.userId,u.name,u.loginId
  80. from sys_role r
  81. inner join sys_user_sys_role ur on r.RoleID = ur.RoleID
  82. inner join sys_user u on ur.UserID = u.UserID
  83. where 1=1
  84. <if test="roleID!='' and roleID!=null">
  85. and r.roleId = #{roleID}
  86. </if>
  87. <if test="name!='' and name!=null">
  88. and u.name like Concat('%',#{name},'%')
  89. </if>
  90. <if test="loginID!='' and loginID!=null">
  91. and u.loginId like Concat('%',#{loginID},'%')
  92. </if>
  93. </select>
  94. <select id="selectUserForSettingList" resultType="com.bowintek.smartsearch.vo.user.UserInfoModel">
  95. select u.userId,u.name,u.loginId,u.userId as 'key'
  96. from sys_user u
  97. left join sys_user_sys_role ur on u.userId = ur.userId and ur.roleID=#{roleID}
  98. where 1=1 and ur.roleID is null
  99. </select>
  100. <select id="selectRoleUserByRolename" resultType="com.bowintek.smartsearch.vo.user.UserInfoModel">
  101. select u.userId,u.name,u.loginId
  102. from sys_role r
  103. inner join sys_user_sys_role ur on r.RoleID = ur.RoleID
  104. inner join sys_user u on ur.UserID = u.UserID
  105. where 1=1
  106. and r.Name in
  107. <foreach collection="rolenameList" item="rolename" index="index" open="(" close=")" separator=",">
  108. #{rolename}
  109. </foreach>
  110. </select>
  111. </mapper>