UserDao.xml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.inkasso.factoring.system.user.dao.UserDAO">
  4. <select id="getUserByOpenId" resultType="com.inkasso.factoring.system.user.model.dto.UserDTO"
  5. parameterType="java.lang.String">
  6. select
  7. a.*,
  8. b.open_id,
  9. b.id AS "wxAccountId"
  10. from kfb_sys_user a left join kfb_sys_user_wxaccount b on a.id = b.user_id
  11. where open_id = #{openId}
  12. </select>
  13. <!-- 查询所有 拥有某个资源的code 的用户集合 -->
  14. <select id="getByResourceCode" resultType="com.inkasso.factoring.system.user.model.dto.UserDTO"
  15. parameterType="java.lang.String">
  16. select
  17. a.*,
  18. a1.open_id
  19. from kfb_sys_user a
  20. LEFT JOIN kfb_sys_user_wxaccount a1 on a.id = a1.user_id
  21. JOIN kfb_sys_user_role b on a.id = b.user_id
  22. JOIN kfb_sys_role_resource c on b.role_id = c.role_id
  23. JOIN kfb_sys_resource d on c.resource_id = d.id
  24. where d.code = #{resourceCode}
  25. </select>
  26. <!-- 小程序管理端 用户数据统计 -->
  27. <select id="pageUserStatistis"
  28. resultType="com.inkasso.management.statistics.model.UserStatisticsVO">
  29. select
  30. a.phone,
  31. a.register_time "loginDate",
  32. b.authDate,
  33. c.referenceNumber,
  34. if(a.reference is null,0,1) AS "addUserType"
  35. from kfb_sys_user a
  36. LEFT JOIN (
  37. select
  38. min(create_time) AS "authDate",
  39. user_id
  40. from kfb_sys_tenant group by user_id) b on a.id = b.user_id
  41. LEFT JOIN(
  42. select
  43. reference,
  44. count(*) AS "referenceNumber"
  45. from kfb_sys_user
  46. where reference is not null
  47. group by reference ) c on c.reference = a.id
  48. </select>
  49. </mapper>