PushUserMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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="cn.com.ty.lift.push.push.mapper.PushUserMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="cn.com.ty.lift.common.model.PushUserInfo">
  6. <id column="user_id" property="userId"/>
  7. <result column="username" property="userName"/>
  8. <result column="mobile" property="mobile"/>
  9. <result column="device_model" property="deviceModel"/>
  10. <result column="device_flag" property="deviceFlag"/>
  11. <result column="role_name" property="roleName"/>
  12. </resultMap>
  13. <select id="listByUserId" resultMap="BaseResultMap">
  14. SELECT
  15. ui.user_id,
  16. ui.NAME AS username,
  17. ua.mobile,
  18. ua.device_model,
  19. ua.device_flag,
  20. ro.NAME AS role_name
  21. FROM
  22. user_info ui
  23. LEFT JOIN user_account ua ON ui.user_id = ua.user_id
  24. LEFT JOIN user_role ur ON ui.user_id = ur.user_id
  25. LEFT JOIN role ro ON ro.id = ur.role_id
  26. <where>
  27. <if test="mtCompanyId != null and mtCompanyId > 0">
  28. AND ur.company_id = #{mtCompanyId}
  29. </if>
  30. <if test="userId != null and userId > 0">
  31. AND ui.user_id = #{userId}
  32. </if>
  33. </where>
  34. </select>
  35. <select id="listByUserIds" resultMap="BaseResultMap">
  36. SELECT
  37. ui.user_id,
  38. ui.NAME AS username,
  39. ua.mobile,
  40. ua.device_model,
  41. ua.device_flag,
  42. ro.NAME AS role_name
  43. FROM
  44. user_info ui
  45. LEFT JOIN user_account ua ON ui.user_id = ua.user_id
  46. LEFT JOIN user_role ur ON ui.user_id = ur.user_id
  47. LEFT JOIN role ro ON ro.id = ur.role_id
  48. <where>
  49. <if test="mtCompanyId != null and mtCompanyId > 0">
  50. AND ur.company_id = #{mtCompanyId}
  51. </if>
  52. <if test="userIds != null">
  53. AND ui.user_id IN
  54. <foreach collection="userIds" item="userId" open="(" separator="," close=")">
  55. #{userId, jdbcType=BIGINT}
  56. </foreach>
  57. </if>
  58. </where>
  59. </select>
  60. <select id="listByRoleCodes" resultMap="BaseResultMap">
  61. SELECT
  62. ui.user_id,
  63. ui.NAME AS username,
  64. ua.mobile,
  65. ua.device_model,
  66. ua.device_flag,
  67. ro.NAME AS role_name
  68. FROM
  69. user_info ui
  70. LEFT JOIN user_account ua ON ui.user_id = ua.user_id
  71. LEFT JOIN user_role ur ON ui.user_id = ur.user_id
  72. LEFT JOIN role ro ON ro.id = ur.role_id
  73. <where>
  74. <if test="mtCompanyId != null and mtCompanyId > 0">
  75. AND ur.company_id = #{mtCompanyId}
  76. </if>
  77. <if test="roleCodes != null">
  78. AND ro.code IN
  79. <foreach collection="roleCodes" item="roleCode" open="(" separator="," close=")">
  80. #{roleCode, jdbcType=VARCHAR}
  81. </foreach>
  82. </if>
  83. </where>
  84. </select>
  85. <select id="listByRoleCode" resultMap="BaseResultMap">
  86. SELECT
  87. ui.user_id,
  88. ui.NAME AS username,
  89. ua.mobile,
  90. ua.device_model,
  91. ua.device_flag,
  92. ro.NAME AS role_name
  93. FROM
  94. user_info ui
  95. LEFT JOIN user_account ua ON ui.user_id = ua.user_id
  96. LEFT JOIN user_role ur ON ui.user_id = ur.user_id
  97. LEFT JOIN role ro ON ro.id = ur.role_id
  98. <where>
  99. <if test="mtCompanyId != null and mtCompanyId > 0">
  100. AND ur.company_id = #{mtCompanyId}
  101. </if>
  102. <if test="roleCode != null and roleCode != ''">
  103. AND ro.code = #{roleCode, jdbcType=VARCHAR}
  104. </if>
  105. </where>
  106. </select>
  107. <select id="pageByMtCompany" resultMap="BaseResultMap" parameterType="java.lang.Long">
  108. SELECT
  109. ui.user_id,
  110. ui.NAME AS username,
  111. ua.mobile,
  112. ua.device_model,
  113. ua.device_flag,
  114. ro.NAME AS role_name
  115. FROM
  116. user_info ui
  117. LEFT JOIN user_account ua ON ui.user_id = ua.user_id
  118. LEFT JOIN user_role ur ON ui.user_id = ur.user_id
  119. LEFT JOIN role ro ON ro.id = ur.role_id
  120. LEFT JOIN mt_company_user mcu ON mcu.user_id = ui.user_id AND mcu.mt_company_id = ur.company_id
  121. <where>
  122. <if test="mtCompanyId != null and mtCompanyId > 0">
  123. mcu.mt_company_id = #{mtCompanyId}
  124. </if>
  125. </where>
  126. </select>
  127. </mapper>