UserRoleMapper.xml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.juxiao.xchat.module.system.mapper.UserRoleMapper">
  6. <resultMap type="com.juxiao.xchat.module.system.domain.UserRole" id="UserRoleResult">
  7. <result property="userId" column="user_id" />
  8. <result property="roleId" column="role_id" />
  9. </resultMap>
  10. <delete id="deleteUserRoleByUserId" parameterType="java.lang.Long">
  11. delete from sys_user_role where user_id=#{userId}
  12. </delete>
  13. <select id="countUserRoleByRoleId" resultType="java.lang.Integer">
  14. select count(1) from sys_user_role where role_id=#{roleId}
  15. </select>
  16. <delete id="deleteUserRole" parameterType="java.lang.Long">
  17. delete from sys_user_role where user_id in
  18. <foreach collection="array" item="userId" open="(" separator="," close=")">
  19. #{userId}
  20. </foreach>
  21. </delete>
  22. <insert id="batchUserRole">
  23. insert into sys_user_role(user_id, role_id) values
  24. <foreach item="item" index="index" collection="list" separator=",">
  25. (#{item.userId},#{item.roleId})
  26. </foreach>
  27. </insert>
  28. <delete id="deleteUserRoleInfo" parameterType="com.juxiao.xchat.module.system.domain.UserRole">
  29. delete from sys_user_role where user_id=#{userId} and role_id=#{roleId}
  30. </delete>
  31. <delete id="deleteUserRoleInfos">
  32. delete from sys_user_role where role_id=#{roleId} and user_id in
  33. <foreach collection="userIds" item="userId" open="(" separator="," close=")">
  34. #{userId}
  35. </foreach>
  36. </delete>
  37. </mapper>