StorePlatformUserRoleMapper.xml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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="shop.alien.mapper.StorePlatformUserRoleMapper">
  6. <!-- 根据店铺ID查询子账号列表(连表查询) -->
  7. <select id="querySubAccounts" resultType="shop.alien.entity.store.vo.SubAccountVo">
  8. SELECT
  9. spur.id AS id,
  10. sur.id AS userId,
  11. spur.account_name AS accountName,
  12. sur.phone AS phone,
  13. spr.role_id AS roleId,
  14. spr.role_name AS roleName,
  15. spur.store_id AS storeId,
  16. 0 AS permissionCount
  17. FROM store_platform_user_role spur
  18. INNER JOIN store_user sur ON spur.user_id = sur.id
  19. LEFT JOIN store_platform_role spr ON spur.role_id = spr.role_id
  20. WHERE spur.store_id = #{storeId}
  21. AND sur.delete_flag = 0
  22. AND spur.delete_flag = 0
  23. <if test="accountName != null and accountName != ''">
  24. AND (spur.account_name LIKE CONCAT('%', #{accountName}, '%') )
  25. </if>
  26. <if test="phone != null and phone != ''">
  27. AND sur.phone LIKE CONCAT('%', #{phone}, '%')
  28. </if>
  29. <if test="roleName != null and roleName != ''">
  30. AND spr.role_name LIKE CONCAT('%', #{roleName}, '%')
  31. </if>
  32. ORDER BY spur.created_time DESC
  33. </select>
  34. <!-- 查询所有子账号信息(包含主账号电话) -->
  35. <select id="queryAllSubAccounts" resultType="shop.alien.entity.store.vo.SubAccountListVo">
  36. SELECT
  37. su_main.id AS mainAccountId,
  38. su_main.phone AS mainAccountPhone,
  39. sur.id AS userId,
  40. sur.phone AS phone,
  41. spur.id AS subAccountId,
  42. spur.account_name AS accountName,
  43. spur.store_id AS storeId,
  44. spr.role_id AS roleId,
  45. spr.role_name AS roleName,
  46. spur.created_time AS createdTime,
  47. spur.status AS status
  48. FROM store_platform_user_role spur
  49. INNER JOIN store_user sur ON spur.user_id = sur.id
  50. LEFT JOIN store_user su_main ON spur.store_id = su_main.store_id
  51. AND su_main.account_type = 1
  52. AND su_main.delete_flag = 0
  53. LEFT JOIN store_platform_role spr ON spur.role_id = spr.role_id
  54. WHERE spur.delete_flag = 0
  55. AND sur.delete_flag = 0
  56. <if test="accountId != null and accountId != ''">
  57. AND (sur.id LIKE CONCAT('%', #{accountId}, '%')
  58. OR su_main.id LIKE CONCAT('%', #{accountId}, '%'))
  59. </if>
  60. <if test="phone != null and phone != ''">
  61. AND sur.phone LIKE CONCAT('%', #{phone}, '%')
  62. </if>
  63. <if test="status != null">
  64. AND spur.status = #{status}
  65. </if>
  66. ORDER BY spur.created_time DESC
  67. </select>
  68. </mapper>