igl 1 ano atrás
pai
commit
54af53cb8a

+ 4 - 11
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/DynamicContentServiceImpl.java

@@ -1,7 +1,6 @@
 package com.chelvc.cloud.vehicle.server.service.impl;
 
 import cn.hutool.extra.spring.SpringUtil;
-import com.baomidou.lock.annotation.Lock4j;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -310,12 +309,10 @@ public class DynamicContentServiceImpl implements DynamicContentService, com.che
   @Override
   @Transactional(rollbackFor = Exception.class)
   public void deleteByIds(Long id, Long userId) {
-    DynamicContent DynamicContent = baseMapper.selectById(id);
-    if (DynamicContent == null || userId == null ||
-        !DynamicContent.getUserId().equals(userId)) {
-      throw new ResourceUnavailableException("动态删除失败");
-    }
-    boolean b = baseMapper.deleteById(id) > 0;
+    LambdaQueryWrapper<DynamicContent> wrapper = Wrappers.lambdaQuery();
+    wrapper.eq(DynamicContent::getId, id);
+    wrapper.eq(DynamicContent::getUserId, userId);
+    boolean b = baseMapper.delete(wrapper) > 0;
     if (!b) {
       throw new ResourceUnavailableException("动态删除失败");
     }
@@ -326,7 +323,6 @@ public class DynamicContentServiceImpl implements DynamicContentService, com.che
   }
 
   @Override
-  @Lock4j(keys = {"#dynamicId"})
   public void addComment(Long dynamicId) {
     int i = baseMapper.addComment(dynamicId);
     if (i != 1) {
@@ -335,7 +331,6 @@ public class DynamicContentServiceImpl implements DynamicContentService, com.che
   }
 
   @Override
-  @Lock4j(keys = {"#dynamicId"})
   public void reduceComment(Long dynamicId, int num) {
     int i = baseMapper.reduceComment(dynamicId, num);
     if (i != 1) {
@@ -344,7 +339,6 @@ public class DynamicContentServiceImpl implements DynamicContentService, com.che
   }
 
   @Override
-  @Lock4j(keys = {"#contentId"})
   public void addNum(Integer dynamicStatus, Long contentId) {
     if (Objects.equals(DynamicStatusType.GOOD.getValue(), dynamicStatus)) {
       int i = baseMapper.addGoodNum(contentId);
@@ -360,7 +354,6 @@ public class DynamicContentServiceImpl implements DynamicContentService, com.che
   }
 
   @Override
-  @Lock4j(keys = {"#contentId"})
   public void reduceNum(Integer dynamicStatus, Long contentId) {
     if (Objects.equals(DynamicStatusType.GOOD.getValue(), dynamicStatus)) {
       int i = baseMapper.reduceGoodNum(contentId);

+ 2 - 4
vehicle-server/src/main/resources/mapper/UserInviteMapper.xml

@@ -17,8 +17,7 @@
                 AND r.type = 0
                 AND i.type = r.source_type
         WHERE
-            1 = 1
-            and i.user_id = #{userId}
+            i.user_id = #{userId}
             <if test="type != null">
                 and i.type = #{type}
             </if>
@@ -40,8 +39,7 @@
         AND r.type = 0
         AND i.type = r.source_type
         WHERE
-        1 = 1
-        and i.user_id = #{userId}
+        i.user_id = #{userId}
         <if test="type != null">
             and i.type = #{type}
         </if>