18586361686
2025-05-14 6034602612eba7caf4fffeb7265add0e30da85b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package tech.aiflowy.ai.service.impl;
 
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import tech.aiflowy.ai.entity.AiPlugin;
import tech.aiflowy.ai.mapper.AiPluginMapper;
import tech.aiflowy.ai.service.AiPluginService;
import org.springframework.stereotype.Service;
import tech.aiflowy.common.domain.Result;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
/**
 *  服务层实现。
 *
 * @author WangGangqiang
 * @since 2025-04-25
 */
@Service
public class AiPluginServiceImpl extends ServiceImpl<AiPluginMapper, AiPlugin>  implements AiPluginService {
 
    @Resource
    AiPluginMapper aiPluginMapper;
 
    @Override
    public Result savePlugin(AiPlugin aiPlugin) {
        System.out.println("aaa");
        aiPlugin.setCreated(new Date());
        int insert = aiPluginMapper.insert(aiPlugin);
        if (insert <= 0){
            return Result.fail(1, "保存失败");
        }
        return Result.success();
    }
 
    @Override
    public Result removePlugin(String id) {
        int remove =  aiPluginMapper.deleteById(id);
        if (remove <= 0){
            return Result.fail(1, "删除失败");
 
        }
        return Result.success();
 
    }
 
    @Override
    public Result updatePlugin(AiPlugin aiPlugin) {
        QueryWrapper queryWrapper = QueryWrapper.create().select("id")
                .from("tb_ai_plugin")
                .where("id = ?", aiPlugin.getId());
        int update = aiPluginMapper.updateByQuery(aiPlugin, queryWrapper);
        if (update <= 0){
            return Result.fail(1, "修改失败");
 
        }
        return Result.success();
    }
 
    @Override
    public Result getList(String botId) {
        QueryWrapper queryWrapper = QueryWrapper.create().select("*")
                .from("tb_ai_plugin");
        List<AiPlugin> aiPlugins = aiPluginMapper.selectListByQueryAs(queryWrapper, AiPlugin.class);
        return Result.success(aiPlugins);
    }
}