Skip to content

Commit aa8c5fa

Browse files
committed
refactor: remove mybatis-plus plugin
1 parent 579dc4a commit aa8c5fa

23 files changed

+559
-306
lines changed

pom.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<spring-boot.version>3.4.8</spring-boot.version>
4242
<springdoc-openapi.version>2.8.8</springdoc-openapi.version>
4343
<spring-javaformat-maven-plugin.version>0.0.39</spring-javaformat-maven-plugin.version>
44+
<mybatis.version>3.0.4</mybatis.version>
4445

4546
<!-- CheckStyle Maven Plugin -->
4647
<maven-checkstyle-plugin.version>3.5.0</maven-checkstyle-plugin.version>
@@ -99,9 +100,15 @@
99100
<version>${druid.version}</version>
100101
</dependency>
101102
<dependency>
102-
<groupId>com.baomidou</groupId>
103-
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
104-
<version>3.5.12</version>
103+
<groupId>org.mybatis.spring.boot</groupId>
104+
<artifactId>mybatis-spring-boot-starter</artifactId>
105+
<version>${mybatis.version}</version>
106+
</dependency>
107+
<dependency>
108+
<groupId>org.mybatis.spring.boot</groupId>
109+
<artifactId>mybatis-spring-boot-starter-test</artifactId>
110+
<version>${mybatis.version}</version>
111+
<scope>test</scope>
105112
</dependency>
106113
<dependency>
107114
<groupId>org.postgresql</groupId>

spring-ai-alibaba-data-agent-chat/pom.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@
2424
<artifactId>spring-boot-starter</artifactId>
2525
</dependency>
2626
<dependency>
27-
<groupId>com.baomidou</groupId>
28-
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
27+
<groupId>org.mybatis.spring.boot</groupId>
28+
<artifactId>mybatis-spring-boot-starter-test</artifactId>
29+
<scope>test</scope>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.mybatis.spring.boot</groupId>
33+
<artifactId>mybatis-spring-boot-starter</artifactId>
2934
</dependency>
3035
<!-- 引入 Spring MVC -->
3136
<dependency>
@@ -145,18 +150,22 @@
145150
<dependency>
146151
<groupId>org.springframework.boot</groupId>
147152
<artifactId>spring-boot-testcontainers</artifactId>
153+
<scope>test</scope>
148154
</dependency>
149155
<dependency>
150156
<groupId>org.testcontainers</groupId>
151157
<artifactId>testcontainers</artifactId>
158+
<scope>test</scope>
152159
</dependency>
153160
<dependency>
154161
<groupId>org.testcontainers</groupId>
155162
<artifactId>junit-jupiter</artifactId>
163+
<scope>test</scope>
156164
</dependency>
157165
<dependency>
158166
<groupId>org.testcontainers</groupId>
159167
<artifactId>mysql</artifactId>
168+
<scope>test</scope>
160169
</dependency>
161170

162171
<dependency>
@@ -183,7 +192,6 @@
183192
<groupId>com.alibaba.cloud.ai</groupId>
184193
<artifactId>spring-ai-alibaba-data-agent-common</artifactId>
185194
<version>${revision}</version>
186-
<scope>compile</scope>
187195
</dependency>
188196
<dependency>
189197
<groupId>com.alibaba.cloud.ai</groupId>

spring-ai-alibaba-data-agent-chat/src/main/java/com/alibaba/cloud/ai/entity/AgentDatasource.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2024-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +16,6 @@
1616

1717
package com.alibaba.cloud.ai.entity;
1818

19-
import com.baomidou.mybatisplus.annotation.*;
2019
import com.fasterxml.jackson.annotation.JsonFormat;
2120
import org.springframework.format.annotation.DateTimeFormat;
2221

@@ -25,41 +24,28 @@
2524
import lombok.NoArgsConstructor;
2625
import lombok.AllArgsConstructor;
2726

28-
/**
29-
* Agent Data Source Association Entity Class
30-
*
31-
* @author Alibaba Cloud AI
32-
*/
33-
@TableName("agent_datasource")
3427
@Data
3528
@NoArgsConstructor
3629
@AllArgsConstructor
3730
public class AgentDatasource {
3831

39-
@TableId(value = "id", type = IdType.AUTO)
4032
private Integer id;
4133

42-
@TableField("agent_id")
4334
private Integer agentId;
4435

45-
@TableField("datasource_id")
4636
private Integer datasourceId;
4737

48-
@TableField("is_active")
4938
private Integer isActive;
5039

51-
@TableField(value = "create_time", fill = FieldFill.INSERT)
5240
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
5341
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
5442
private LocalDateTime createTime;
5543

56-
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
5744
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
5845
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
5946
private LocalDateTime updateTime;
6047

6148
// Associated data source object (for joint query)
62-
@TableField(exist = false)
6349
private Datasource datasource;
6450

6551
public AgentDatasource(Integer agentId, Integer datasourceId) {

spring-ai-alibaba-data-agent-chat/src/main/java/com/alibaba/cloud/ai/entity/Datasource.java

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2024-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,88 +16,55 @@
1616

1717
package com.alibaba.cloud.ai.entity;
1818

19-
import com.baomidou.mybatisplus.annotation.*;
2019
import com.fasterxml.jackson.annotation.JsonFormat;
20+
import lombok.Builder;
2121
import org.springframework.format.annotation.DateTimeFormat;
2222

2323
import java.time.LocalDateTime;
2424
import lombok.Data;
2525
import lombok.NoArgsConstructor;
2626
import lombok.AllArgsConstructor;
2727

28-
/**
29-
* Data Source Entity Class
30-
*
31-
* @author Alibaba Cloud AI
32-
*/
33-
@TableName("datasource")
3428
@Data
3529
@NoArgsConstructor
3630
@AllArgsConstructor
31+
@Builder
3732
public class Datasource {
3833

39-
@TableId(value = "id", type = IdType.AUTO)
4034
private Integer id;
4135

42-
@TableField("name")
4336
private String name;
4437

45-
@TableField("type")
4638
private String type;
4739

48-
@TableField("host")
4940
private String host;
5041

51-
@TableField("port")
5242
private Integer port;
5343

54-
@TableField("database_name")
5544
private String databaseName;
5645

57-
@TableField("username")
5846
private String username;
5947

60-
@TableField("password")
6148
private String password;
6249

63-
@TableField("connection_url")
6450
private String connectionUrl;
6551

66-
@TableField("status")
6752
private String status;
6853

69-
@TableField("test_status")
7054
private String testStatus;
7155

72-
@TableField("description")
7356
private String description;
7457

75-
@TableField("creator_id")
7658
private Long creatorId;
7759

78-
@TableField(value = "create_time", fill = FieldFill.INSERT)
7960
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
8061
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
8162
private LocalDateTime createTime;
8263

83-
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
8464
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
8565
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
8666
private LocalDateTime updateTime;
8767

88-
public Datasource(String name, String type, String host, Integer port, String databaseName, String username,
89-
String password) {
90-
this.name = name;
91-
this.type = type;
92-
this.host = host;
93-
this.port = port;
94-
this.databaseName = databaseName;
95-
this.username = username;
96-
this.password = password;
97-
this.status = "active";
98-
this.testStatus = "unknown";
99-
}
100-
10168
/**
10269
* Generate connection URL
10370
*/

spring-ai-alibaba-data-agent-chat/src/main/java/com/alibaba/cloud/ai/entity/UserPromptConfig.java

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,95 +16,76 @@
1616

1717
package com.alibaba.cloud.ai.entity;
1818

19-
import com.baomidou.mybatisplus.annotation.*;
19+
import lombok.AllArgsConstructor;
20+
import lombok.Builder;
2021
import lombok.Data;
2122
import lombok.NoArgsConstructor;
2223
import java.time.LocalDateTime;
2324

24-
/**
25-
* User-defined prompt configuration entity class
26-
*
27-
* @author Makoto
28-
*/
29-
@TableName("user_prompt_config")
3025
@Data
3126
@NoArgsConstructor
27+
@AllArgsConstructor
28+
@Builder
3229
public class UserPromptConfig {
3330

3431
/**
3532
* Configuration ID
3633
*/
37-
@TableId(value = "id", type = IdType.ASSIGN_UUID)
3834
private String id;
3935

4036
/**
4137
* Configuration name
4238
*/
43-
@TableField("name")
4439
private String name;
4540

4641
/**
4742
* Prompt type (e.g., report-generator, planner, etc.)
4843
*/
49-
@TableField("prompt_type")
5044
private String promptType;
5145

5246
/**
5347
* User-defined system prompt content
5448
*/
55-
@TableField("system_prompt")
5649
private String systemPrompt;
5750

5851
/**
5952
* Whether to enable this configuration
6053
*/
61-
@TableField("enabled")
54+
@Builder.Default
6255
private Boolean enabled = true;
6356

6457
/**
6558
* Configuration description
6659
*/
67-
@TableField("description")
6860
private String description;
6961

7062
/**
7163
* Configuration priority (higher number = higher priority)
7264
*/
73-
@TableField("priority")
65+
@Builder.Default
7466
private Integer priority = 0;
7567

7668
/**
7769
* Configuration order for display
7870
*/
79-
@TableField("display_order")
71+
@Builder.Default
8072
private Integer displayOrder = 0;
8173

8274
/**
8375
* Creation time
8476
*/
85-
@TableField(value = "create_time", fill = FieldFill.INSERT)
8677
private LocalDateTime createTime;
8778

8879
/**
8980
* Update time
9081
*/
91-
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
9282
private LocalDateTime updateTime;
9383

9484
/**
9585
* Creator
9686
*/
97-
@TableField("creator")
9887
private String creator;
9988

100-
// Constructors
101-
102-
public UserPromptConfig(String promptType, String systemPrompt) {
103-
this();
104-
this.promptType = promptType;
105-
this.systemPrompt = systemPrompt;
106-
}
107-
10889
public String getOptimizationPrompt() {
10990
return this.systemPrompt;
11091
}

spring-ai-alibaba-data-agent-chat/src/main/java/com/alibaba/cloud/ai/mapper/AgentDatasourceMapper.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,16 @@
1717
package com.alibaba.cloud.ai.mapper;
1818

1919
import com.alibaba.cloud.ai.entity.AgentDatasource;
20-
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20+
import org.apache.ibatis.annotations.Delete;
2121
import org.apache.ibatis.annotations.Mapper;
2222
import org.apache.ibatis.annotations.Param;
2323
import org.apache.ibatis.annotations.Select;
2424
import org.apache.ibatis.annotations.Update;
2525

2626
import java.util.List;
2727

28-
/**
29-
* Agent Data Source Association Mapper Interface
30-
*
31-
* @author Alibaba Cloud AI
32-
*/
3328
@Mapper
34-
public interface AgentDatasourceMapper extends BaseMapper<AgentDatasource> {
29+
public interface AgentDatasourceMapper {
3530

3631
/**
3732
* Query associated data sources by agent ID (including data source details)
@@ -69,4 +64,21 @@ AgentDatasource selectByAgentIdAndDatasourceId(@Param("agentId") Integer agentId
6964
int countActiveByAgentIdExcluding(@Param("agentId") Integer agentId,
7065
@Param("excludeDatasourceId") Integer excludeDatasourceId);
7166

67+
@Delete("DELETE FROM agent_datasource WHERE datasource_id = #{datasourceId}")
68+
int deleteAllByDatasourceId(@Param("datasourceId") Integer datasourceId);
69+
70+
@Select("INSERT INTO agent_datasource (agent_id, datasource_id, is_active) VALUES (#{agentId}, #{datasourceId}, 1)")
71+
int createNewRelationEnabled(@Param("agentId") Integer agentId, @Param("datasourceId") Integer datasourceId);
72+
73+
@Update("UPDATE agent_datasource SET is_active = #{isActive} WHERE agent_id = #{agentId} AND datasource_id = #{datasourceId}")
74+
int updateRelation(@Param("agentId") Integer agentId, @Param("datasourceId") Integer datasourceId,
75+
@Param("isActive") Integer isActive);
76+
77+
default int enableRelation(Integer agentId, Integer datasourceId) {
78+
return updateRelation(agentId, datasourceId, 1);
79+
}
80+
81+
@Delete("DELETE FROM agent_datasource WHERE agent_id = #{agentId} AND datasource_id = #{datasourceId}")
82+
int removeRelation(@Param("agentId") Integer agentId, @Param("datasourceId") Integer datasourceId);
83+
7284
}

0 commit comments

Comments
 (0)