RiskMapper.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.middle.dao.RiskMapper">
  4. <insert id="insertConfigItem">
  5. insert into yt_risk_config
  6. (
  7. config_id,
  8. field_name,
  9. field_desc,
  10. config_type,
  11. config_val,
  12. multy,
  13. channel_id
  14. )
  15. values
  16. (
  17. #{configId},
  18. #{fieldName},
  19. #{fieldDesc},
  20. #{configType},
  21. #{configVal},
  22. #{multy},
  23. #{channelId}
  24. )
  25. </insert>
  26. <insert id="insertTempConfig">
  27. insert into yt_risk_template_config
  28. (
  29. template_id,
  30. config_id,
  31. operator,
  32. operator_time,
  33. operator_name
  34. )
  35. values
  36. (
  37. #{templateId},
  38. #{configId},
  39. #{operator},
  40. #{operatorTime},
  41. #{operatorName}
  42. );
  43. </insert>
  44. <insert id="insertTemplate">
  45. insert into yt_risk_template
  46. (
  47. template_id,
  48. template_name,
  49. template_content,
  50. template_code,
  51. channel_id,
  52. effect_node,
  53. app_id,
  54. all_satisfy,
  55. create_time,
  56. create_user_id,
  57. enabled,
  58. can_modify
  59. )
  60. values
  61. (
  62. #{templateId},
  63. #{templateName},
  64. #{templateContent},
  65. #{templateCode},
  66. #{channelId},
  67. #{effectNode},
  68. #{appId},
  69. #{allSatisfy},
  70. #{createTime},
  71. #{createUserId},
  72. #{enabled},
  73. #{canModify}
  74. );
  75. </insert>
  76. <insert id="relativeApp">
  77. insert into yt_cofig_app (template_id, app_id, app_name, operator, operator_name, operator_time)
  78. values (#{templateId},#{appId},#{appName},#{userId},#{nickName},now());
  79. </insert>
  80. <select id="getTemplateByAppId" resultType="com.ytpm.risk.model.YtRiskTemplate">
  81. select
  82. template_id, template_name, template_content, template_code, channel_id, effect_node, app_id, all_satisfy, create_time, create_user_id, update_time, update_user_id, enabled, can_modify
  83. from yt_risk_template
  84. where app_id = #{appId}
  85. limit 1
  86. </select>
  87. <select id="countBanned" resultType="java.lang.Integer">
  88. select
  89. count(distinct user_id)
  90. from yt_platform_banned
  91. where app_id = #{appId}
  92. <if test="type != null and type ==1">
  93. and DATE(banned_time) = DATE(now())
  94. </if>
  95. <if test="type != null and type ==2">
  96. and DATE(banned_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  97. </if>
  98. <if test="type != null and type ==3">
  99. and DATE_FORMAT(banned_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  100. </if>
  101. </select>
  102. <select id="countBannedHour" resultType="com.ytpm.middle.view.AppUserHourVO">
  103. select
  104. DATE_FORMAT(banned_time,'%Y-%m-%d %H:00:00') as `time`,
  105. count(distinct user_id)`count`
  106. from yt_platform_banned
  107. where app_id = #{appId}
  108. <if test="type != null and type ==1">
  109. and DATE(banned_time) = DATE(now())
  110. </if>
  111. <if test="type != null and type ==2">
  112. and DATE(banned_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
  113. </if>
  114. <if test="type != null and type ==3">
  115. and DATE_FORMAT(banned_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
  116. </if>
  117. </select>
  118. </mapper>