RiskManageMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.ytpm.dao.RiskManageMapper">
  4. <insert id="addDeblockingRecord">
  5. insert into yt_platform_deblocking
  6. (
  7. deblocking_id,
  8. banned_id,
  9. user_id,
  10. app_id,
  11. channel_id,
  12. agent_id,
  13. deblocking_time,
  14. deblocking_reason,
  15. operator,
  16. operator_name
  17. )
  18. values
  19. (
  20. #{deblockingId},
  21. #{bannedId},
  22. #{userId},
  23. #{appId},
  24. #{channelId},
  25. #{agentId},
  26. #{deblockingTime},
  27. #{deblockingReason},
  28. #{operator},
  29. #{operatorName}
  30. )
  31. </insert>
  32. <insert id="relativeApps" parameterType="com.ytpm.risk.param.RiskRelativeAppParam">
  33. insert into yt_cofig_app
  34. (
  35. template_id,
  36. app_id,
  37. app_name,
  38. operator,
  39. operator_name,
  40. operator_time
  41. )
  42. values
  43. <foreach collection="appList" separator="," index="index" item="item">
  44. (
  45. #{templateId},
  46. #{item.appId},
  47. #{item.appName},
  48. #{operator},
  49. #{operatorName},
  50. now()
  51. )
  52. </foreach>
  53. </insert>
  54. <delete id="deleteRelatives">
  55. delete from yt_cofig_app where template_id = #{templateId}
  56. </delete>
  57. <select id="getDeblockingList" resultType="com.ytpm.risk.view.RiskDeblockingListView">
  58. SELECT
  59. pd.deblocking_id,
  60. pd.banned_id,
  61. pd.user_id,
  62. pd.agent_id,
  63. pd.channel_id,
  64. pd.deblocking_time,
  65. pd.deblocking_reason,
  66. pd.operator,
  67. pd.operator_name,
  68. a.app_id,
  69. a.app_name,
  70. a.ditch_id,
  71. a.ditch_name
  72. FROM
  73. yt_platform_deblocking pd
  74. JOIN yt_app a ON pd.app_id = a.app_id
  75. WHERE
  76. pd.agent_id = #{agentId}
  77. <if test="appId != null and appId != ''">
  78. and a.app_id = #{appId}
  79. </if>
  80. <if test="channelOrigin != null">
  81. and a.ditch_id = #{channelOrigin}
  82. </if>
  83. <if test="deblockingReason != null and deblockingReason != ''">
  84. and pd.deblocking_reason like concat('%',#{deblockingReason},'%')
  85. </if>
  86. <if test="deblockingTimeBegin != null">
  87. and DATE_FORMAT(pd.deblocking_time,'%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{deblockingTimeBegin}, '%Y-%m-%d')
  88. </if>
  89. <if test="deblockingTimeEnd != null">
  90. and DATE_FORMAT(pd.deblocking_time,'%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{deblockingTimeEnd}, '%Y-%m-%d')
  91. </if>
  92. ORDER BY pd.deblocking_time DESC
  93. </select>
  94. <select id="getBannedList" resultType="com.ytpm.risk.view.RiskBannedListView">
  95. SELECT
  96. pb.banned_id,
  97. pb.banned_time,
  98. pb.banned_reason,
  99. pb.banned_type,
  100. pb.banned_limit,
  101. pb.operator,
  102. pb.operator_name,
  103. pb.user_id,
  104. pb.agent_id,
  105. a.app_id,
  106. a.app_name,
  107. a.ditch_id,
  108. a.ditch_name
  109. FROM
  110. yt_platform_banned pb
  111. JOIN yt_app a ON pb.app_id = a.app_id
  112. WHERE
  113. pb.agent_id = #{agentId}
  114. <if test="appId != null and appId != ''">
  115. and a.app_id = #{appId}
  116. </if>
  117. <if test="userId != null and userId != ''">
  118. and pb.user_id = #{userId}
  119. </if>
  120. <if test="channelOrigin != null">
  121. and a.ditch_id = #{channelOrigin}
  122. </if>
  123. <if test="bannedReason != null and bannedReason != ''">
  124. and pb.banned_reason like concat('%',#{bannedReason},'%')
  125. </if>
  126. <if test="bannedTimeBegin != null">
  127. and DATE_FORMAT(pb.banned_time,'%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{bannedTimeBegin}, '%Y-%m-%d')
  128. </if>
  129. <if test="bannedTimeEnd != null">
  130. and DATE_FORMAT(pb.banned_time,'%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{bannedTimeEnd}, '%Y-%m-%d')
  131. </if>
  132. ORDER BY pb.banned_time DESC
  133. </select>
  134. <select id="getLastBanned" resultType="com.ytpm.agent.model.YtPlatformBanned">
  135. select
  136. banned_id, app_id, user_id, channel_id,agent_id, banned_time, banned_reason, banned_type, banned_limit, operator, operator_name
  137. from yt_platform_banned
  138. where user_id = #{userId}
  139. order by banned_time desc
  140. limit 1
  141. </select>
  142. <select id="queryBannedRecord" resultType="com.ytpm.agent.model.YtPlatformBanned">
  143. select
  144. banned_id, user_id, channel_id,agent_id, banned_time, banned_reason, banned_type, banned_limit, operator, operator_name
  145. from yt_platform_banned
  146. <where>
  147. <if test="startTime != null">
  148. AND banned_time >= #{startTime}
  149. </if>
  150. <if test="endTime != null">
  151. AND banned_time &lt;= #{endTime}
  152. </if>
  153. <choose>
  154. <when test="appIdList == null or appIdList.isEmpty()">
  155. <!-- 为空直接查询不到数据 -->
  156. AND 1 = 0
  157. </when>
  158. <otherwise>
  159. AND app_id IN
  160. <foreach collection="appIdList" item="item"
  161. open="(" close=")" separator=",">
  162. #{item}
  163. </foreach>
  164. </otherwise>
  165. </choose>
  166. </where>
  167. </select>
  168. <select id="queryBannedRecordGroupByUserId" resultType="com.ytpm.agent.model.YtPlatformBanned">
  169. select
  170. user_id
  171. from yt_platform_banned
  172. <where>
  173. <if test="startTime != null">
  174. AND banned_time >= #{startTime}
  175. </if>
  176. <if test="endTime != null">
  177. AND banned_time &lt;= #{endTime}
  178. </if>
  179. <choose>
  180. <when test="appIdList == null or appIdList.isEmpty()">
  181. <!-- 为空直接查询不到数据 -->
  182. AND 1 = 0
  183. </when>
  184. <otherwise>
  185. AND app_id IN
  186. <foreach collection="appIdList" item="item"
  187. open="(" close=")" separator=",">
  188. #{item}
  189. </foreach>
  190. </otherwise>
  191. </choose>
  192. </where>
  193. group by user_id
  194. </select>
  195. </mapper>