UserProfileMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. <!-- 数据范围过滤 -->
  99. ${params.dataScope}
  100. order by up.create_time desc
  101. </select>
  102. <select id="getInfo" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  103. SELECT
  104. up.*,
  105. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  106. (SELECT u.sex FROM `user` u where u.user_id = up.user_id) as sex,
  107. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  108. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  109. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  110. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  111. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  112. (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,
  113. (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,
  114. (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
  115. FROM
  116. user_profile up
  117. where 1=1
  118. and up.current_status = 1
  119. <if test="typeStatus != null and typeStatus !='' ">
  120. and up.type_status = #{typeStatus}
  121. </if>
  122. <if test="status != null and status.size()!=0 ">
  123. AND up.status in
  124. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  125. #{item}
  126. </foreach>
  127. </if>
  128. <if test="id != null and id !='' ">
  129. AND up.id =#{id}
  130. </if>
  131. <if test="userId != null and userId !='' ">
  132. AND up.user_id =#{userId}
  133. </if>
  134. <if test="goodsId != null and goodsId !='' ">
  135. AND up.goods_id =#{goodsId}
  136. </if>
  137. order by up.create_time desc LIMIT 1
  138. </select>
  139. <select id="listRecord" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  140. SELECT
  141. up.*,
  142. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  143. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  144. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  145. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  146. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  147. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  148. (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,
  149. (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,
  150. (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
  151. FROM
  152. user_profile up
  153. where 1=1
  154. and up.status != 2
  155. AND up.change_status != 2
  156. <if test="typeStatus != null and typeStatus !='' ">
  157. and up.type_status = #{typeStatus}
  158. </if>
  159. <if test="status != null and status.size()!=0 ">
  160. AND up.status in
  161. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  162. #{item}
  163. </foreach>
  164. </if>
  165. <if test="id != null and id !='' ">
  166. AND up.id =#{id}
  167. </if>
  168. <if test="userId != null and userId !='' ">
  169. AND up.user_id =#{userId}
  170. </if>
  171. <if test="goodsId != null and goodsId !='' ">
  172. AND up.goods_id =#{goodsId}
  173. </if>
  174. <if test="educationTypeId != null and educationTypeId !='' ">
  175. AND g.education_type_id =#{educationTypeId}
  176. </if>
  177. <if test="businessId != null and businessId !='' ">
  178. AND g.business_id =#{businessId}
  179. </if>
  180. <if test="schoolId != null and schoolId !='' ">
  181. AND g.school_id =#{schoolId}
  182. </if>
  183. <if test="majorId != null and majorId !='' ">
  184. AND g.major_id =#{majorId}
  185. </if>
  186. <if test="changeStatus != null and changeStatus !='' ">
  187. AND up.change_status =#{changeStatus}
  188. </if>
  189. order by up.create_time desc
  190. </select>
  191. <select id="selectCountProfile" parameterType="map" resultType="Long">
  192. SELECT
  193. COUNT(1)
  194. FROM
  195. profile_tp p
  196. WHERE
  197. 1 = 1
  198. AND FIND_IN_SET(#{goodsId},p.goods_ids)
  199. and FIND_IN_SET(#{userId},p.user_ids)
  200. </select>
  201. <select id="selectGrade" parameterType="map" resultType="Long">
  202. SELECT
  203. cgu.grade_id
  204. FROM
  205. class_grade_user cgu
  206. LEFT JOIN class_grade_goods cgg on cgu.grade_id = cgg.grade_id
  207. LEFT JOIN class_grade cg on cg.grade_id = cgg.grade_id
  208. WHERE
  209. cgu.user_id = #{userId}
  210. and cgg.goods_id = #{goodsId}
  211. and cg.`status` = 1
  212. and cgu.`status` = 1
  213. ORDER BY cgu.create_time desc
  214. LIMIT 1
  215. </select>
  216. </mapper>