Skip to content

Commit 140e07c

Browse files
committed
[app-builder] 修改检视意见,重构了模型列表接口的代码,提高了可读性和维护性。
1 parent 9bc768b commit 140e07c

18 files changed

Lines changed: 720 additions & 206 deletions

File tree

app-builder/plugins/aipp-custom-model-center/pom.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
<groupId>org.fitframework.integration</groupId>
4545
<artifactId>fit-druid</artifactId>
4646
</dependency>
47+
<dependency>
48+
<groupId>modelengine.fit.jade.service</groupId>
49+
<artifactId>tool-service</artifactId>
50+
</dependency>
51+
<dependency>
52+
<groupId>com.fasterxml.jackson.core</groupId>
53+
<artifactId>jackson-annotations</artifactId>
54+
</dependency>
4755

4856
<!-- Test -->
4957
<dependency>
@@ -65,10 +73,6 @@
6573
<artifactId>assertj-core</artifactId>
6674
<scope>test</scope>
6775
</dependency>
68-
<dependency>
69-
<groupId>modelengine.fit.jade.service</groupId>
70-
<artifactId>tool-service</artifactId>
71-
</dependency>
7276
</dependencies>
7377

7478
<build>

app-builder/plugins/aipp-custom-model-center/src/main/java/modelengine/fit/jade/aipp/model/mapper/ModelMapper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,29 @@ public interface ModelMapper {
2424
* 根据模型标识查询模型信息。
2525
*
2626
* @param modelId 表示模型标识。
27-
* @return 模型信息 {@link ModelPo}。
27+
* @return 模型信息的 {@link ModelPo}。
2828
*/
29-
ModelPo get(String modelId);
29+
ModelPo getModel(String modelId);
3030

3131
/**
3232
* 根据模型标识列表批量查询模型信息。
3333
*
3434
* @param modelIds 表示模型标识列表。
35-
* @return 模型信息列表 {@link List}{@code <}{@link ModelPo}{@code >}.
35+
* @return 模型信息列表的 {@link List}{@code <}{@link ModelPo}{@code >}.
3636
*/
3737
List<ModelPo> listModels(List<String> modelIds);
3838

3939
/**
4040
* 插入模型信息。
4141
*
42-
* @param model 表示待插入的模型信息 {@link ModelPo}。
42+
* @param model 表示待插入的模型信息的 {@link ModelPo}。
4343
*/
4444
void insertModel(ModelPo model);
4545

4646
/**
47-
* 根据模型ID删除模型信息
47+
* 根据模型标识删除模型信息
4848
*
49-
* @param modelId 表示删除模型标识 {@link String}。
49+
* @param modelId 表示删除模型标识的 {@link String}。
5050
*/
5151
void deleteByModelId(String modelId);
5252
}

app-builder/plugins/aipp-custom-model-center/src/main/java/modelengine/fit/jade/aipp/model/mapper/UserModelMapper.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,55 +25,55 @@ public interface UserModelMapper {
2525
* 根据用户标识获取用户模型关系列表。
2626
*
2727
* @param userId 表示用户标识。
28-
* @return 用户模型关系列表 {@link List}{@code <}{@link UserModelPo}{@code >}.
28+
* @return 用户模型关系列表的 {@link List}{@code <}{@link UserModelPo}{@code >}.
2929
*/
3030
List<UserModelPo> listUserModels(String userId);
3131

3232
/**
3333
* 根据用户标识获取默认用户模型关系。
3434
*
3535
* @param userId 表示用户标识。
36-
* @return 默认的用户模型关系
36+
* @return 默认的用户模型关系的 {@link UserModelPo}
3737
*/
3838
UserModelPo getDefault(String userId);
3939

4040
/**
4141
* 判断指定用户是否已绑定默认模型。
4242
*
43-
* @param userId 表示用户标识 {@link String}。
43+
* @param userId 表示用户标识的 {@link String}。
4444
* @return 若已绑定默认模型则返回 {@code true},否则返回 {@code false}。
4545
*/
46-
boolean userHasDefaultModel(String userId);
46+
boolean hasDefaultModel(String userId);
4747

4848
/**
4949
* 插入用户模型绑定关系。
5050
*
51-
* @param userModel 表示待插入的用户模型关系对象 {@link UserModelPo}。
51+
* @param userModel 表示待插入的用户模型关系对象的 {@link UserModelPo}。
5252
*/
53-
void addUserModel(UserModelPo userModel);
53+
void insertUserModel(UserModelPo userModel);
5454

5555
/**
5656
* 根据模型标识删除对应的用户模型绑定关系。
5757
*
58-
* @param modelId 表示模型标识 {@link String}。
58+
* @param modelId 表示模型标识的 {@link String}。
5959
*/
6060
void deleteByModelId(String modelId);
6161

6262
/**
6363
* 查找指定用户最新创建的模型绑定记录(按创建时间降序,取第一条)。
6464
*
65-
* @param userId 表示用户标识 {@link String}。
66-
* @return 最新的用户模型关系 {@link UserModelPo}。
65+
* @param userId 表示用户标识的 {@link String}。
66+
* @return 最新的用户模型关系的 {@link UserModelPo}。
6767
*/
6868
UserModelPo findLatestUserModel(String userId);
6969

7070
/**
7171
* 更新指定用户的所有模型绑定记录的默认状态。
72-
* <p>若记录中的模型标识与传入的 {@link String modelId} 一致,则设置为默认(1),否则设为非默认(0)。</p>
72+
* <p>若记录中的模型标识与传入的 {@code modelId} 一致,则设置为默认(1),否则设为非默认(0)。</p>
7373
*
74-
* @param userId 表示用户标识 {@link String}。
75-
* @param modelId 表示需设为默认的模型标识 {@link String}。
76-
* @return 成功更新的记录条数 {@code int}。
74+
* @param userId 表示用户标识的 {@link String}。
75+
* @param modelId 表示需设为默认的模型标识的 {@link String}。
76+
* @return 成功更新的记录条数的 {@code int}。
7777
*/
7878
int switchDefaultForUser(@Param("userId") String userId, @Param("modelId") String modelId);
7979
}

app-builder/plugins/aipp-custom-model-center/src/main/java/modelengine/fit/jade/aipp/model/po/ModelPo.java

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,87 @@
66

77
package modelengine.fit.jade.aipp.model.po;
88

9-
import lombok.AllArgsConstructor;
109
import lombok.Data;
1110
import modelengine.jade.common.po.BasePo;
1211

12+
import java.time.LocalDateTime;
13+
1314
/**
1415
* 模型信息 ORM 对象。
1516
*
1617
* @author lixin
1718
* @since 2025/3/11
1819
*/
1920
@Data
20-
@AllArgsConstructor
2121
public class ModelPo extends BasePo {
2222
private String modelId;
2323
private String name;
2424
private String tag;
2525
private String baseUrl;
2626
private String type;
27+
28+
/**
29+
* 用于构建 {@link ModelPo} 实例的构建器类。
30+
*/
31+
public static class Builder {
32+
private final ModelPo instance = new ModelPo();
33+
34+
public Builder modelId(String modelId) {
35+
instance.setModelId(modelId);
36+
return this;
37+
}
38+
39+
public Builder name(String name) {
40+
instance.setName(name);
41+
return this;
42+
}
43+
44+
public Builder tag(String tag) {
45+
instance.setTag(tag);
46+
return this;
47+
}
48+
49+
public Builder baseUrl(String baseUrl) {
50+
instance.setBaseUrl(baseUrl);
51+
return this;
52+
}
53+
54+
public Builder type(String type) {
55+
instance.setType(type);
56+
return this;
57+
}
58+
59+
public Builder id(Long id) {
60+
instance.setId(id);
61+
return this;
62+
}
63+
64+
public Builder createdAt(LocalDateTime createdAt) {
65+
instance.setCreatedAt(createdAt);
66+
return this;
67+
}
68+
69+
public Builder updatedAt(LocalDateTime updatedAt) {
70+
instance.setUpdatedAt(updatedAt);
71+
return this;
72+
}
73+
74+
public Builder createdBy(String createdBy) {
75+
instance.setCreatedBy(createdBy);
76+
return this;
77+
}
78+
79+
public Builder updatedBy(String updatedBy) {
80+
instance.setUpdatedBy(updatedBy);
81+
return this;
82+
}
83+
84+
public ModelPo build() {
85+
return instance;
86+
}
87+
}
88+
89+
public static Builder builder() {
90+
return new Builder();
91+
}
2792
}

app-builder/plugins/aipp-custom-model-center/src/main/java/modelengine/fit/jade/aipp/model/po/UserModelDetailPo.java

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,107 @@
66

77
package modelengine.fit.jade.aipp.model.po;
88

9-
import lombok.AllArgsConstructor;
109
import lombok.Data;
11-
import lombok.EqualsAndHashCode;
10+
1211
import modelengine.jade.common.po.BasePo;
1312

1413
import java.time.LocalDateTime;
1514

1615
/**
1716
* 用户模型关系信息用于前端表单展示。
1817
*
19-
* @author lizhichao
20-
* @since 2025/4/8
18+
* @author 李智超
19+
* @since 2025-04-08
2120
*/
2221
@Data
23-
@EqualsAndHashCode(callSuper = true)
24-
@AllArgsConstructor
2522
public class UserModelDetailPo extends BasePo {
2623
/**
27-
* 表示创建时间。
28-
*/
29-
private LocalDateTime createdAt;
30-
31-
/**
32-
* 模型 ID。
24+
* 表示模型标识。
3325
*/
3426
private String modelId;
3527

3628
/**
37-
* 用户标识
29+
* 表示用户标识
3830
*/
3931
private String userId;
4032

4133
/**
42-
* 模型名称
34+
* 表示模型名称
4335
*/
4436
private String modelName;
4537

4638
/**
47-
* 模型访问地址
39+
* 表示模型访问地址
4840
*/
4941
private String baseUrl;
5042

5143
/**
52-
* 是否为默认模型(1表示默认,0表示非默认)。
44+
* 表示是否为默认模型(1表示默认,0表示非默认)。
5345
*/
5446
private int isDefault;
47+
48+
/**
49+
* 用于构建 {@link UserModelDetailPo} 实例的构建器类。
50+
*/
51+
public static class Builder {
52+
private final UserModelDetailPo instance = new UserModelDetailPo();
53+
54+
public Builder id(Long id) {
55+
instance.setId(id);
56+
return this;
57+
}
58+
59+
public Builder createdAt(LocalDateTime createdAt) {
60+
instance.setCreatedAt(createdAt);
61+
return this;
62+
}
63+
64+
public Builder updatedAt(LocalDateTime updatedAt) {
65+
instance.setUpdatedAt(updatedAt);
66+
return this;
67+
}
68+
69+
public Builder createdBy(String createdBy) {
70+
instance.setCreatedBy(createdBy);
71+
return this;
72+
}
73+
74+
public Builder updatedBy(String updatedBy) {
75+
instance.setUpdatedBy(updatedBy);
76+
return this;
77+
}
78+
79+
public Builder modelId(String modelId) {
80+
instance.setModelId(modelId);
81+
return this;
82+
}
83+
84+
public Builder userId(String userId) {
85+
instance.setUserId(userId);
86+
return this;
87+
}
88+
89+
public Builder modelName(String modelName) {
90+
instance.setModelName(modelName);
91+
return this;
92+
}
93+
94+
public Builder baseUrl(String baseUrl) {
95+
instance.setBaseUrl(baseUrl);
96+
return this;
97+
}
98+
99+
public Builder isDefault(int isDefault) {
100+
instance.setIsDefault(isDefault);
101+
return this;
102+
}
103+
104+
public UserModelDetailPo build() {
105+
return instance;
106+
}
107+
}
108+
109+
public static Builder builder() {
110+
return new Builder();
111+
}
55112
}

0 commit comments

Comments
 (0)