From 749570394745ae95ee65605eadb42800f42fa20a Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期五, 08 八月 2025 12:09:26 +0800
Subject: [PATCH] 规范

---
 src/main/java/com/linghu/service/impl/TypeServiceImpl.java |   61 ++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/linghu/service/impl/TypeServiceImpl.java b/src/main/java/com/linghu/service/impl/TypeServiceImpl.java
index 15029b0..be12dd5 100644
--- a/src/main/java/com/linghu/service/impl/TypeServiceImpl.java
+++ b/src/main/java/com/linghu/service/impl/TypeServiceImpl.java
@@ -3,12 +3,20 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.linghu.mapper.KeywordMapper;
+import com.linghu.mapper.ReferenceMapper;
+import com.linghu.model.common.ResponseResult;
+import com.linghu.model.entity.Keyword;
 import com.linghu.model.entity.Type;
 import com.linghu.service.TypeService;
 import com.linghu.mapper.TypeMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author xy
@@ -20,6 +28,8 @@
         implements TypeService {
     @Resource
     private TypeMapper typeMapper;
+    @Autowired
+    private KeywordMapper keywordMapper;
     @Override
     public Type getTypeByName(String typeName) {
         // 查询
@@ -29,4 +39,55 @@
 
     }
 
+    @Override
+    public ResponseResult<Type> addType(Type type) {
+        boolean success = this.save(type);
+        if (success) {
+            return ResponseResult.success(type);
+        }
+        return ResponseResult.error("添加类型失败");
+    }
+
+    @Override
+    public ResponseResult<Void> batchDeleteTypes(List<Integer> typeIds) {
+        List<Type> types = typeIds.stream().map(id -> {
+            Type type = new Type();
+            type.setType_id(id);
+            return type;
+        }).collect(Collectors.toList());
+        boolean success = this.updateBatchById(types);
+        if (success) {
+            return ResponseResult.success();
+        }
+        return ResponseResult.error("批量删除类型失败");
+    }
+
+    @Override
+    public ResponseResult<List<Type>> pageList(Integer keywordId, Integer questionId, Integer isNow) {
+        List<Integer> typeIds=new ArrayList<>();
+        Keyword keyword=new Keyword();
+        //先查找当前关键词下,所有的回答 的 所有的平台名称
+        if (keywordId != null) {
+            keyword = keywordMapper.selectById(keywordId);
+        }
+
+
+        typeIds= keywordMapper.getTypeIds(keywordId, questionId, isNow,keyword);
+        LambdaQueryWrapper<Type> queryWrapper = new LambdaQueryWrapper<>();
+        if (!typeIds.isEmpty()) {
+            queryWrapper.in(Type::getType_id, typeIds);
+        }else {
+            if (keywordId != null) {
+                return ResponseResult.success(new ArrayList<>());
+
+            }else {
+                List<Type> list = this.list(queryWrapper);
+                return ResponseResult.success(list);
+            }
+
+        }
+        List<Type> list = this.list(queryWrapper);
+        return ResponseResult.success(list);
+    }
+
 }

--
Gitblit v1.7.1