UserProfileMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. where 1=1
  60. and up.current_status = 1
  61. <if test="status != null and status.size()!=0 ">
  62. AND up.status in
  63. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  64. #{item}
  65. </foreach>
  66. </if>
  67. <if test="id != null and id !='' ">
  68. AND up.id =#{id}
  69. </if>
  70. <if test="typeStatus != null and typeStatus !='' ">
  71. and up.type_status = #{typeStatus}
  72. </if>
  73. <if test="userId != null and userId !='' ">
  74. AND up.user_id =#{userId}
  75. </if>
  76. <if test="goodsId != null and goodsId !='' ">
  77. AND up.goods_id =#{goodsId}
  78. </if>
  79. <if test="educationTypeId != null and educationTypeId !='' ">
  80. 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}
  81. </if>
  82. <if test="businessId != null and businessId !='' ">
  83. AND (SELECT cet.id FROM goods g LEFT JOIN course_business cet on g.business_id = cet.id where up.goods_id = g.goods_id) =#{businessId}
  84. </if>
  85. <if test="schoolId != null and schoolId !='' ">
  86. AND (SELECT g.school_id FROM goods g where up.goods_id = g.goods_id) =#{schoolId}
  87. </if>
  88. <if test="majorId != null and majorId !='' ">
  89. AND (SELECT g.major_id FROM goods g where up.goods_id = g.goods_id) =#{majorId}
  90. </if>
  91. <if test="changeStatus != null and changeStatus !='' ">
  92. AND up.change_status =#{changeStatus}
  93. </if>
  94. <if test="realname != null and realname !='' ">
  95. AND (SELECT count(1) FROM `user` u where u.user_id = up.user_id and u.realname like concat('%', #{realname}, '%') )> 0
  96. </if>
  97. order by up.create_time desc
  98. </select>
  99. <select id="getInfo" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  100. SELECT
  101. up.*,
  102. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  103. (SELECT u.sex FROM `user` u where u.user_id = up.user_id) as sex,
  104. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  105. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  106. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  107. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  108. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  109. (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,
  110. (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,
  111. (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
  112. FROM
  113. user_profile up
  114. where 1=1
  115. and up.current_status = 1
  116. <if test="typeStatus != null and typeStatus !='' ">
  117. and up.type_status = #{typeStatus}
  118. </if>
  119. <if test="status != null and status.size()!=0 ">
  120. AND up.status in
  121. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  122. #{item}
  123. </foreach>
  124. </if>
  125. <if test="id != null and id !='' ">
  126. AND up.id =#{id}
  127. </if>
  128. <if test="userId != null and userId !='' ">
  129. AND up.user_id =#{userId}
  130. </if>
  131. <if test="goodsId != null and goodsId !='' ">
  132. AND up.goods_id =#{goodsId}
  133. </if>
  134. order by up.create_time desc LIMIT 1
  135. </select>
  136. <select id="listRecord" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  137. SELECT
  138. up.*,
  139. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  140. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  141. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  142. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  143. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  144. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  145. (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,
  146. (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,
  147. (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
  148. FROM
  149. user_profile up
  150. where 1=1
  151. and up.status != 2
  152. AND up.change_status != 2
  153. <if test="typeStatus != null and typeStatus !='' ">
  154. and up.type_status = #{typeStatus}
  155. </if>
  156. <if test="status != null and status.size()!=0 ">
  157. AND up.status in
  158. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  159. #{item}
  160. </foreach>
  161. </if>
  162. <if test="id != null and id !='' ">
  163. AND up.id =#{id}
  164. </if>
  165. <if test="userId != null and userId !='' ">
  166. AND up.user_id =#{userId}
  167. </if>
  168. <if test="goodsId != null and goodsId !='' ">
  169. AND up.goods_id =#{goodsId}
  170. </if>
  171. <if test="educationTypeId != null and educationTypeId !='' ">
  172. AND g.education_type_id =#{educationTypeId}
  173. </if>
  174. <if test="businessId != null and businessId !='' ">
  175. AND g.business_id =#{businessId}
  176. </if>
  177. <if test="schoolId != null and schoolId !='' ">
  178. AND g.school_id =#{schoolId}
  179. </if>
  180. <if test="majorId != null and majorId !='' ">
  181. AND g.major_id =#{majorId}
  182. </if>
  183. <if test="changeStatus != null and changeStatus !='' ">
  184. AND up.change_status =#{changeStatus}
  185. </if>
  186. order by up.create_time desc
  187. </select>
  188. <select id="selectCountProfile" parameterType="map" resultType="Long">
  189. SELECT
  190. COUNT(1)
  191. FROM
  192. profile_tp p
  193. WHERE
  194. 1 = 1
  195. AND FIND_IN_SET(#{goodsId},p.goods_ids)
  196. and FIND_IN_SET(#{userId},p.user_ids)
  197. </select>
  198. <select id="selectGrade" parameterType="map" resultType="Long">
  199. SELECT
  200. cgu.grade_id
  201. FROM
  202. class_grade_user cgu
  203. LEFT JOIN class_grade_goods cgg on cgu.grade_id = cgg.grade_id
  204. LEFT JOIN class_grade cg on cg.grade_id = cgg.grade_id
  205. WHERE
  206. cgu.user_id = #{userId}
  207. and cgg.goods_id = #{goodsId}
  208. and cg.`status` = 1
  209. and cgu.`status` = 1
  210. ORDER BY cgu.create_time desc
  211. LIMIT 1
  212. </select>
  213. </mapper>