Skip to content

Commit 8b8730a

Browse files
authored
fix: Modify block create and update api (#171)
* fix: update page history bug * fix: format code and fix style issue * fix: modify page histiry entity * feat: add code submission rules * fix: modify app schema for test * fix: modify t_i18n_entry u_idx_i18n_entity * fix: modify t_i18n_entry u_idx_i18n_entity * fix: modify block update api * fix: Modify code format * fix: Modify code format * fix: Modify code format * fix: modify block group api * fix: modify block group mapper * fix: modify workflows * fix: Update checkstyle.yml * fix: modify workflows * fix: Modify block create and update api * fix: Modify code format * fix: Modify code format
1 parent d5aa1d0 commit 8b8730a

File tree

10 files changed

+358
-177
lines changed

10 files changed

+358
-177
lines changed

.github/workflows/checkstyle.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,16 @@ jobs:
2222
uses: actions/setup-java@v4
2323
with:
2424
java-version: '8.*'
25+
distribution: 'temurin'
2526

26-
# 安装 Checkstyle(如果你是用 Maven 或 Gradle
27-
- name: Install dependencies
27+
# 安装依赖并运行 Checkstyle(如果是 Maven 项目
28+
- name: Install dependencies and run Checkstyle
2829
run: |
29-
./mvnw install # 如果是 Maven 项目
30-
# 或者
31-
# ./gradlew build # 如果是 Gradle 项目
32-
33-
# 运行 Checkstyle
34-
- name: Run Checkstyle
35-
run: |
36-
./mvnw checkstyle:check # 如果是 Maven 项目
37-
# 或者
38-
# ./gradlew check # 如果是 Gradle 项目
30+
mvn checkstyle:check
3931
4032
# 查看 Checkstyle 检查报告
4133
- name: Upload Checkstyle report
4234
uses: actions/upload-artifact@v4
4335
with:
4436
name: checkstyle-report
45-
path: target/checkstyle-result.xml # 如果是 Maven 项目
37+
path: target/checkstyle-result.xml # 这个路径应该是 Maven 生成的检查报告路径

.github/workflows/maven.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ create table `t_block`
198198
`platform_id` int not null comment '设计器id',
199199
`app_id` int not null comment '创建区块时所在appid',
200200
`content_blocks` longtext comment '设计预留字段',
201-
`block_group_id` int comment '区块分组id',
202201
`tenant_id` varchar(60) not null comment '租户id',
203202
`renter_id` varchar(60) comment '业务租户id',
204203
`site_id` varchar(60) comment '站点id,设计预留字段',

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.tinyengine.it.mapper.TenantMapper;
2020
import com.tinyengine.it.model.dto.BlockBuildDto;
2121
import com.tinyengine.it.model.dto.BlockDto;
22+
import com.tinyengine.it.model.dto.BlockParam;
2223
import com.tinyengine.it.model.dto.BlockParamDto;
2324
import com.tinyengine.it.model.dto.NotGroupDto;
2425
import com.tinyengine.it.model.entity.Block;
@@ -150,13 +151,13 @@ public Result<BlockDto> getBlocksById(@PathVariable Integer id) {
150151
/**
151152
* 创建block
152153
*
153-
* @param blockDto the block dto
154+
* @param blockParam the blockParam
154155
* @return BlockDto
155156
*/
156157
@Operation(summary = "创建block",
157158
description = "创建block",
158159
parameters = {
159-
@Parameter(name = "blockDto", description = "入参对象")
160+
@Parameter(name = "blockParam", description = "入参对象")
160161
},
161162
responses = {
162163
@ApiResponse(responseCode = "200", description = "返回信息",
@@ -166,8 +167,8 @@ public Result<BlockDto> getBlocksById(@PathVariable Integer id) {
166167
)
167168
@SystemControllerLog(description = "区块创建api")
168169
@PostMapping("/block/create")
169-
public Result<BlockDto> createBlocks(@Valid @RequestBody BlockDto blockDto) {
170-
return blockService.createBlock(blockDto);
170+
public Result<BlockDto> createBlocks(@Valid @RequestBody BlockParam blockParam) {
171+
return blockService.createBlock(blockParam);
171172
}
172173

173174

@@ -268,7 +269,7 @@ public Result<List<String>> allTags() {
268269
@GetMapping("/block/notgroup/{groupId}")
269270
public Result<List<BlockDto>> findBlocksNotInGroup(@PathVariable Integer groupId,
270271
@RequestParam(value = "label_contains", required = false) String label,
271-
@RequestParam(value = "tags_contains", required = false) String [] tags,
272+
@RequestParam(value = "tags_contains", required = false) String[] tags,
272273
@RequestParam(value = "createdBy", required = false) String createdBy) {
273274
NotGroupDto notGroupDto = new NotGroupDto();
274275
notGroupDto.setGroupId(groupId);
@@ -378,14 +379,14 @@ public Result<List<Block>> getBlockGroups(
378379
/**
379380
* 修改block
380381
*
381-
* @param blockDto blockDto
382+
* @param blockParam blockParam
382383
* @param id id
383384
* @return block dto
384385
*/
385386
@Operation(summary = "修改区块",
386387
description = "修改区块",
387388
parameters = {
388-
@Parameter(name = "blockDto", description = "入参对象"),
389+
@Parameter(name = "blockParam", description = "入参对象"),
389390
@Parameter(name = "id", description = "区块id")
390391
},
391392
responses = {
@@ -396,10 +397,10 @@ public Result<List<Block>> getBlockGroups(
396397
)
397398
@SystemControllerLog(description = "区块修改api")
398399
@PostMapping("/block/update/{id}")
399-
public Result<BlockDto> updateBlocks(@Valid @RequestBody BlockDto blockDto, @PathVariable Integer id,
400+
public Result<BlockDto> updateBlocks(@Valid @RequestBody BlockParam blockParam, @PathVariable Integer id,
400401
@RequestParam(value = "appId", required = false) Integer appId) {
401-
blockDto.setId(id);
402-
return blockService.updateBlockById(blockDto, appId);
402+
blockParam.setId(id);
403+
return blockService.updateBlockById(blockParam, appId);
403404
}
404405

405406
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.tinyengine.it.common.base.BaseEntity;
1919
import com.tinyengine.it.common.handler.ListTypeHandler;
2020
import com.tinyengine.it.common.handler.MapTypeHandler;
21+
import com.tinyengine.it.model.entity.BlockGroup;
2122
import com.tinyengine.it.model.entity.BlockHistory;
2223
import com.tinyengine.it.model.entity.User;
2324

@@ -133,7 +134,7 @@ public class BlockDto extends BaseEntity {
133134

134135
@TableField(exist = false)
135136
@Schema(name = "groups", type = " List<BlockGroup>", description = "区块分组")
136-
private List<Object> groups = new ArrayList<>();
137+
private List<BlockGroup> groups = new ArrayList<>();
137138

138139
@TableField(exist = false)
139140
@Schema(name = "histories", type = " List<BlockHistory>", description = "区块历史")
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
/**
2+
* Copyright (c) 2023 - present TinyEngine Authors.
3+
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
4+
*
5+
* Use of this source code is governed by an MIT-style license.
6+
*
7+
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8+
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9+
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10+
*
11+
*/
12+
13+
package com.tinyengine.it.model.dto;
14+
15+
import com.baomidou.mybatisplus.annotation.TableField;
16+
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
17+
import com.fasterxml.jackson.annotation.JsonProperty;
18+
import com.tinyengine.it.common.base.BaseEntity;
19+
import com.tinyengine.it.common.handler.ListTypeHandler;
20+
import com.tinyengine.it.common.handler.MapTypeHandler;
21+
import com.tinyengine.it.model.entity.BlockHistory;
22+
import com.tinyengine.it.model.entity.User;
23+
import io.swagger.v3.oas.annotations.media.Schema;
24+
import lombok.Data;
25+
26+
import java.util.ArrayList;
27+
import java.util.Arrays;
28+
import java.util.List;
29+
import java.util.Map;
30+
31+
/**
32+
* <p>
33+
* 区块param
34+
* </p>
35+
* This class serves as a parameter object for block creation and updates,
36+
* working in conjunction with {@link BlockDto}. While BlockDto represents
37+
* the full block data model, BlockParam is specifically designed for
38+
* handling input parameters during block operations.
39+
* @author lu-yg
40+
* @since 2024-01-27
41+
*/
42+
@Data
43+
public class BlockParam extends BaseEntity {
44+
private static final long serialVersionUID = 1L;
45+
46+
@Schema(name = "label", description = "区块显示名称,严格大小写格式")
47+
private String label;
48+
49+
@Schema(name = "name", description = "区块名称")
50+
@JsonProperty("name_cn")
51+
private String name;
52+
53+
@Schema(name = "framework", description = "技术栈")
54+
private String framework;
55+
56+
@TableField(typeHandler = JacksonTypeHandler.class)
57+
@Schema(name = "assets", description = "构建资源")
58+
private Map<String, Object> assets;
59+
60+
@JsonProperty("last_build_info")
61+
@TableField(typeHandler = JacksonTypeHandler.class)
62+
@Schema(name = "lastBuildInfo", description = "最新一次构建信息")
63+
private Map<String, Object> lastBuildInfo;
64+
65+
@TableField(typeHandler = JacksonTypeHandler.class)
66+
@Schema(name = "content", description = "区块内容")
67+
private Map<String, Object> content;
68+
69+
@Schema(name = "description", description = "描述")
70+
private String description;
71+
72+
@Schema(name = "tags", description = "标签")
73+
@TableField(typeHandler = ListTypeHandler.class)
74+
private List<String> tags;
75+
76+
@Schema(name = "latestHistoryId", description = "当前历史记录表ID")
77+
@JsonProperty("current_history")
78+
private BlockHistory latestHistoryId;
79+
80+
@Schema(name = "screenshot", description = "截屏")
81+
private String screenshot;
82+
83+
@Schema(name = "path", description = "区块路径")
84+
private String path;
85+
86+
@Schema(name = "latestVersion", description = "当前历史记录表最新版本")
87+
@JsonProperty("version")
88+
private String latestVersion;
89+
90+
@Schema(name = "occupierId", description = "当前锁定人id")
91+
private String occupierId;
92+
93+
@Schema(name = "isOfficial", description = "是否是官方")
94+
@JsonProperty("is_official")
95+
private Boolean isOfficial;
96+
97+
@Schema(name = "isDefault", description = "是否是默认")
98+
@JsonProperty("is_default")
99+
private Boolean isDefault;
100+
101+
@Schema(name = "tinyReserved", description = "是否是tiny专有")
102+
@JsonProperty("tiny_reserved")
103+
private Boolean isTinyReserved;
104+
105+
@Schema(name = "npmName", description = "npm包名")
106+
@JsonProperty("npm_name")
107+
private String npmName;
108+
109+
@Schema(name = "public", description = "公开状态:0,1,2")
110+
@JsonProperty("public")
111+
private Integer publicStatus;
112+
113+
@Schema(name = "i18n", description = "国际化")
114+
@TableField(typeHandler = MapTypeHandler.class)
115+
private Map<String, Map<String, String>> i18n;
116+
117+
@Schema(name = "appId", description = "创建区块时所在appId")
118+
@JsonProperty("created_app")
119+
private Integer appId;
120+
121+
@Schema(name = "contentBlocks", description = "*设计预留字段用途*")
122+
@JsonProperty("content_blocks")
123+
private String contentBlocks;
124+
125+
@Schema(name = "platformId", description = "设计器ID")
126+
@JsonProperty("platform_id")
127+
private Integer platformId;
128+
129+
@JsonProperty("occupier")
130+
@Schema(name = "occupierBy", description = "当前锁定人")
131+
private User occupier;
132+
133+
@TableField(exist = false)
134+
@JsonProperty("public_scope_tenants")
135+
private List<Object> publicScopeTenants = new ArrayList<>();
136+
137+
@TableField(exist = false)
138+
@Schema(name = "groups", type = " List<BlockGroup>", description = "区块分组")
139+
private List<Integer> groups = new ArrayList<>();
140+
141+
@TableField(exist = false)
142+
@Schema(name = "histories", type = " List<BlockHistory>", description = "区块历史")
143+
private List<BlockHistory> histories = new ArrayList<>();
144+
145+
@TableField(exist = false)
146+
@JsonProperty("histories_length")
147+
private Integer historiesLength = 0;
148+
149+
@TableField(exist = false)
150+
@JsonProperty("is_published")
151+
private Boolean isPublished;
152+
153+
@TableField(exist = false)
154+
@JsonProperty("current_version")
155+
private String currentVersion;
156+
@JsonProperty("public")
157+
public Integer getPublic() {
158+
if (this.publicStatus != null && !Arrays.asList(0, 1, 2).contains(this.publicStatus)) {
159+
throw new IllegalStateException("Invalid public status value: " + this.publicStatus);
160+
}
161+
return this.publicStatus;
162+
}
163+
}
164+

base/src/main/java/com/tinyengine/it/service/material/BlockService.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.tinyengine.it.common.base.Result;
1717
import com.tinyengine.it.model.dto.BlockBuildDto;
1818
import com.tinyengine.it.model.dto.BlockDto;
19+
import com.tinyengine.it.model.dto.BlockParam;
1920
import com.tinyengine.it.model.dto.BlockParamDto;
2021
import com.tinyengine.it.model.dto.NotGroupDto;
2122
import com.tinyengine.it.model.entity.Block;
@@ -66,18 +67,18 @@ public interface BlockService {
6667
/**
6768
* 根据主键id更新表t_block信息
6869
*
69-
* @param blockDto the block dto
70+
* @param blockParam the block param
7071
* @return the BlockDto
7172
*/
72-
Result<BlockDto> updateBlockById(BlockDto blockDto, Integer appId);
73+
Result<BlockDto> updateBlockById(BlockParam blockParam, Integer appId);
7374

7475
/**
7576
* 新增表t_block数据
7677
*
77-
* @param blockDto the block dto
78+
* @param blockParam the blockParam
7879
* @return the result
7980
*/
80-
Result<BlockDto> createBlock(BlockDto blockDto);
81+
Result<BlockDto> createBlock(BlockParam blockParam);
8182

8283
/**
8384
* 区块分页查询

0 commit comments

Comments
 (0)