EdsSocialApplicationQueryMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.zsjz.ai.module.eds.mapper.EdsSocialApplicationQueryMapper">
  5. <!-- 社交应用账号。 -->
  6. <select id="selectAccount" resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationAccountDTO">
  7. select user_photo as userPhoto,
  8. account_id as accountId,
  9. account,
  10. regis_nickname as regisNickname,
  11. "password" as password,
  12. fans_counter as fansCounter,
  13. follow_counter as followCounter,
  14. message_counter as messageCounter,
  15. prevacy_message_counter as prevacyMessageCounter,
  16. url,
  17. certificate_content as certificateContent,
  18. sexcode,
  19. birthday,
  20. try_cast(age as integer) as age,
  21. zodiac,
  22. constallation,
  23. reg_city as regCity,
  24. graduateschool,
  25. occupation_name as occupationName,
  26. blood_type as bloodType,
  27. "name" as name,
  28. sign_name as signName,
  29. personal_desc as personalDesc,
  30. msisdn,
  31. fixed_phone as fixedPhone,
  32. email_account as emailAccount,
  33. postal_address as postalAddress,
  34. postal_code as postalCode,
  35. certificate_type as certificateType,
  36. certificate_code as certificateCode,
  37. install_time as installTime,
  38. account_reg_date as accountRegDate,
  39. last_login_time as lastLoginTime,
  40. latest_mod_time as latestModTime,
  41. delete_status as deleteStatus,
  42. delete_time as deleteTime
  43. from wa_mforensics_030100 a
  44. where a.collect_target_id = #{param.collectTargetId}
  45. and account = #{param.account}
  46. and contact_account_type = #{param.type}
  47. limit 1
  48. </select>
  49. <!-- 好友分组统计。 -->
  50. <select id="selectFriendGroupStats" resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationGroupStatDTO">
  51. select friend_group as name,
  52. count(1) as num,
  53. sum(case when delete_status = 1 then 1 else 0 end) as deleteNum
  54. from wa_mforensics_030200
  55. where collect_target_id = #{param.collectTargetId}
  56. and account = #{param.account}
  57. and contact_account_type = #{param.type}
  58. group by friend_group
  59. </select>
  60. <!-- 默认分组好友列表。 -->
  61. <select id="selectDefaultGroupFriends" resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationFriendDTO">
  62. select friend_account as friendAccount,
  63. max(friend_nickname) as friendNickname,
  64. max(user_photo) as userPhoto,
  65. max(delete_status) as deleteStatus
  66. from wa_mforensics_030200
  67. where collect_target_id = #{param.collectTargetId}
  68. and account = #{param.account}
  69. and contact_account_type = #{param.type}
  70. and (friend_group = '默认分组' or friend_group is null)
  71. group by friend_account
  72. order by friendNickname
  73. </select>
  74. <!-- 指定分组好友列表。 -->
  75. <select id="selectGroupFriends" resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationFriendDTO">
  76. select friend_account as friendAccount,
  77. max(friend_nickname) as friendNickname,
  78. max(user_photo) as userPhoto,
  79. max(delete_status) as deleteStatus
  80. from wa_mforensics_030200
  81. where collect_target_id = #{param.collectTargetId}
  82. and account = #{param.account}
  83. and contact_account_type = #{param.type}
  84. and friend_group = #{param.groupName}
  85. group by friend_account
  86. order by friendNickname
  87. </select>
  88. <!-- 好友详情。 -->
  89. <select id="selectFriendAccount" resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationFriendAccountDTO">
  90. select user_photo as userPhoto,
  91. friend_id as friendId,
  92. friend_account as friendAccount,
  93. friend_nickname as friendNickname,
  94. fans_counter as fansCounter,
  95. follow_counter as followCounter,
  96. friend_remark as friendRemark,
  97. message_counter as messageCounter,
  98. url,
  99. certificate_content as certificateContent,
  100. sexcode,
  101. birthday,
  102. try_cast(age as integer) as age,
  103. zodiac,
  104. constallation,
  105. reg_city as regCity,
  106. graduateschool,
  107. occupation_name as occupationName,
  108. blood_type as bloodType,
  109. "name" as name,
  110. sign_name as signName,
  111. personal_desc as personalDesc,
  112. msisdn,
  113. fixed_phone as fixedPhone,
  114. email_account as emailAccount,
  115. postal_address as postalAddress,
  116. postal_code as postalCode,
  117. certificate_type as certificateType,
  118. certificate_code as certificateCode,
  119. account_reg_date as accountRegDate,
  120. last_login_time as lastLoginTime,
  121. latest_mod_time as latestModTime,
  122. delete_status as deleteStatus,
  123. delete_time as deleteTime
  124. from wa_mforensics_030200
  125. where collect_target_id = #{param.collectTargetId}
  126. and account = #{param.account}
  127. and contact_account_type = #{param.type}
  128. and (friend_account = #{param.friendAccount}
  129. or (friend_account is null
  130. and #{param.friendAccount} = ''
  131. and (#{param.friendNickname} is null
  132. or #{param.friendNickname} = ''
  133. or friend_nickname = #{param.friendNickname})))
  134. limit 1
  135. </select>
  136. <!-- 博文分组统计。 -->
  137. <select id="selectBlogGroupStats" resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationGroupStatDTO">
  138. select count(1) as num,
  139. friend_group as name,
  140. sum(delete_status) as deleteNum,
  141. count(distinct friend_account) as personNum
  142. from (
  143. select a.friend_account, friend_group, a.delete_status
  144. from wa_mforensics_030300 a
  145. left join (
  146. select collect_target_id, account, friend_account, max(friend_group) as friend_group
  147. from wa_mforensics_030200
  148. where collect_target_id = #{param.collectTargetId}
  149. and account = #{param.account}
  150. and contact_account_type = #{param.type}
  151. group by collect_target_id, account, friend_account
  152. ) b
  153. on a.collect_target_id = b.collect_target_id
  154. and a.account = b.account
  155. and a.friend_account = b.friend_account
  156. where a.collect_target_id = #{param.collectTargetId}
  157. and a.account = #{param.account}
  158. and a.contact_account_type = #{param.type}
  159. ) t
  160. group by t.friend_group
  161. order by num desc
  162. </select>
  163. <!-- 博文默认分组好友统计。 -->
  164. <select id="selectBlogDefaultGroupFriends"
  165. resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationFriendStatDTO">
  166. select count(1) as num,
  167. friend_account as friendAccount,
  168. sum(delete_status) as deleteNum,
  169. max(friend_nickname) as friendNickname,
  170. max(user_photo) as userPhoto
  171. from (
  172. select a.friend_account, a.friend_nickname, friend_group, a.delete_status, b.user_photo
  173. from wa_mforensics_030300 a
  174. left join (
  175. select collect_target_id, account, friend_account,
  176. max(friend_group) as friend_group, max(user_photo) as user_photo
  177. from wa_mforensics_030200
  178. where collect_target_id = #{param.collectTargetId}
  179. and account = #{param.account}
  180. and contact_account_type = #{param.type}
  181. group by collect_target_id, account, friend_account
  182. ) b
  183. on a.collect_target_id = b.collect_target_id
  184. and a.account = b.account
  185. and a.friend_account = b.friend_account
  186. where a.collect_target_id = #{param.collectTargetId}
  187. and a.account = #{param.account}
  188. and a.contact_account_type = #{param.type}
  189. and (b.friend_group = '默认分组' or b.friend_group is null)
  190. ) t
  191. group by t.friend_account
  192. order by num desc
  193. </select>
  194. <!-- 博文指定分组好友统计。 -->
  195. <select id="selectBlogGroupFriends"
  196. resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationFriendStatDTO">
  197. select count(1) as num,
  198. friend_account as friendAccount,
  199. sum(delete_status) as deleteNum,
  200. max(friend_nickname) as friendNickname,
  201. max(user_photo) as userPhoto
  202. from (
  203. select a.friend_account, a.friend_nickname, friend_group, a.delete_status, b.user_photo
  204. from wa_mforensics_030300 a
  205. left join (
  206. select collect_target_id, account, friend_account,
  207. max(friend_group) as friend_group, max(user_photo) as user_photo
  208. from wa_mforensics_030200
  209. where collect_target_id = #{param.collectTargetId}
  210. and account = #{param.account}
  211. and contact_account_type = #{param.type}
  212. group by collect_target_id, account, friend_account
  213. ) b
  214. on a.collect_target_id = b.collect_target_id
  215. and a.account = b.account
  216. and a.friend_account = b.friend_account
  217. where a.collect_target_id = #{param.collectTargetId}
  218. and a.account = #{param.account}
  219. and a.contact_account_type = #{param.type}
  220. and friend_group = #{param.groupName}
  221. ) t
  222. group by t.friend_account
  223. order by num desc
  224. </select>
  225. <!-- 博文列表。 -->
  226. <select id="selectBlogs" resultType="com.zsjz.ai.module.eds.dto.EdsBlogDTO">
  227. select mail_send_time as mailSendTime,
  228. weibo_message as weiboMessage,
  229. weibo_reply_counter as weiboReplyCounter,
  230. weibo_retweet_counter as weiboRetweetCounter,
  231. weibo_like_counter as weiboLikeCounter,
  232. copy_from as copyFrom,
  233. city_code as cityCode,
  234. company_address as companyAddress,
  235. delete_status as deleteStatus,
  236. delete_time as deleteTime,
  237. friend_nickname as friendNickName
  238. from wa_mforensics_030300
  239. where collect_target_id = #{param.collectTargetId}
  240. and account = #{param.account}
  241. and contact_account_type = #{param.type}
  242. and friend_account = #{param.friendAccount}
  243. </select>
  244. <!-- 私信分组统计。 -->
  245. <select id="selectPrivateLetterGroupStats" resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationGroupStatDTO">
  246. select count(1) as num,
  247. friend_group as name,
  248. sum(delete_status) as deleteNum,
  249. count(distinct friend_account) as personNum
  250. from (
  251. select a.friend_account, friend_group, a.delete_status
  252. from wa_mforensics_030400 a
  253. left join (
  254. select collect_target_id, account, friend_account, max(friend_group) as friend_group
  255. from wa_mforensics_030200
  256. where collect_target_id = #{param.collectTargetId}
  257. and account = #{param.account}
  258. and contact_account_type = #{param.type}
  259. group by collect_target_id, account, friend_account
  260. ) b
  261. on a.collect_target_id = b.collect_target_id
  262. and a.account = b.account
  263. and a.friend_account = b.friend_account
  264. where a.collect_target_id = #{param.collectTargetId}
  265. and a.account = #{param.account}
  266. and a.contact_account_type = #{param.type}
  267. ) t
  268. group by t.friend_group
  269. order by num desc
  270. </select>
  271. <!-- 私信默认分组好友统计。 -->
  272. <select id="selectPrivateLetterDefaultGroupFriends"
  273. resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationFriendStatDTO">
  274. select count(1) as num,
  275. friend_account as friendAccount,
  276. sum(delete_status) as deleteNum,
  277. max(friend_nickname) as friendNickname,
  278. max(user_photo) as userPhoto
  279. from (
  280. select a.friend_account, a.friend_nickname, friend_group, a.delete_status, b.user_photo
  281. from wa_mforensics_030400 a
  282. left join (
  283. select collect_target_id, account, friend_account,
  284. max(friend_group) as friend_group, max(user_photo) as user_photo
  285. from wa_mforensics_030200
  286. where collect_target_id = #{param.collectTargetId}
  287. and account = #{param.account}
  288. and contact_account_type = #{param.type}
  289. group by collect_target_id, account, friend_account
  290. ) b
  291. on a.collect_target_id = b.collect_target_id
  292. and a.account = b.account
  293. and a.friend_account = b.friend_account
  294. where a.collect_target_id = #{param.collectTargetId}
  295. and a.account = #{param.account}
  296. and a.contact_account_type = #{param.type}
  297. and (b.friend_group = '默认分组' or b.friend_group is null)
  298. ) t
  299. group by t.friend_account
  300. order by num desc
  301. </select>
  302. <!-- 私信指定分组好友统计。 -->
  303. <select id="selectPrivateLetterGroupFriends"
  304. resultType="com.zsjz.ai.module.eds.dto.EdsSocialApplicationFriendStatDTO">
  305. select count(1) as num,
  306. friend_account as friendAccount,
  307. sum(delete_status) as deleteNum,
  308. max(friend_nickname) as friendNickname,
  309. max(user_photo) as userPhoto
  310. from (
  311. select a.friend_account, a.friend_nickname, friend_group, a.delete_status, b.user_photo
  312. from wa_mforensics_030400 a
  313. left join (
  314. select collect_target_id, account, friend_account,
  315. max(friend_group) as friend_group, max(user_photo) as user_photo
  316. from wa_mforensics_030200
  317. where collect_target_id = #{param.collectTargetId}
  318. and account = #{param.account}
  319. and contact_account_type = #{param.type}
  320. group by collect_target_id, account, friend_account
  321. ) b
  322. on a.collect_target_id = b.collect_target_id
  323. and a.account = b.account
  324. and a.friend_account = b.friend_account
  325. where a.collect_target_id = #{param.collectTargetId}
  326. and a.account = #{param.account}
  327. and a.contact_account_type = #{param.type}
  328. and friend_group = #{param.groupName}
  329. ) t
  330. group by t.friend_account
  331. order by num desc
  332. </select>
  333. <!-- 私信列表。 -->
  334. <select id="selectPrivateLetters" resultType="com.zsjz.ai.module.eds.dto.EdsPrivateLetterDTO">
  335. select mail_send_time as mailSendTime,
  336. content,
  337. local_action as localAction,
  338. delete_status as deleteStatus,
  339. delete_time as deleteTime,
  340. regis_nickname as regisNickname,
  341. friend_nickname as friendNickname
  342. from wa_mforensics_030400
  343. where collect_target_id = #{param.collectTargetId}
  344. and account = #{param.account}
  345. and contact_account_type = #{param.contactAccountType}
  346. and friend_account = #{param.friendAccount}
  347. <if test="param.startDateTime != null">
  348. and mail_send_time &gt;= #{param.startDateTime}
  349. </if>
  350. <if test="param.endDateTime != null">
  351. and mail_send_time &lt;= #{param.endDateTime}
  352. </if>
  353. <if test="param.keyword != null and param.keyword != ''">
  354. and strpos(content, #{param.keyword}) &gt; 0
  355. </if>
  356. <if test="param.mediaType != null">
  357. and media_type = #{param.mediaType.code}
  358. </if>
  359. </select>
  360. <!-- 搜索记录。 -->
  361. <select id="selectSearchRecords" resultType="com.zsjz.ai.module.eds.dto.EdsSocialSearchRecordDTO">
  362. select create_time as createTime,
  363. keyword,
  364. delete_status as deleteStatus,
  365. delete_time as deleteTime
  366. from wa_mforensics_030500
  367. where collect_target_id = #{param.collectTargetId}
  368. and account = #{param.account}
  369. and contact_account_type = #{param.type}
  370. order by create_time desc
  371. </select>
  372. </mapper>