张延森 4 gadus atpakaļ
vecāks
revīzija
569bb827c7

+ 8
- 0
src/main/java/com/shigongli/controller/TaMateTagGroupController.java Parādīt failu

@@ -9,6 +9,7 @@ import com.shigongli.common.StringUtils;
9 9
 import com.shigongli.constants.StatusConstant;
10 10
 import com.shigongli.entity.TaMateTag;
11 11
 import com.shigongli.service.ITaMateTagService;
12
+import com.shigongli.service.ITaMetaImageTagService;
12 13
 import io.swagger.annotations.Api;
13 14
 import io.swagger.annotations.ApiOperation;
14 15
 import io.swagger.annotations.ApiParam;
@@ -48,6 +49,9 @@ public class TaMateTagGroupController extends BaseController {
48 49
     @Autowired
49 50
     public ITaMateTagService iTaMateTagService;
50 51
 
52
+    @Autowired
53
+    public ITaMetaImageTagService iTaMetaImageTagService;
54
+
51 55
 
52 56
     /**
53 57
      * 分页查询列表
@@ -117,6 +121,10 @@ public class TaMateTagGroupController extends BaseController {
117 121
         }
118 122
 
119 123
         taMateTagGroup.setStatus(StatusConstant.DELETE);
124
+
125
+        iTaMateTagService.deleteByGroup(taMateTagGroup.getGroupId());
126
+        iTaMetaImageTagService.deleteByTagGroup(taMateTagGroup.getGroupId());
127
+
120 128
         return taMateTagGroupUpdate(id, taMateTagGroup);
121 129
     }
122 130
 

+ 2
- 0
src/main/java/com/shigongli/mapper/TaMetaImageTagMapper.java Parādīt failu

@@ -24,4 +24,6 @@ public interface TaMetaImageTagMapper extends BaseMapper<TaMetaImageTag> {
24 24
     IPage<TaMetaImageTag> pagedBy(IPage<TaMetaImageTag> pg, @Param("tagIds") String[] tagIds);
25 25
 
26 26
     int removeAllByTagAndImage(@Param("tagIds") String[] originTags, @Param("imageId") String originImage);
27
+
28
+    int deleteByTagGroup(@Param("groupId") String groupId);
27 29
 }

+ 2
- 0
src/main/java/com/shigongli/service/ITaMateTagService.java Parādīt failu

@@ -18,4 +18,6 @@ public interface ITaMateTagService extends IService<TaMateTag> {
18 18
     List<TaMateTag> getByGroup(String groupId);
19 19
 
20 20
     TaMateTag getByName(String name);
21
+
22
+    boolean deleteByGroup(String groupId);
21 23
 }

+ 2
- 0
src/main/java/com/shigongli/service/ITaMetaImageTagService.java Parādīt failu

@@ -21,4 +21,6 @@ public interface ITaMetaImageTagService extends IService<TaMetaImageTag> {
21 21
     IPage<TaMetaImageTag> pagedBy(IPage<TaMetaImageTag> pg, String tagIds);
22 22
 
23 23
     void removeAllBy(String[] originTags, String originImage);
24
+
25
+    boolean deleteByTagGroup(String groupId);
24 26
 }

+ 15
- 0
src/main/java/com/shigongli/service/impl/TaMateTagServiceImpl.java Parādīt failu

@@ -1,6 +1,8 @@
1 1
 package com.shigongli.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
+import com.shigongli.common.StringUtils;
4 6
 import com.shigongli.constants.StatusConstant;
5 7
 import com.shigongli.entity.TaMateTag;
6 8
 import com.shigongli.mapper.TaMateTagMapper;
@@ -39,4 +41,17 @@ public class TaMateTagServiceImpl extends ServiceImpl<TaMateTagMapper, TaMateTag
39 41
 
40 42
         return getOne(queryWrapper);
41 43
     }
44
+
45
+    @Override
46
+    public boolean deleteByGroup(String groupId) {
47
+        if (StringUtils.isEmpty(groupId)) {
48
+            return false;
49
+        }
50
+
51
+        UpdateWrapper<TaMateTag> updateWrapper = new UpdateWrapper<TaMateTag>()
52
+                .set("status", StatusConstant.DELETE)
53
+                .eq("group_id", groupId);
54
+
55
+        return update(updateWrapper);
56
+    }
42 57
 }

+ 6
- 0
src/main/java/com/shigongli/service/impl/TaMetaImageTagServiceImpl.java Parādīt failu

@@ -52,4 +52,10 @@ public class TaMetaImageTagServiceImpl extends ServiceImpl<TaMetaImageTagMapper,
52 52
 
53 53
         taMetaImageTagMapper.removeAllByTagAndImage(originTags, originImage);
54 54
     }
55
+
56
+    @Override
57
+    public boolean deleteByTagGroup(String groupId) {
58
+        int row = taMetaImageTagMapper.deleteByTagGroup(groupId);
59
+        return row >= 0;
60
+    }
55 61
 }

+ 8
- 0
src/main/resources/mapper/TaMetaImageTagMapper.xml Parādīt failu

@@ -18,6 +18,14 @@
18 18
         And image_id = #{imageId}
19 19
 
20 20
     </delete>
21
+    <delete id="deleteByTagGroup">
22
+        DELETE t
23
+        FROM
24
+            ta_meta_image_tag t
25
+            INNER JOIN ta_mate_tag s ON t.tag_id = s.tag_id
26
+        WHERE
27
+            s.group_id = #{groupId}
28
+    </delete>
21 29
     <select id="pagedBy" resultType="com.shigongli.entity.TaMetaImageTag">
22 30
         SELECT
23 31
             t.`name` AS tag_name,