SysRoleMapper.xml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.gxzc.zen.api.sys.mapper.SysRoleMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.gxzc.zen.api.sys.model.SysRole">
  6. <result column="id" property="id"/>
  7. <result column="enable" property="enable"/>
  8. <result column="remark" property="remark"/>
  9. <result column="create_time" property="createTime"/>
  10. <result column="create_by" property="createBy"/>
  11. <result column="update_time" property="updateTime"/>
  12. <result column="update_by" property="updateBy"/>
  13. <result column="parent_id" property="parentId"/>
  14. <result column="name" property="name"/>
  15. <result column="path" property="path"/>
  16. <result column="code" property="code"/>
  17. <result column="ext1" property="ext1"/>
  18. <result column="ext2" property="ext2"/>
  19. <result column="ext3" property="ext3"/>
  20. <result column="ext4" property="ext4"/>
  21. <result column="ext5" property="ext5"/>
  22. </resultMap>
  23. <sql id="CommonColumns">
  24. ${prefix}.id,
  25. ${prefix}.enable,
  26. ${prefix}.remark,
  27. ${prefix}.create_time AS createTime,
  28. ${prefix}.create_by AS createBy,
  29. ${prefix}.update_time AS updateTime,
  30. ${prefix}.update_by AS updateBy,
  31. </sql>
  32. <sql id="Columns">
  33. <include refid="CommonColumns">
  34. <property name="prefix" value="${prefix}"/>
  35. </include>
  36. ${prefix}.parent_id AS parentId,
  37. ${prefix}.name,
  38. ${prefix}.path,
  39. ${prefix}.code,
  40. ${prefix}.ext1,
  41. ${prefix}.ext2,
  42. ${prefix}.ext3,
  43. ${prefix}.ext4,
  44. ${prefix}.ext5
  45. </sql>
  46. <select id="selectByUserId" resultType="com.gxzc.zen.api.sys.model.SysRole">
  47. SELECT
  48. <include refid="Columns">
  49. <property name="prefix" value="A"/>
  50. </include>
  51. FROM sys_role AS A
  52. INNER JOIN sys_user_role AS B ON A.id = B.role_id
  53. WHERE B.user_id = #{userId}
  54. AND A.enable = 1
  55. </select>
  56. </mapper>