Bladeren bron

fix: 修复SQL错误

hidewnd 3 dagen geleden
bovenliggende
commit
efe50c866b
1 gewijzigde bestanden met toevoegingen van 40 en 36 verwijderingen
  1. 40 36
      yt-agent/agent-service/src/main/resources/mapper/RiskMapper.xml

+ 40 - 36
yt-agent/agent-service/src/main/resources/mapper/RiskMapper.xml

@@ -165,24 +165,26 @@
             LEFT JOIN yt_ditch_share yds ON yds.app_id = a.app_id AND pb.agent_id = yds.user_id
             WHERE yds.is_deleted = 0 AND yds.shared_user_id = #{agentId}
         ) t
-        <if test="appId != null and appId != ''">
-            and t.app_id = #{appId}
-        </if>
-        <if test="userId != null and userId != ''">
-            and t.user_id = #{userId}
-        </if>
-        <if test="channelOrigin != null and channelOrigin != ''">
-            and t.ditch_id = #{channelOrigin}
-        </if>
-        <if test="bannedReason != null and bannedReason != ''">
-            and t.banned_reason like concat('%',#{bannedReason},'%')
-        </if>
-        <if test="bannedTimeBegin != null">
-            and DATE_FORMAT(t.banned_time,'%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{bannedTimeBegin}, '%Y-%m-%d')
-        </if>
-        <if test="bannedTimeEnd != null">
-            and DATE_FORMAT(t.banned_time,'%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{bannedTimeEnd}, '%Y-%m-%d')
-        </if>
+        <where>
+            <if test="appId != null and appId != ''">
+                and t.app_id = #{appId}
+            </if>
+            <if test="userId != null and userId != ''">
+                and t.user_id = #{userId}
+            </if>
+            <if test="channelOrigin != null and channelOrigin != ''">
+                and t.ditch_id = #{channelOrigin}
+            </if>
+            <if test="bannedReason != null and bannedReason != ''">
+                and t.banned_reason like concat('%',#{bannedReason},'%')
+            </if>
+            <if test="bannedTimeBegin != null">
+                and DATE_FORMAT(t.banned_time,'%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{bannedTimeBegin}, '%Y-%m-%d')
+            </if>
+            <if test="bannedTimeEnd != null">
+                and DATE_FORMAT(t.banned_time,'%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{bannedTimeEnd}, '%Y-%m-%d')
+            </if>
+        </where>
         ORDER BY t.banned_time DESC
     </select>
     <select id="getDeblockingList" resultType="com.ytpm.risk.view.RiskDeblockingListView">
@@ -225,24 +227,26 @@
             LEFT JOIN yt_ditch_share yds ON yds.app_id = a.app_id AND pd.agent_id = yds.user_id
             WHERE yds.is_deleted = 0 AND yds.shared_user_id = #{agentId}
         ) t
-        <if test="appId != null and appId != ''">
-            and t.app_id = #{appId}
-        </if>
-        <if test="userId != null and userId != ''">
-            and t.user_id = #{userId}
-        </if>
-        <if test="channelOrigin != null and channelOrigin != ''">
-            and t.ditch_id = #{channelOrigin}
-        </if>
-        <if test="deblockingReason != null and deblockingReason != ''">
-            and t.deblocking_reason like concat('%',#{deblockingReason},'%')
-        </if>
-        <if test="deblockingTimeBegin != null">
-            and DATE_FORMAT(t.deblocking_time,'%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{deblockingTimeBegin}, '%Y-%m-%d')
-        </if>
-        <if test="deblockingTimeEnd != null">
-            and DATE_FORMAT(t.deblocking_time,'%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{deblockingTimeEnd}, '%Y-%m-%d')
-        </if>
+        <where>
+            <if test="appId != null and appId != ''">
+                and t.app_id = #{appId}
+            </if>
+            <if test="userId != null and userId != ''">
+                and t.user_id = #{userId}
+            </if>
+            <if test="channelOrigin != null and channelOrigin != ''">
+                and t.ditch_id = #{channelOrigin}
+            </if>
+            <if test="deblockingReason != null and deblockingReason != ''">
+                and t.deblocking_reason like concat('%',#{deblockingReason},'%')
+            </if>
+            <if test="deblockingTimeBegin != null">
+                and DATE_FORMAT(t.deblocking_time,'%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{deblockingTimeBegin}, '%Y-%m-%d')
+            </if>
+            <if test="deblockingTimeEnd != null">
+                and DATE_FORMAT(t.deblocking_time,'%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{deblockingTimeEnd}, '%Y-%m-%d')
+            </if>
+        </where>
         ORDER BY t.deblocking_time DESC
     </select>
     <select id="getLastBanned" resultType="com.ytpm.agent.model.YtPlatformBanned">