RoleMapper.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.energy.manage.service.mappers.system.SysRoleMapper">
  4. <select id="getRoleListByName" resultType="com.energy.manage.common.po.system.SysRolePO">
  5. SELECT
  6. id AS id,
  7. role_description AS roleDescription,
  8. role_code AS roleCode,
  9. role_available AS roleAvailable,
  10. role_type as roleType,
  11. source as source,
  12. create_time as createTime
  13. FROM sys_role
  14. where 1=1
  15. <if test="null != roleName and '' != roleName">
  16. and role_description LIKE CONCAT('%',#{roleName,jdbcType=VARCHAR},'%')
  17. </if>
  18. <if test="null != roleAvailable ">
  19. and role_available = #{roleAvailable}
  20. </if>
  21. ORDER BY id ASC
  22. </select>
  23. <update id="updateRoleSelective" parameterType="com.energy.manage.common.po.system.SysRolePO">
  24. UPDATE sys_role
  25. <set>
  26. <if test="null != roleDescription and '' != roleDescription">
  27. role_description = #{roleDescription,jdbcType=VARCHAR},
  28. </if>
  29. <if test="null != roleCode and '' != roleCode">
  30. role_code = #{roleCode,jdbcType=VARCHAR},
  31. </if>
  32. </set>
  33. WHERE id = #{id,jdbcType=INTEGER}
  34. </update>
  35. <!-- 通过userid查询用户角色code -->
  36. <select id="selectUserRoleCodeByUserId" resultType="java.lang.String">
  37. select
  38. role_code
  39. from
  40. sys_role r
  41. inner join
  42. sys_user_role ur on r.id = ur.role_id
  43. where 1=1
  44. and ur.user_id = #{userId}
  45. </select>
  46. <select id="selectRoleByUserId" resultType="com.energy.manage.common.po.system.SysRolePO">
  47. select
  48. r.*
  49. from sys_role r
  50. left join sys_user_role ur on r.id = ur.role_id
  51. where 1=1
  52. and ur.user_id= #{userId}
  53. </select>
  54. </mapper>