SmartUserMapper.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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.template.mapper.SmartUserMapper">
  4. <resultMap type="com.template.model.vo.AffiliateUserVo" id="affiliateUserMap">
  5. <result property="id" column="id"/>
  6. <result property="name" column="name"/>
  7. <result property="cardNo" column="card_no"/>
  8. <result property="departmentId" column="department_id"/>
  9. <result property="headImage" column="head_image"/>
  10. </resultMap>
  11. <select id="queryAffiliateUserById" resultType="com.template.model.vo.AffiliateUserVo" resultMap="affiliateUserMap">
  12. select id,name,card_no,department_id,head_image from smart_user
  13. where find_in_set(id,(select affiliate from smart_user where
  14. deleted = 0
  15. <if test="id != null and id != ''">
  16. and id = #{id}
  17. </if>
  18. )) and deleted = 0
  19. </select>
  20. <resultMap type="com.template.model.vo.UserVo" id="smartUserPageMap">
  21. <result property="id" column="id"/>
  22. <result property="cardNo" column="card_no"/>
  23. <result property="name" column="name"/>
  24. <result property="identityId" column="identity_id"/>
  25. <result property="idCard" column="id_card"/>
  26. <result property="sexId" column="sex_id"/>
  27. <result property="departmentId" column="department_id"/>
  28. <result property="headImage" column="head_image"/>
  29. <result property="grade" column="grade"/>
  30. <result property="college" column="college"/>
  31. <result property="speciality" column="speciality"/>
  32. <result property="schoolClass" column="school_class"/>
  33. <result property="campus" column="campus"/>
  34. <result property="dormitoryNumber" column="dormitory_number"/>
  35. <result property="phone" column="phone"/>
  36. <result property="affiliate" column="affiliate"/>
  37. <result property="title" column="title"/>
  38. <result property="address" column="address"/>
  39. <result property="nation" column="nation"/>
  40. <result property="ofStudent" column="of_student"/>
  41. <result property="graduate" column="graduate"/>
  42. <result property="duties" column="duties"/>
  43. <result property="timeGroupId" column="time_group_id"/>
  44. </resultMap>
  45. <select id="querySmartUserPages" resultType="com.template.model.vo.UserVo" resultMap="smartUserPageMap">
  46. select
  47. id,card_no,name,identity_id,id_card,sex_id,department_id,head_image,grade,college,speciality,school_class,campus,dormitory_number,
  48. phone,affiliate,title,address,nation,of_student,graduate,duties,time_group_id
  49. from smart_user
  50. where deleted = 0 and is_cancel = 0
  51. <if test="departmentIds != null and departmentIds.size() > 0">
  52. and department_id in
  53. <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
  54. ${departmentId}
  55. </foreach>
  56. </if>
  57. <if test="name != null and name != ''">
  58. and (name like '%' #{name} '%' or card_no like '%' #{name} '%')
  59. </if>
  60. </select>
  61. <resultMap type="com.template.model.pojo.SmartUser" id="smartUsersMap">
  62. <result property="cardNo" column="card_no"/>
  63. <result property="name" column="name"/>
  64. <result property="identityId" column="identity_id"/>
  65. <result property="idCard" column="id_card"/>
  66. <result property="sexId" column="sex_id"/>
  67. <result property="departmentId" column="department_id"/>
  68. <result property="headImage" column="head_image"/>
  69. <result property="grade" column="grade"/>
  70. <result property="college" column="college"/>
  71. <result property="speciality" column="speciality"/>
  72. <result property="schoolClass" column="school_class"/>
  73. <result property="campus" column="campus"/>
  74. <result property="dormitoryNumber" column="dormitory_number"/>
  75. <result property="phone" column="phone"/>
  76. <result property="affiliate" column="affiliate"/>
  77. <result property="title" column="title"/>
  78. <result property="address" column="address"/>
  79. <result property="nation" column="nation"/>
  80. <result property="ofStudent" column="of_student"/>
  81. <result property="graduate" column="graduate"/>
  82. <result property="duties" column="duties"/>
  83. </resultMap>
  84. <select id="querySmartUsers" resultType="com.template.model.pojo.SmartUser" resultMap="smartUsersMap">
  85. select
  86. card_no,name,identity_id,id_card,sex_id,department_id,head_image,grade,college,speciality,school_class,campus,dormitory_number,
  87. phone,affiliate,title,address,nation,of_student,graduate,duties from smart_user
  88. where deleted = 0 and is_cancel = 0
  89. <if test="departmentIds != null and departmentIds.size() > 0">
  90. and department_id in
  91. <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
  92. ${departmentId}
  93. </foreach>
  94. </if>
  95. <if test="name != null and name != ''">
  96. and name like '%' #{name} '%'
  97. </if>
  98. </select>
  99. <resultMap type="com.template.model.vo.GradeVo" id="smartSecordUserPageMap">
  100. <result property="id" column="id"/>
  101. <result property="name" column="name"/>
  102. <result property="grade" column="grade"/>
  103. <result property="schoolClass" column="school_class"/>
  104. <result property="cardNo" column="card_no"/>
  105. </resultMap>
  106. <select id="querySmartSecordPage" resultType="com.template.model.vo.GradeVo" resultMap="smartSecordUserPageMap">
  107. select id,name,grade,school_class,card_no from smart_user
  108. where deleted = 0 and is_cancel = 0 and identity_id = 2
  109. <if test="name != null and name != ''">
  110. and name like '%' #{name} '%'
  111. </if>
  112. <if test="userId != null and userId != '' and userId != 0">
  113. and id != #{userId}
  114. </if>
  115. </select>
  116. <select id="warningUserList" resultType="com.template.model.dto.WarningUserDto">
  117. SELECT
  118. su.id AS id,
  119. su.`name` AS `name`,
  120. su.card_no AS cardNo,
  121. sd.`name` AS departmentName
  122. FROM
  123. `smart_user` su
  124. LEFT JOIN smart_department sd ON sd.id = su.department_id and sd.deleted=0
  125. where su.deleted = 0 and su.is_cancel = 0
  126. <if test="name != null and name != ''">
  127. and su.`name` like '%' #{name} '%'
  128. </if>
  129. </select>
  130. <select id="warningPushList" resultType="com.template.model.dto.WarningUserDto">
  131. SELECT su.id AS id,
  132. su.`name` AS `name`,
  133. su.card_no AS cardNo,
  134. sd.`name` AS departmentName
  135. FROM `smart_user` su
  136. LEFT JOIN smart_department sd ON sd.id = su.department_id and sd.deleted = 0
  137. WHERE su.is_push = 1
  138. and su.is_cancel = 0
  139. and su.deleted = 0
  140. </select>
  141. <resultMap type="com.template.model.vo.AffiliateParentVo" id="affiliateParentMap">
  142. <result property="id" column="id"/>
  143. <result property="name" column="name"/>
  144. </resultMap>
  145. <select id="queryAffiliateParents" resultType="com.template.model.vo.AffiliateParentVo"
  146. resultMap="affiliateParentMap">
  147. SELECT id,name FROM `smart_user`
  148. where deleted = 0 and is_cancel=0
  149. <if test="userId != null and userId != ''">
  150. and FIND_IN_SET(#{userId},affiliate)
  151. </if>
  152. </select>
  153. <select id="getAffiliateList" resultType="com.template.model.pojo.SmartUser">
  154. SELECT * FROM `smart_user`
  155. where deleted = 0 and is_cancel=0
  156. <if test="id != null and id != ''">
  157. and FIND_IN_SET(#{id},affiliate)
  158. </if>
  159. </select>
  160. <resultMap type="com.template.model.vo.SmartUserVo" id="smartUserMap">
  161. <result property="id" column="id"/>
  162. <result property="grade" column="grade"/>
  163. <result property="gradeId" column="grade_id"/>
  164. <result property="schoolClass" column="school_class"/>
  165. <result property="schoolClassId" column="school_class_id"/>
  166. <result property="name" column="name"/>
  167. <result property="cardNo" column="card_no"/>
  168. </resultMap>
  169. <select id="querySmartUserById" resultType="com.template.model.vo.SmartUserVo" resultMap="smartUserMap">
  170. select su.id,sg.name as grade,sg.id as grade_id,sc.name as school_class,sc.id as school_class_id,su.name,su.card_no
  171. from smart_user su
  172. left join smart_grade sg on sg.id = su.grade and sg.deleted = 0
  173. left join smart_class sc on sc.id = su.school_class and sc.deleted = 0
  174. where su.deleted = 0
  175. <if test="userId != null and userId != '' and userId != 0">
  176. and su.id = #{userId}
  177. </if>
  178. </select>
  179. <update id="deleteUserBatch" parameterType="com.template.model.vo.deleteUserVo">
  180. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  181. update smart_user
  182. <set>
  183. delete_reason=#{item.reason}
  184. </set>
  185. where id = ${item.id}
  186. </foreach>
  187. </update>
  188. </mapper>