Skip to content

Commit f190b6f

Browse files
committed
fix: fix init_data_for_test_v1.0.0.sql
2 parents 2b9768d + 24cfb66 commit f190b6f

File tree

17 files changed

+174
-177
lines changed

17 files changed

+174
-177
lines changed

app/src/main/resources/application-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spring:
1212
driver-class-name: org.mariadb.jdbc.Driver
1313
username: root
1414
password: 111111
15-
url: jdbc:mariadb://localhost:3306/tiny-engine-java?useUnicode=true&useSSL=false&characterEncoding=utf8
15+
url: jdbc:mariadb://localhost:3306/tiny_engine_data_java?useUnicode=true&useSSL=false&characterEncoding=utf8
1616
type: com.alibaba.druid.pool.DruidDataSource
1717
druid:
1818
initial-size: 5 # 连接池初始化时建立的连接数,默认值为 0。

app/src/main/resources/sql/mysql/update_all_tables_ddl.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ ALTER TABLE t_platform_history MODIFY tenant_id varchar(60) NULL;
2828
ALTER TABLE t_task_record MODIFY tenant_id varchar(60) NULL;
2929
ALTER TABLE t_user MODIFY tenant_id varchar(60) NULL;
3030

31-
ALTER TABLE t_component_library ADD app_id int NULL;
3231

base/src/main/java/com/tinyengine/it/common/utils/Schema.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212

1313
package com.tinyengine.it.common.utils;
1414

15+
import cn.hutool.core.exceptions.UtilException;
16+
import cn.hutool.core.util.ReflectUtil;
1517
import com.tinyengine.it.model.dto.SchemaConfig;
1618

1719
import lombok.extern.slf4j.Slf4j;
1820

19-
import java.lang.reflect.InvocationTargetException;
21+
import java.lang.reflect.Method;
2022
import java.text.ParseException;
2123
import java.text.SimpleDateFormat;
2224
import java.util.Date;
@@ -148,12 +150,15 @@ protected Map<String, Object> formatFields(Map<String, Object> data, Map<String,
148150
String key = entry.getKey();
149151
String funcName = entry.getValue();
150152
try {
151-
// 使用反射调用相应的格式化方法
152-
java.lang.reflect.Method method = this.getClass().getMethod(funcName, Object.class);
153-
Object value = data.get(key);
154-
formattedData.put(key, method.invoke(this, value));
155-
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
156-
log.error(e.getMessage());
153+
Method method = ReflectUtil.getMethod(Schema.class, funcName, Object.class);
154+
if (method == null) {
155+
log.error("not found {} funcName from schema", funcName);
156+
continue;
157+
}
158+
159+
formattedData.put(key, ReflectUtil.invoke(this, method, data.get(key)));
160+
} catch (SecurityException | UtilException err) {
161+
log.error(err.getMessage());
157162
}
158163
}
159164
return formattedData;
@@ -248,11 +253,14 @@ public String toRootElement(Object isBody) {
248253
* @return the string
249254
*/
250255
// group名称转换
251-
public String toGroupName(String group) {
256+
public String toGroupName(Object group) {
257+
if (group == null) {
258+
return "";
259+
}
252260
// 调整一下group命名
253-
if (GROUPS.contains(group)) {
261+
if (GROUPS.contains(group.toString())) {
254262
return group + "Pages";
255263
}
256-
return group;
264+
return group.toString();
257265
}
258266
}

base/src/main/java/com/tinyengine/it/controller/BlockController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,19 @@ public Result<List<String>> allTags() {
255255
@GetMapping("/block/notgroup/{groupId}")
256256
public Result<List<BlockDto>> findBlocksNotInGroup(@PathVariable Integer groupId,
257257
@RequestParam(value = "label_contains", required = false) String label,
258+
@RequestParam(value = "name_cn_contains", required = false) String name,
258259
@RequestParam(value = "tags_contains", required = false) String[] tags,
259260
@RequestParam(value = "createdBy", required = false) String createdBy) {
260261
NotGroupDto notGroupDto = new NotGroupDto();
261262
notGroupDto.setGroupId(groupId);
262263
notGroupDto.setLabel(label);
264+
notGroupDto.setName(name);
263265
notGroupDto.setCreatedBy(createdBy);
264266
notGroupDto.setTags(null);
267+
if (tags != null && tags.length > 0) {
268+
notGroupDto.setTags(JsonUtils.encode(tags)); // 将数组转换为有效的 JSON 字符串
269+
}
270+
265271

266272
List<BlockDto> blocksList = blockService.getNotInGroupBlocks(notGroupDto);
267273
return Result.success(blocksList);

base/src/main/java/com/tinyengine/it/controller/PageController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import io.swagger.v3.oas.annotations.responses.ApiResponse;
3030
import io.swagger.v3.oas.annotations.tags.Tag;
3131
import jakarta.servlet.http.HttpServletRequest;
32-
import jakarta.validation.Valid;
3332

3433
import org.springframework.beans.factory.annotation.Autowired;
3534
import org.springframework.validation.annotation.Validated;
@@ -115,7 +114,7 @@ public Result<Page> getPageById(@PathVariable Integer id) throws Exception {
115114
/**
116115
* 创建页面
117116
*
118-
* @param page the page
117+
* @param request the request
119118
* @return result
120119
* @throws Exception the exception
121120
*/
@@ -128,7 +127,8 @@ public Result<Page> getPageById(@PathVariable Integer id) throws Exception {
128127
})
129128
@SystemControllerLog(description = "创建页面")
130129
@PostMapping("/pages/create")
131-
public Result<Page> createPage(@Valid @RequestBody Page page) throws Exception {
130+
public Result<Page> createPage(HttpServletRequest request) throws IOException {
131+
Page page = JsonUtils.decode(request.getInputStream(), Page.class);
132132
if (page.getIsPage()) {
133133
// 创建页面
134134
return pageService.createPage(page);

base/src/main/java/com/tinyengine/it/mapper/BlockGroupBlockMapper.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,16 @@ public interface BlockGroupBlockMapper extends BaseMapper<BlockGroupBlock> {
9494
* 通过区块分组id和区块删除区块与分组关联关系
9595
* @param blockId the block id
9696
* @param groupId the block group id
97-
* @return the list
97+
* @return the Integer
9898
*/
9999
@Delete("delete from r_block_group_block where block_group_id = #{groupId} and block_id = #{blockId}")
100100
Integer deleteByGroupIdAndBlockId(Integer groupId, Integer blockId);
101+
102+
/**
103+
* 通过区块id删除区块与分组关联关系
104+
* @param blockId the block id
105+
* @return the Integer
106+
*/
107+
@Delete("delete from r_block_group_block where block_id = #{blockId}")
108+
Integer deleteByBlockId(Integer blockId);
101109
}

base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,13 @@ public interface BlockMapper extends BaseMapper<Block> {
156156
})
157157
@Select("<script>" + "SELECT b.* " + "FROM t_block b " + "<where>"
158158
+ " <if test='notGroupDto.label != null and notGroupDto.label != \"\"'> "
159-
+ " AND b.label LIKE CONCAT('%', #{notGroupDto.label}, '%') " + " </if>"
159+
+ " OR b.label LIKE CONCAT('%', #{notGroupDto.label}, '%') " + " </if>"
160+
+ " <if test='notGroupDto.name != null and notGroupDto.name != \"\"'> "
161+
+ " OR b.name LIKE CONCAT('%', #{notGroupDto.name}, '%') " + " </if>"
160162
+ " <if test='notGroupDto.createdBy != null and notGroupDto.createdBy != \"\"'> "
161-
+ " AND b.created_by LIKE CONCAT('%', #{notGroupDto.createdBy}, '%') " + " </if>"
162-
+ " <if test='notGroupDto.tags != null and notGroupDto.tags.length > 0'> "
163-
+ " AND JSON_CONTAINS(b.tags, #{notGroupDto.tags})" + " </if>" + "</where>" + "</script>")
163+
+ " OR b.created_by LIKE CONCAT('%', #{notGroupDto.createdBy}, '%') " + " </if>"
164+
+ " <if test='notGroupDto.tags != null and notGroupDto.tags != \"\"'> "
165+
+ " OR JSON_CONTAINS(b.tags, #{notGroupDto.tags})" + " </if>" + "</where>" + "</script>")
164166
List<BlockDto> findBlocksReturn(@Param("notGroupDto") NotGroupDto notGroupDto);
165167

166168
/**

base/src/main/java/com/tinyengine/it/model/dto/NotGroupDto.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ public class NotGroupDto {
3131
@Schema(name = "label", description = "区块编码")
3232
private String label;
3333

34+
@Schema(name = "name", description = "区块名称")
35+
private String name;
36+
37+
3438
@Schema(name = "createdBY", description = "创建人id")
3539
private String createdBy;
3640

3741
@Schema(name = "tags", description = "区块标签")
38-
private String [] tags;
42+
private String tags;
3943
}

base/src/main/java/com/tinyengine/it/model/entity/Component.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class Component extends BaseEntity {
4747
private Map<String, String> name;
4848

4949
@Schema(name = "component", description = "组件")
50+
@TableField(value = "name_en")
5051
private String component;
5152

5253
@Schema(name = "icon", description = "组件图标")
@@ -75,6 +76,7 @@ public class Component extends BaseEntity {
7576
private Map<String, Object> npm;
7677

7778
@Schema(name = "group", description = "分组")
79+
@TableField(value = "`group`")
7880
private String group;
7981

8082
@Schema(name = "category", description = "分类")
@@ -98,9 +100,11 @@ public class Component extends BaseEntity {
98100

99101
@JsonProperty("public")
100102
@Schema(name = "public", description = "公开状态:0,1,2")
103+
@TableField(value = "public")
101104
private Integer publicStatus;
102105

103106
@Schema(name = "framework", description = "技术栈")
107+
@TableField(value = "framework")
104108
private String framework;
105109

106110
@Schema(name = "isOfficial", description = "标识官方组件")
@@ -110,6 +114,7 @@ public class Component extends BaseEntity {
110114
private Boolean isDefault;
111115

112116
@Schema(name = "isTinyReserved", description = "是否tiny自有")
117+
@TableField(value = "tiny_reserved")
113118
private Boolean isTinyReserved;
114119

115120
@JsonProperty("component_metadata")

base/src/main/java/com/tinyengine/it/model/entity/ComponentLibrary.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ public class ComponentLibrary extends BaseEntity {
4545
private String name;
4646

4747
@Schema(name = "appId", description = "关联应用id")
48+
@TableField(value = "app_id")
4849
private Integer appId;
4950

5051
@JsonProperty("package")
5152
@Schema(name = "package", description = "包名")
53+
@TableField(value = "package")
5254
private String packageName;
5355

5456
@Schema(name = "registry", description = "注册")
@@ -82,17 +84,22 @@ public class ComponentLibrary extends BaseEntity {
8284

8385
@JsonProperty("public")
8486
@Schema(name = "public", description = "公开状态:0,1,2")
87+
@TableField(value = "public")
8588
private Integer publicStatus;
8689

8790
@Schema(name = "isStarted", description = "标识启用")
91+
@TableField(value = "is_started")
8892
private Boolean isStarted;
8993

9094
@Schema(name = "isOfficial", description = "标识官方组件")
95+
@TableField(value = "is_official")
9196
private Boolean isOfficial;
9297

9398
@Schema(name = "isDefault", description = "标识默认组件")
99+
@TableField(value = "is_default")
94100
private Boolean isDefault;
95101

96102
@Schema(name = "components", description = "组件库组件")
103+
@TableField(exist = false)
97104
private List<Component> components;
98105
}

0 commit comments

Comments
 (0)