RoleMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.project.system.role.dao.IRoleDao">
  6. <resultMap type="Role" id="RoleResult">
  7. <id property="roleId" column="role_id" />
  8. <result property="roleName" column="role_name" />
  9. <result property="roleKey" column="role_key" />
  10. <result property="roleSort" column="role_sort" />
  11. <result property="status" column="status" />
  12. <result property="createBy" column="create_by" />
  13. <result property="createTime" column="create_time" />
  14. <result property="updateBy" column="update_by" />
  15. <result property="updateTime" column="update_time" />
  16. <result property="remark" column="remark" />
  17. </resultMap>
  18. <select id="selectRoleList" parameterType="Role" resultMap="RoleResult">
  19. select role_id, role_name, role_key, role_sort, status, create_time from sys_role
  20. <where>
  21. <if test="searchValue != null and searchValue != ''">
  22. AND role_name = #{searchValue} OR role_key = #{searchValue}
  23. </if>
  24. </where>
  25. </select>
  26. <select id="selectRolesByUserId" parameterType="Long" resultMap="RoleResult">
  27. SELECT r.role_id, r.role_name, r.role_key
  28. FROM sys_user u
  29. LEFT JOIN sys_user_role ur ON u.user_id = ur.user_id
  30. LEFT JOIN sys_role r ON ur.role_id = r.role_id
  31. WHERE ur.user_id = #{userId}
  32. </select>
  33. <select id="selectRolesAll" resultMap="RoleResult">
  34. SELECT role_id, role_name, role_key, role_sort, status, create_time FROM sys_role
  35. </select>
  36. <select id="selectRoleById" parameterType="Long" resultMap="RoleResult">
  37. select role_id, role_name, role_key, role_sort, status, create_time
  38. from sys_role u
  39. where u.role_id = #{roleId}
  40. </select>
  41. <select id="checkRoleNameUnique" parameterType="String" resultMap="RoleResult">
  42. select role_id, role_name, role_key, role_sort, status, create_time
  43. from sys_role where role_name=#{roleName}
  44. </select>
  45. <delete id="deleteRoleById" parameterType="Long">
  46. delete from sys_role where role_id = #{roleId}
  47. </delete>
  48. <delete id="batchDeleteRole" parameterType="Long">
  49. delete from sys_role where role_id in
  50. <foreach collection="array" item="roleId" open="(" separator="," close=")">
  51. #{roleId}
  52. </foreach>
  53. </delete>
  54. <update id="updateRole" parameterType="Role">
  55. update sys_role
  56. <set>
  57. <if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
  58. <if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
  59. <if test="roleSort != null and roleSort != ''">role_sort = #{roleSort},</if>
  60. <if test="status !=null">status = #{status},</if>
  61. <if test="remark != null and remark != ''">remark = #{remark},</if>
  62. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  63. update_time = sysdate()
  64. </set>
  65. where 1=1
  66. <if test="roleId != null">and role_id = #{roleId}</if>
  67. </update>
  68. <insert id="insertRole" parameterType="Role" useGeneratedKeys="true" keyProperty="roleId">
  69. insert into sys_role(
  70. <if test="roleId != null and roleId != 0">role_id,</if>
  71. <if test="roleName != null and roleName != ''">role_name,</if>
  72. <if test="roleKey != null and roleKey != ''">role_key,</if>
  73. <if test="roleSort != null and roleSort != ''">role_sort,</if>
  74. <if test="status !=null and status != ''">status,</if>
  75. <if test="remark != null and remark != ''">remark,</if>
  76. <if test="createBy != null and createBy != ''">create_by,</if>
  77. create_time
  78. )values(
  79. <if test="roleId != null and roleId != 0">#{roleId},</if>
  80. <if test="roleName != null and roleName != ''">#{roleName},</if>
  81. <if test="roleKey != null and roleKey != ''">#{roleKey},</if>
  82. <if test="roleSort != null and roleSort != ''">#{roleSort},</if>
  83. <if test="status !=null and status != ''">#{status},</if>
  84. <if test="remark != null and remark != ''">#{remark},</if>
  85. <if test="createBy != null and createBy != ''">#{createBy},</if>
  86. sysdate()
  87. )
  88. </insert>
  89. </mapper>