RoleMapper.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.tofly.base.mapper.RoleMapper">
  4. <resultMap id="roleMap" type="com.tofly.base.entity.Role">
  5. <id property="id" column="ID"/>
  6. <result property="roleName" column="ROLE_NAME"/>
  7. <result property="roleCode" column="ROLE_CODE"/>
  8. <result property="roleDesc" column="ROLE_DESC"/>
  9. <result property="createTime" column="CREATE_TIME"/>
  10. <result property="updateTime" column="UPDATE_TIME"/>
  11. <result property="statusFlag" column="STATUS_FLAG"/>
  12. <result property="portaluserId" column="PORTALUSER_ID"/>
  13. <result property="createUser" column="CREATE_USER"/>
  14. <result property="sysId" column="SYS_ID"/>
  15. <result property="treeValue" column="TREE_VALUE"/>
  16. <result property="updateUsers" column="UPDATE_USERS"/>
  17. <result property="companyId" column="COMPANY_ID"/>
  18. </resultMap>
  19. <select id="listMenuByRoleId" parameterType="map" resultType="map" databaseId="oracle">
  20. select m.*,
  21. decode((select 1
  22. from tf_smpn_rolemenu_x rm
  23. where m.id = rm.menu_id
  24. and rm.role_id = #{roleId,jdbcType=NUMERIC}),
  25. 1,
  26. 'true',
  27. 'false') is_exists
  28. from tf_smpn_menu_x m
  29. where sys_id = #{systemId}
  30. order by sort
  31. </select>
  32. <select id="listMenuByRoleId" parameterType="map" resultType="map" databaseId="mysql">
  33. select m.*,
  34. case (select 1
  35. from TF_SMPN_ROLEMENU_X rm
  36. where m.id = rm.menu_id
  37. and rm.role_id = #{roleId,jdbcType=NUMERIC})
  38. when 1 then 'true'
  39. else 'false' end is_exists
  40. from TF_SMPN_MENU_X m
  41. where sys_id = #{systemId}
  42. order by sort
  43. </select>
  44. <!-- 通过用户ID,查询角色信息-->
  45. <select id="listRolesByUserId" resultMap="roleMap">
  46. SELECT
  47. r.*
  48. FROM
  49. TF_SMPN_ROLE_X r, TF_SMPN_USERROLE_X ur WHERE r.id = ur.role_id AND r.status_flag = 1 and ur.user_id = #{userId}
  50. </select>
  51. </mapper>