UserRoleMapper.xml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.abi.qms.platform.dao.mapper.UserRoleMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.abi.qms.platform.dao.entity.UserRole">
  6. <id column="ID" property="id" />
  7. <result column="ROLE_CODE" property="roleCode" />
  8. <result column="ROLE_NAME" property="roleName" />
  9. <result column="ROLE_DESC" property="roleDesc" />
  10. <result column="ROLE_LEVEL" property="roleLevel" />
  11. <result column="parent_role_code" property="parentRoleCode" />
  12. <result column="L1_ROLE_CODE" property="l1RoleCode" />
  13. <result column="L2_ROLE_CODE" property="l2RoleCode" />
  14. <result column="L3_ROLE_CODE" property="l3RoleCode" />
  15. <result column="L4_ROLE_CODE" property="l4RoleCode" />
  16. <result column="L5_ROLE_CODE" property="l5RoleCode" />
  17. <result column="is_enable" property="isEnable" />
  18. <result column="CREATE_TIME" property="createTime" />
  19. <result column="CREATE_BY" property="createBy" />
  20. <result column="UPDATE_TIME" property="updateTime" />
  21. <result column="IS_DELETE" property="isDelete" />
  22. </resultMap>
  23. <!-- 通用查询结果列 -->
  24. <sql id="Base_Column_List">
  25. ID, ROLE_CODE, ROLE_NAME, ROLE_DESC, ROLE_LEVEL, L1_ROLE_CODE, L2_ROLE_CODE, L3_ROLE_CODE, L4_ROLE_CODE, L5_ROLE_CODE, is_enable, CREATE_TIME, CREATE_BY, UPDATE_TIME, IS_DELETE
  26. </sql>
  27. <select id="listRoleFromRootRoleCode" resultType="com.abi.qms.platform.dao.vo.result.ListRoleVO">
  28. select r.role_code,r.role_name,r.role_desc,
  29. pr.role_name as parent_role_name,
  30. r.is_enable,r.update_time
  31. from user_role r
  32. inner join user_role pr on pr.role_code=r.parent_role_code
  33. <where>
  34. <if test="param.roleName!=null and param.roleName!=''">
  35. and r.role_name=#{param.roleName}
  36. </if>
  37. <if test="param.isEnable!=null and param.isEnable!=''">
  38. and r.is_enable=#{param.isEnable}
  39. </if>
  40. <!-- 仅可以查看当前角色树下的角色 -->
  41. <if test="roleLevel==1">
  42. and r.l1_role_code=#{roleCode}
  43. </if>
  44. <if test="roleLevel==2">
  45. and r.l2_role_code=#{roleCode}
  46. </if>
  47. <if test="roleLevel==3">
  48. and r.l3_role_code=#{roleCode}
  49. </if>
  50. <if test="roleLevel==4">
  51. and r.l4_role_code=#{roleCode}
  52. </if>
  53. <if test="roleLevel==5">
  54. and r.l5_role_code=#{roleCode}
  55. </if>
  56. </where>
  57. </select>
  58. <select id="countList" resultType="long">
  59. select IFNULL(count(distinct user_id),0) as user_count
  60. from user_mapping_info_role
  61. where role_code=#{roleCode}
  62. and is_delete=0
  63. </select>
  64. </mapper>