UserProfileMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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.zhongzheng.modules.base.mapper.UserProfileMapper">
  6. <resultMap type="com.zhongzheng.modules.base.domain.UserProfile" id="UserProfileResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="goodsId" column="goods_id"/>
  10. <result property="status" column="status"/>
  11. <result property="createTime" column="create_time"/>
  12. <result property="updateTime" column="update_time"/>
  13. <result property="oneTime" column="one_time"/>
  14. <result property="lastTime" column="last_time"/>
  15. <result property="keyValue" column="key_value"/>
  16. <result property="createByName" column="create_by_name"/>
  17. <result property="currentStatus" column="current_status"/>
  18. <result property="changeStatus" column="change_status"/>
  19. <result property="text" column="text"/>
  20. <result property="auditTime" column="audit_time"/>
  21. </resultMap>
  22. <resultMap type="com.zhongzheng.modules.base.vo.UserProfileVo" id="UserProfileVo">
  23. <result property="id" column="id"/>
  24. <result property="userId" column="user_id"/>
  25. <result property="goodsId" column="goods_id"/>
  26. <result property="sex" column="sex"/>
  27. <result property="status" column="status"/>
  28. <result property="oneTime" column="one_time"/>
  29. <result property="lastTime" column="last_time"/>
  30. <result property="keyValue" column="key_value"/>
  31. <result property="currentStatus" column="current_status"/>
  32. <result property="changeStatus" column="change_status"/>
  33. <result property="realname" column="realname"/>
  34. <result property="userAccount" column="user_account"/>
  35. <result property="telphone" column="telphone"/>
  36. <result property="idCard" column="id_card"/>
  37. <result property="goodsName" column="goods_name"/>
  38. <result property="goodsCode" column="goods_code"/>
  39. <result property="educationName" column="education_name"/>
  40. <result property="projectName" column="project_name"/>
  41. <result property="businessName" column="business_name"/>
  42. <result property="text" column="text"/>
  43. <result property="auditTime" column="audit_time"/>
  44. </resultMap>
  45. <select id="selectUserProfile" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  46. SELECT
  47. up.*,
  48. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  49. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  50. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  51. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  52. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  53. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  54. (SELECT cet.education_name FROM goods g LEFT JOIN course_education_type cet on g.education_type_id = cet.id where up.goods_id = g.goods_id) as education_name,
  55. (SELECT cet.project_name FROM goods g LEFT JOIN course_project_type cet on g.project_id = cet.id where up.goods_id = g.goods_id) as project_name,
  56. (SELECT cet.business_name FROM goods g LEFT JOIN course_business cet on g.business_id = cet.id where up.goods_id = g.goods_id) as business_name
  57. FROM
  58. user_profile up
  59. LEFT JOIN goods g ON up.goods_id = g.goods_id LEFT JOIN course_business cb on g.business_id = cb.id
  60. where 1=1
  61. and up.current_status = 1
  62. <if test="status != null and status.size()!=0 ">
  63. AND up.status in
  64. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  65. #{item}
  66. </foreach>
  67. </if>
  68. <if test="id != null and id !='' ">
  69. AND up.id =#{id}
  70. </if>
  71. <if test="typeStatus != null and typeStatus !='' ">
  72. and up.type_status = #{typeStatus}
  73. </if>
  74. <if test="userId != null and userId !='' ">
  75. AND up.user_id =#{userId}
  76. </if>
  77. <if test="goodsId != null and goodsId !='' ">
  78. AND up.goods_id =#{goodsId}
  79. </if>
  80. <if test="educationTypeId != null and educationTypeId !='' ">
  81. AND (SELECT cet.id FROM goods g LEFT JOIN course_education_type cet on g.education_type_id = cet.id where up.goods_id = g.goods_id) =#{educationTypeId}
  82. </if>
  83. <if test="businessId != null and businessId !='' ">
  84. AND cb.id =#{businessId}
  85. </if>
  86. <if test="schoolId != null and schoolId !='' ">
  87. AND (SELECT g.school_id FROM goods g where up.goods_id = g.goods_id) =#{schoolId}
  88. </if>
  89. <if test="majorId != null and majorId !='' ">
  90. AND (SELECT g.major_id FROM goods g where up.goods_id = g.goods_id) =#{majorId}
  91. </if>
  92. <if test="changeStatus != null and changeStatus !='' ">
  93. AND up.change_status =#{changeStatus}
  94. </if>
  95. <if test="realname != null and realname !='' ">
  96. AND (SELECT count(1) FROM `user` u where u.user_id = up.user_id and u.realname like concat('%', #{realname}, '%') )> 0
  97. </if>
  98. <if test="searchStartTime != null and searchStartTime !='' ">
  99. AND up.create_time >=#{searchStartTime}
  100. </if>
  101. <if test="searchEndTime != null and searchEndTime !='' ">
  102. AND #{searchEndTime} >= up.create_time
  103. </if>
  104. <!-- 数据范围过滤 -->
  105. ${params.dataScope}
  106. order by up.create_time desc
  107. </select>
  108. <select id="getInfo" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  109. SELECT
  110. up.*,
  111. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  112. (SELECT u.sex FROM `user` u where u.user_id = up.user_id) as sex,
  113. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  114. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  115. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  116. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  117. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  118. (SELECT cet.education_name FROM goods g LEFT JOIN course_education_type cet on g.education_type_id = cet.id where up.goods_id = g.goods_id) as education_name,
  119. (SELECT cet.project_name FROM goods g LEFT JOIN course_project_type cet on g.project_id = cet.id where up.goods_id = g.goods_id) as project_name,
  120. (SELECT cet.business_name FROM goods g LEFT JOIN course_business cet on g.business_id = cet.id where up.goods_id = g.goods_id) as business_name
  121. FROM
  122. user_profile up
  123. where 1=1
  124. and up.current_status = 1
  125. <if test="typeStatus != null and typeStatus !='' ">
  126. and up.type_status = #{typeStatus}
  127. </if>
  128. <if test="status != null and status.size()!=0 ">
  129. AND up.status in
  130. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  131. #{item}
  132. </foreach>
  133. </if>
  134. <if test="id != null and id !='' ">
  135. AND up.id =#{id}
  136. </if>
  137. <if test="userId != null and userId !='' ">
  138. AND up.user_id =#{userId}
  139. </if>
  140. <if test="goodsId != null and goodsId !='' ">
  141. AND up.goods_id =#{goodsId}
  142. </if>
  143. order by up.create_time desc LIMIT 1
  144. </select>
  145. <select id="listRecord" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  146. SELECT
  147. up.*,
  148. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  149. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  150. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  151. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  152. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  153. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  154. (SELECT cet.education_name FROM goods g LEFT JOIN course_education_type cet on g.education_type_id = cet.id where up.goods_id = g.goods_id) as education_name,
  155. (SELECT cet.project_name FROM goods g LEFT JOIN course_project_type cet on g.project_id = cet.id where up.goods_id = g.goods_id) as project_name,
  156. (SELECT cet.business_name FROM goods g LEFT JOIN course_business cet on g.business_id = cet.id where up.goods_id = g.goods_id) as business_name
  157. FROM
  158. user_profile up
  159. where 1=1
  160. and up.status != 2
  161. AND up.change_status != 2
  162. <if test="typeStatus != null and typeStatus !='' ">
  163. and up.type_status = #{typeStatus}
  164. </if>
  165. <if test="status != null and status.size()!=0 ">
  166. AND up.status in
  167. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  168. #{item}
  169. </foreach>
  170. </if>
  171. <if test="id != null and id !='' ">
  172. AND up.id =#{id}
  173. </if>
  174. <if test="userId != null and userId !='' ">
  175. AND up.user_id =#{userId}
  176. </if>
  177. <if test="goodsId != null and goodsId !='' ">
  178. AND up.goods_id =#{goodsId}
  179. </if>
  180. <if test="educationTypeId != null and educationTypeId !='' ">
  181. AND g.education_type_id =#{educationTypeId}
  182. </if>
  183. <if test="businessId != null and businessId !='' ">
  184. AND g.business_id =#{businessId}
  185. </if>
  186. <if test="schoolId != null and schoolId !='' ">
  187. AND g.school_id =#{schoolId}
  188. </if>
  189. <if test="majorId != null and majorId !='' ">
  190. AND g.major_id =#{majorId}
  191. </if>
  192. <if test="changeStatus != null and changeStatus !='' ">
  193. AND up.change_status =#{changeStatus}
  194. </if>
  195. order by up.create_time desc
  196. </select>
  197. <select id="selectCountProfile" parameterType="map" resultType="Long">
  198. SELECT
  199. COUNT(1)
  200. FROM
  201. profile_tp p
  202. WHERE
  203. 1 = 1
  204. AND FIND_IN_SET(#{goodsId},p.goods_ids)
  205. and FIND_IN_SET(#{userId},p.user_ids)
  206. </select>
  207. <select id="selectGrade" parameterType="map" resultType="Long">
  208. SELECT
  209. cgu.grade_id
  210. FROM
  211. class_grade_user cgu
  212. LEFT JOIN class_grade_goods cgg on cgu.grade_id = cgg.grade_id
  213. LEFT JOIN class_grade cg on cg.grade_id = cgg.grade_id
  214. WHERE
  215. cgu.user_id = #{userId}
  216. and cgg.goods_id = #{goodsId}
  217. and cg.`status` = 1
  218. and cgu.`status` = 1
  219. ORDER BY cgu.create_time desc
  220. LIMIT 1
  221. </select>
  222. </mapper>