yq před 3 roky
rodič
revize
f716dadc8c

+ 6 - 10
src/main/java/com/usky/dxtop/service/impl/MsgLogServiceImpl.java

@@ -1,7 +1,7 @@
 package com.usky.dxtop.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.usky.dxtop.mapper.MsgLogMapper;
@@ -51,15 +51,11 @@ public class MsgLogServiceImpl extends ServiceImpl<MsgLogMapper, MsgLog> impleme
     public void addOrUpdate(MsgLog msgLog) {
         msgLog.setId(System.currentTimeMillis());
         msgLog.setCreateTime(new Date());
-        LambdaQueryWrapper<MsgLog> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(MsgLog::getBusinessId,msgLog.getBusinessId());
-        MsgLog msg = this.getOne(queryWrapper);
-        if (null == msg){
-            this.save(msgLog);
-        }else {
-            msgLog.setId(msg.getId());
-            this.updateById(msgLog);
-        }
+        LambdaUpdateWrapper<MsgLog> updateWrapper = Wrappers.lambdaUpdate();
+        updateWrapper.set(MsgLog::getId,msgLog.getId());
+        updateWrapper.eq(MsgLog::getBusinessId,msgLog.getBusinessId());
+        this.saveOrUpdate(msgLog,updateWrapper);
+
     }
 
 }

+ 1 - 1
src/test/java/com/usky/dxtop/SmApiTest.java

@@ -23,7 +23,7 @@ public class SmApiTest {
     public void test1(){
         MsgLog msgLog = new MsgLog();
         msgLog.setId(System.currentTimeMillis());
-        msgLog.setBusinessId("111");
+        msgLog.setBusinessId("2222");
         msgLogService.addOrUpdate(msgLog);
     }
 }