浏览代码

fix mapper xml sql

xiewj 2 年之前
父节点
当前提交
138a0a0925

+ 6 - 3
src/main/java/com/fdkankan/openApi/mq/listener/CallApiListener.java

@@ -1,5 +1,6 @@
 package com.fdkankan.openApi.mq.listener;
 
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.openApi.mq.dto.CallApiDTO;
 import com.fdkankan.openApi.service.system.IUserAuthService;
@@ -52,11 +53,13 @@ public class CallApiListener {
         try {
             log.info("callApi开始,id:{},deliveryTag:{},消息体:{}", messageId, deliveryTag, msg);
             CallApiDTO param = JSONObject.parseObject(msg, CallApiDTO.class);
-
-            int i = userAuthService.updateCallCounts(param.getAppKey());
-            log.info("修改数据量为{}", i);
+            if (StrUtil.isNotEmpty(param.getAppKey())){
+                int i = userAuthService.updateCallCounts(param.getAppKey());
+                log.info("修改数据量为{}", i);
+            }
             channel.basicAck(deliveryTag, false);
 
+
         } catch (DeadlockLoserDataAccessException e) {
             log.info("修改死锁重新入队");
             channel.basicReject(deliveryTag, true);

+ 38 - 0
src/main/resources/mapper/www/system/UserMapper.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.openApi.mapper.system.IUserAuthMapper">
+
+    <update id="updateCallCounts">
+        update t_users_auth_info
+        set call_counts = call_counts -1
+        where call_counts > 0
+        <if test="appKey != null and appKey != ''">
+            and appKey = #{appKey}
+        </if>
+    </update>
+    <update id="updateCallCountsByParam">
+        update t_users_auth_info
+        set call_counts = #{count}
+        <where>
+            <if test="appKey != null and appKey != ''">
+                  appKey = #{appKey}
+            </if>
+        </where>
+    </update>
+    <update id="updateCallCountsByParamAndType">
+        update t_users_auth_info
+        <choose>
+            <when test="type != null and type == 1">
+                set call_counts = call_counts+1
+            </when>
+            <when test="type != null and type == 2">
+                set call_counts = call_counts-1
+            </when>
+        </choose>
+        <where>
+            <if test="appKey != null and appKey != ''">
+                appKey = #{appKey}
+            </if>
+        </where>
+    </update>
+</mapper>