UserFollowMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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.goafanti.common.dao.UserFollowMapper">
  6. <resultMap id="BaseResultMap" type="com.goafanti.common.model.UserFollow">
  7. <id property="id" column="id" jdbcType="VARCHAR"/>
  8. <result property="uid" column="uid" jdbcType="VARCHAR"/>
  9. <result property="aid" column="aid" jdbcType="VARCHAR"/>
  10. <result property="paid" column="paid" jdbcType="VARCHAR"/>
  11. <result property="result" column="result" jdbcType="VARCHAR"/>
  12. <result property="attachmentUrl" column="attachment_url" jdbcType="VARCHAR"/>
  13. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  14. <result property="ocbId" column="ocb_id" jdbcType="VARCHAR"/>
  15. <result property="contactType" column="contact_type" jdbcType="INTEGER"/>
  16. <result property="effective" column="effective" jdbcType="INTEGER"/>
  17. <result property="timeStamp" column="time_stamp" jdbcType="TIMESTAMP"/>
  18. <result property="followCount" column="follow_count" jdbcType="INTEGER"/>
  19. <result property="guidance" column="guidance" jdbcType="VARCHAR"/>
  20. <result property="guidanceTime" column="guidance_time" jdbcType="TIMESTAMP"/>
  21. <result property="guidanceAid" column="guidance_aid" jdbcType="VARCHAR"/>
  22. <result property="guidanceName" column="guidance_name" jdbcType="VARCHAR"/>
  23. <result property="followName" column="follow_name" jdbcType="VARCHAR"/>
  24. <result property="followDep" column="follow_dep" jdbcType="VARCHAR"/>
  25. <result property="type" column="type" jdbcType="INTEGER"/>
  26. <result property="pid" column="pid" jdbcType="VARCHAR"/>
  27. </resultMap>
  28. <sql id="Base_Column_List">
  29. id,uid,aid,
  30. paid,result,attachment_url,
  31. create_time,ocb_id,contact_type,
  32. effective,time_stamp,follow_count,
  33. guidance,guidance_time,guidance_aid,
  34. guidance_name,follow_name,follow_dep,
  35. type,pid
  36. </sql>
  37. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  38. select
  39. <include refid="Base_Column_List" />
  40. from user_follow
  41. where id = #{id,jdbcType=VARCHAR}
  42. </select>
  43. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  44. delete from user_follow
  45. where id = #{id,jdbcType=VARCHAR}
  46. </delete>
  47. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.UserFollow" useGeneratedKeys="true">
  48. insert into user_follow
  49. ( id,uid,aid
  50. ,paid,result,attachment_url
  51. ,create_time,ocb_id,contact_type
  52. ,effective,time_stamp,follow_count
  53. ,guidance,guidance_time,guidance_aid
  54. ,guidance_name,follow_name,follow_dep
  55. ,type,pid)
  56. values (#{id,jdbcType=VARCHAR},#{uid,jdbcType=VARCHAR},#{aid,jdbcType=VARCHAR}
  57. ,#{paid,jdbcType=VARCHAR},#{result,jdbcType=VARCHAR},#{attachmentUrl,jdbcType=VARCHAR}
  58. ,#{createTime,jdbcType=TIMESTAMP},#{ocbId,jdbcType=VARCHAR},#{contactType,jdbcType=INTEGER}
  59. ,#{effective,jdbcType=INTEGER},#{timeStamp,jdbcType=TIMESTAMP},#{followCount,jdbcType=INTEGER}
  60. ,#{guidance,jdbcType=VARCHAR},#{guidanceTime,jdbcType=TIMESTAMP},#{guidanceAid,jdbcType=VARCHAR}
  61. ,#{guidanceName,jdbcType=VARCHAR},#{followName,jdbcType=VARCHAR},#{followDep,jdbcType=VARCHAR}
  62. ,#{type,jdbcType=INTEGER},#{pid,jdbcType=VARCHAR})
  63. </insert>
  64. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.UserFollow" useGeneratedKeys="true">
  65. insert into user_follow
  66. <trim prefix="(" suffix=")" suffixOverrides=",">
  67. <if test="id != null">id,</if>
  68. <if test="uid != null">uid,</if>
  69. <if test="aid != null">aid,</if>
  70. <if test="paid != null">paid,</if>
  71. <if test="result != null">result,</if>
  72. <if test="attachmentUrl != null">attachment_url,</if>
  73. <if test="createTime != null">create_time,</if>
  74. <if test="ocbId != null">ocb_id,</if>
  75. <if test="contactType != null">contact_type,</if>
  76. <if test="effective != null">effective,</if>
  77. <if test="timeStamp != null">time_stamp,</if>
  78. <if test="followCount != null">follow_count,</if>
  79. <if test="guidance != null">guidance,</if>
  80. <if test="guidanceTime != null">guidance_time,</if>
  81. <if test="guidanceAid != null">guidance_aid,</if>
  82. <if test="guidanceName != null">guidance_name,</if>
  83. <if test="followName != null">follow_name,</if>
  84. <if test="followDep != null">follow_dep,</if>
  85. <if test="type != null">type,</if>
  86. <if test="pid != null">pid,</if>
  87. </trim>
  88. <trim prefix="values (" suffix=")" suffixOverrides=",">
  89. <if test="id != null">#{id,jdbcType=VARCHAR},</if>
  90. <if test="uid != null">#{uid,jdbcType=VARCHAR},</if>
  91. <if test="aid != null">#{aid,jdbcType=VARCHAR},</if>
  92. <if test="paid != null">#{paid,jdbcType=VARCHAR},</if>
  93. <if test="result != null">#{result,jdbcType=VARCHAR},</if>
  94. <if test="attachmentUrl != null">#{attachmentUrl,jdbcType=VARCHAR},</if>
  95. <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
  96. <if test="ocbId != null">#{ocbId,jdbcType=VARCHAR},</if>
  97. <if test="contactType != null">#{contactType,jdbcType=INTEGER},</if>
  98. <if test="effective != null">#{effective,jdbcType=INTEGER},</if>
  99. <if test="timeStamp != null">#{timeStamp,jdbcType=TIMESTAMP},</if>
  100. <if test="followCount != null">#{followCount,jdbcType=INTEGER},</if>
  101. <if test="guidance != null">#{guidance,jdbcType=VARCHAR},</if>
  102. <if test="guidanceTime != null">#{guidanceTime,jdbcType=TIMESTAMP},</if>
  103. <if test="guidanceAid != null">#{guidanceAid,jdbcType=VARCHAR},</if>
  104. <if test="guidanceName != null">#{guidanceName,jdbcType=VARCHAR},</if>
  105. <if test="followName != null">#{followName,jdbcType=VARCHAR},</if>
  106. <if test="followDep != null">#{followDep,jdbcType=VARCHAR},</if>
  107. <if test="type != null">#{type,jdbcType=INTEGER},</if>
  108. <if test="pid != null">#{pid,jdbcType=VARCHAR},</if>
  109. </trim>
  110. </insert>
  111. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.UserFollow">
  112. update user_follow
  113. <set>
  114. <if test="uid != null">
  115. uid = #{uid,jdbcType=VARCHAR},
  116. </if>
  117. <if test="aid != null">
  118. aid = #{aid,jdbcType=VARCHAR},
  119. </if>
  120. <if test="paid != null">
  121. paid = #{paid,jdbcType=VARCHAR},
  122. </if>
  123. <if test="result != null">
  124. result = #{result,jdbcType=VARCHAR},
  125. </if>
  126. <if test="attachmentUrl != null">
  127. attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
  128. </if>
  129. <if test="createTime != null">
  130. create_time = #{createTime,jdbcType=TIMESTAMP},
  131. </if>
  132. <if test="ocbId != null">
  133. ocb_id = #{ocbId,jdbcType=VARCHAR},
  134. </if>
  135. <if test="contactType != null">
  136. contact_type = #{contactType,jdbcType=INTEGER},
  137. </if>
  138. <if test="effective != null">
  139. effective = #{effective,jdbcType=INTEGER},
  140. </if>
  141. <if test="timeStamp != null">
  142. time_stamp = #{timeStamp,jdbcType=TIMESTAMP},
  143. </if>
  144. <if test="followCount != null">
  145. follow_count = #{followCount,jdbcType=INTEGER},
  146. </if>
  147. <if test="guidance != null">
  148. guidance = #{guidance,jdbcType=VARCHAR},
  149. </if>
  150. <if test="guidanceTime != null">
  151. guidance_time = #{guidanceTime,jdbcType=TIMESTAMP},
  152. </if>
  153. <if test="guidanceAid != null">
  154. guidance_aid = #{guidanceAid,jdbcType=VARCHAR},
  155. </if>
  156. <if test="guidanceName != null">
  157. guidance_name = #{guidanceName,jdbcType=VARCHAR},
  158. </if>
  159. <if test="followName != null">
  160. follow_name = #{followName,jdbcType=VARCHAR},
  161. </if>
  162. <if test="followDep != null">
  163. follow_dep = #{followDep,jdbcType=VARCHAR},
  164. </if>
  165. <if test="type != null">
  166. type = #{type,jdbcType=INTEGER},
  167. </if>
  168. <if test="pid != null">
  169. pid = #{pid,jdbcType=VARCHAR},
  170. </if>
  171. </set>
  172. where id = #{id,jdbcType=VARCHAR}
  173. </update>
  174. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.UserFollow">
  175. update user_follow
  176. set
  177. uid = #{uid,jdbcType=VARCHAR},
  178. aid = #{aid,jdbcType=VARCHAR},
  179. paid = #{paid,jdbcType=VARCHAR},
  180. result = #{result,jdbcType=VARCHAR},
  181. attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
  182. create_time = #{createTime,jdbcType=TIMESTAMP},
  183. ocb_id = #{ocbId,jdbcType=VARCHAR},
  184. contact_type = #{contactType,jdbcType=INTEGER},
  185. effective = #{effective,jdbcType=INTEGER},
  186. time_stamp = #{timeStamp,jdbcType=TIMESTAMP},
  187. follow_count = #{followCount,jdbcType=INTEGER},
  188. guidance = #{guidance,jdbcType=VARCHAR},
  189. guidance_time = #{guidanceTime,jdbcType=TIMESTAMP},
  190. guidance_aid = #{guidanceAid,jdbcType=VARCHAR},
  191. guidance_name = #{guidanceName,jdbcType=VARCHAR},
  192. follow_name = #{followName,jdbcType=VARCHAR},
  193. follow_dep = #{followDep,jdbcType=VARCHAR},
  194. type = #{type,jdbcType=INTEGER},
  195. pid = #{pid,jdbcType=VARCHAR}
  196. where id = #{id,jdbcType=VARCHAR}
  197. </update>
  198. <update id="pushUserGuidance">
  199. update user_follow b, `user` a
  200. set a.guidance= #{guidance}
  201. where a.id=b.uid and b.id= #{id}
  202. </update>
  203. <select id="selectByUidAndUid" resultMap="BaseResultMap">
  204. select
  205. <include refid="Base_Column_List" />
  206. from user_follow a
  207. where a.uid= #{uid}
  208. <if test="aid !=null">
  209. and a.aid= #{aid}
  210. </if>
  211. </select>
  212. <select id="userFollowList" resultType="com.goafanti.user.bo.outUserFollowList">
  213. select b.nickname,b.share_type shareType ,b.channel,b.id,date_format(b.transfer_time,'%Y-%m-%d %H:%i:%s')startTimes,
  214. a.contact_type contactType,a.follow_name followName ,a.follow_dep followDep,a.`result` ,a.follow_count followCount,
  215. date_format(a.create_time ,'%Y-%m-%d %H:%i:%s')followTimes,a.guidance_name guidanceName, a.guidance ,a.type,a.pid,
  216. date_format(a.guidance_time,'%Y-%m-%d %H:%i:%s') guidanceTimes,c.contacts ,c.contact_mobile contactMobile,
  217. c.location_province province ,c.location_city city ,c.location_area area,e.bname projectName,
  218. c.intended_project intendedProject ,c.business_scope businessScope
  219. from user_follow a left join `user`b on a.uid =b.id left join organization_identity c on a.uid=c.uid
  220. left join admin d on a.aid =d.id left join business_project e on a.pid =e.id
  221. where 1=1
  222. <include refid="userFollowSql"/>
  223. order by a.create_time desc
  224. <if test="page_sql != null">
  225. ${page_sql}
  226. </if>
  227. </select>
  228. <sql id="userFollowSql">
  229. <if test="shiroType == 0">
  230. and a.aid= #{aid}
  231. </if>
  232. <if test="shiroType == 1">
  233. and a.aid in
  234. <foreach close=")" collection="aids" item="id" open="(" separator=",">
  235. #{id}
  236. </foreach>
  237. </if>
  238. <if test="followName != null">
  239. and a.follow_name like concat('%',#{followName},'%')
  240. </if>
  241. <if test="userName != null">
  242. and b.nickname like concat('%',#{userName},'%')
  243. </if>
  244. <if test="userType == 1">
  245. and b.share_type =0
  246. </if>
  247. <if test="userType == 2">
  248. and b.share_type =1
  249. </if>
  250. <if test="userType == 3">
  251. and b.share_type =2
  252. </if>
  253. <if test="userType == 4">
  254. and b.share_type =3
  255. </if>
  256. <if test="userType == 5">
  257. and a.type=1
  258. </if>
  259. <if test="contactType != null">
  260. and a.contact_type = #{contactType}
  261. </if>
  262. <if test="followStartTime !=null and followEndTime !=null">
  263. and a.create_time between #{followStartTime} and #{followEndTime}
  264. </if>
  265. <if test="createStartTime !=null and createEndTime !=null">
  266. and b.transfer_time between #{createStartTime} and #{createEndTime}
  267. </if>
  268. <if test="guidanceStartTime !=null and guidanceEndTime !=null">
  269. and a.guidance_time between #{guidanceStartTime} and #{guidanceEndTime}
  270. </if>
  271. <if test="deps != null">
  272. and d.department_id in
  273. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  274. #{depId}
  275. </foreach>
  276. </if>
  277. </sql>
  278. <select id="userFollowCount" resultType="java.lang.Integer">
  279. select count(*)
  280. from user_follow a left join `user`b on a.uid =b.id
  281. left join admin d on a.aid =d.id where 1=1
  282. <include refid="userFollowSql"/>
  283. </select>
  284. <select id="selectByaidAndDate" resultType="java.lang.Integer">
  285. select count(*)followCount
  286. from (select aid
  287. from user_follow where aid= #{aid}
  288. and create_time BETWEEN #{startTime} and #{endTime})a
  289. group by aid
  290. </select>
  291. </mapper>