SysRoleMapper.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.fs.system.mapper.SysRoleMapper">
  6. <resultMap type="SysRole" id="SysRoleResult">
  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="dataScope" column="data_scope" />
  12. <result property="menuCheckStrictly" column="menu_check_strictly" />
  13. <result property="deptCheckStrictly" column="dept_check_strictly" />
  14. <result property="status" column="status" />
  15. <result property="delFlag" column="del_flag" />
  16. <result property="createBy" column="create_by" />
  17. <result property="createTime" column="create_time" />
  18. <result property="updateBy" column="update_by" />
  19. <result property="updateTime" column="update_time" />
  20. <result property="remark" column="remark" />
  21. <result property="isCheckPhone" column="is_check_phone" />
  22. <result property="isCheckAddress" column="is_check_address" />
  23. </resultMap>
  24. <sql id="selectRoleVo">
  25. select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
  26. r.status, r.del_flag, r.create_time, r.remark,r.is_check_phone,r.is_check_address
  27. from sys_role r
  28. left join sys_user_role ur on ur.role_id = r.role_id
  29. left join sys_user u on u.user_id = ur.user_id
  30. left join sys_dept d on u.dept_id = d.dept_id
  31. </sql>
  32. <select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
  33. <include refid="selectRoleVo"/>
  34. where r.del_flag = '0'
  35. <if test="roleId != null and roleId != 0">
  36. AND r.role_id = #{roleId}
  37. </if>
  38. <if test="roleName != null and roleName != ''">
  39. AND r.role_name like concat('%', #{roleName}, '%')
  40. </if>
  41. <if test="status != null and status != ''">
  42. AND r.status = #{status}
  43. </if>
  44. <if test="roleKey != null and roleKey != ''">
  45. AND r.role_key like concat('%', #{roleKey}, '%')
  46. </if>
  47. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  48. and date_format(r.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
  49. </if>
  50. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  51. and date_format(r.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
  52. </if>
  53. <if test="params.isCheckPhone != null"><!-- 结束时间检索 -->
  54. and r.is_check_phone = #{params.isCheckPhone}
  55. </if>
  56. <!-- 数据范围过滤 -->
  57. ${params.dataScope}
  58. order by r.role_sort
  59. </select>
  60. <select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
  61. <include refid="selectRoleVo"/>
  62. WHERE r.del_flag = '0' and ur.user_id = #{userId}
  63. </select>
  64. <select id="selectRoleAll" resultMap="SysRoleResult">
  65. <include refid="selectRoleVo"/>
  66. </select>
  67. <select id="selectRoleListByUserId" parameterType="Long" resultType="Integer">
  68. select r.role_id
  69. from sys_role r
  70. left join sys_user_role ur on ur.role_id = r.role_id
  71. left join sys_user u on u.user_id = ur.user_id
  72. where u.user_id = #{userId}
  73. </select>
  74. <select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
  75. <include refid="selectRoleVo"/>
  76. where r.role_id = #{roleId}
  77. </select>
  78. <select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult">
  79. <include refid="selectRoleVo"/>
  80. WHERE r.del_flag = '0' and u.user_name = #{userName}
  81. </select>
  82. <select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
  83. <include refid="selectRoleVo"/>
  84. where r.role_name=#{roleName} limit 1
  85. </select>
  86. <select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
  87. <include refid="selectRoleVo"/>
  88. where r.role_key=#{roleKey} limit 1
  89. </select>
  90. <select id="selectSysRoleByIds" resultType="com.fs.common.core.domain.entity.SysRole">
  91. select role_id,is_check_phone from sys_role where role_id in
  92. <foreach collection="array" item="roleId" open="(" separator="," close=")">
  93. #{roleId}
  94. </foreach>
  95. </select>
  96. <insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
  97. insert into sys_role(
  98. <if test="roleId != null and roleId != 0">role_id,</if>
  99. <if test="roleName != null and roleName != ''">role_name,</if>
  100. <if test="roleKey != null and roleKey != ''">role_key,</if>
  101. <if test="roleSort != null and roleSort != ''">role_sort,</if>
  102. <if test="dataScope != null and dataScope != ''">data_scope,</if>
  103. <if test="menuCheckStrictly != null">menu_check_strictly,</if>
  104. <if test="deptCheckStrictly != null">dept_check_strictly,</if>
  105. <if test="status != null and status != ''">status,</if>
  106. <if test="remark != null and remark != ''">remark,</if>
  107. <if test="createBy != null and createBy != ''">create_by,</if>
  108. <if test="isCheckPhone != null">is_check_phone,</if>
  109. <if test="isCheckAddress != null">is_check_address,</if>
  110. create_time
  111. )values(
  112. <if test="roleId != null and roleId != 0">#{roleId},</if>
  113. <if test="roleName != null and roleName != ''">#{roleName},</if>
  114. <if test="roleKey != null and roleKey != ''">#{roleKey},</if>
  115. <if test="roleSort != null and roleSort != ''">#{roleSort},</if>
  116. <if test="dataScope != null and dataScope != ''">#{dataScope},</if>
  117. <if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
  118. <if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
  119. <if test="status != null and status != ''">#{status},</if>
  120. <if test="remark != null and remark != ''">#{remark},</if>
  121. <if test="createBy != null and createBy != ''">#{createBy},</if>
  122. <if test="isCheckPhone != null">#{isCheckPhone},</if>
  123. <if test="isCheckAddress != null">#{isCheckAddress},</if>
  124. sysdate()
  125. )
  126. </insert>
  127. <update id="updateRole" parameterType="SysRole">
  128. update sys_role
  129. <set>
  130. <if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
  131. <if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
  132. <if test="roleSort != null and roleSort != ''">role_sort = #{roleSort},</if>
  133. <if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
  134. <if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
  135. <if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
  136. <if test="status != null and status != ''">status = #{status},</if>
  137. <if test="remark != null">remark = #{remark},</if>
  138. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  139. <if test="isCheckPhone != null">is_check_phone = #{isCheckPhone},</if>
  140. <if test="isCheckAddress != null">is_check_address = #{isCheckAddress},</if>
  141. update_time = sysdate()
  142. </set>
  143. where role_id = #{roleId}
  144. </update>
  145. <delete id="deleteRoleById" parameterType="Long">
  146. update sys_role set del_flag = '2' where role_id = #{roleId}
  147. </delete>
  148. <delete id="deleteRoleByIds" parameterType="Long">
  149. update sys_role set del_flag = '2' where role_id in
  150. <foreach collection="array" item="roleId" open="(" separator="," close=")">
  151. #{roleId}
  152. </foreach>
  153. </delete>
  154. </mapper>