UserProfileMapper.xml 12 KB

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