Skip to content

Commit b1e0f83

Browse files
committed
feat: component library api
1 parent a920283 commit b1e0f83

19 files changed

+1097
-150
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE t_material_history
2+
ADD COLUMN is_started TINYINT(1) DEFAULT 0;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE t_material_history
2+
ADD COLUMN is_started TINYINT(1) DEFAULT 0;

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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ create table `t_block_carriers_relation`
619619
(
620620
`id` int not null auto_increment comment '主键id',
621621
`block_id` int not null comment '区块id',
622-
`host_id` int not null comment '类型id',
622+
`host_id` int not null comment '类型id',
623623
`host_type` varchar(60) comment '类型:blockGroup,materialHistory',
624624
`version` varchar(60) not null comment '区块当前使用版本',
625625
`tenant_id` varchar(60) not null comment '租户id',
@@ -642,4 +642,36 @@ create table `r_block_group_block`
642642
`block_group_id` int not null comment '区块分组id',
643643
primary key (`id`) using btree,
644644
unique index `u_idx_block_group_block` (block_id, block_group_id) using btree
645-
) engine = innodb comment = '区块分组和区块关系表';
645+
) engine = innodb comment = '区块分组和区块关系表';
646+
647+
drop table if exists `t_component_library`;
648+
649+
create table `t_component_library`
650+
(
651+
`id` int not null auto_increment comment '主键id',
652+
`version` varchar(255) not null comment '版本',
653+
`name` varchar(255) not null comment '名称',
654+
`package` varchar(255) not null comment '包名',
655+
`registry` varchar(255) comment '注册',
656+
`framework` varchar(255) not null comment '技术栈',
657+
`description` varchar(2000) comment '描述',
658+
`script` varchar(255) comment '脚本地址',
659+
`css` varchar(255) comment '样式地址',
660+
`bundle` varchar(255) comment 'bundle.json地址',
661+
`dependencies` longtext comment '依赖',
662+
`others` longtext comment '其他',
663+
`thumbnail` varchar(255) comment '略图',
664+
`public` int comment '公开状态:0,1,2',
665+
`is_started` tinyint(1) comment '是否启用',
666+
`is_official` tinyint(1) comment '是否是官方',
667+
`is_default` tinyint(1) comment '是否是默认',
668+
`tenant_id` varchar(60) not null comment '租户id',
669+
`renter_id` varchar(60) comment '业务租户id',
670+
`site_id` varchar(60) comment '站点id,设计预留字段',
671+
`created_by` varchar(60) not null comment '创建人',
672+
`created_time` timestamp not null default current_timestamp comment '创建时间',
673+
`last_updated_by` varchar(60) not null comment '最后修改人',
674+
`last_updated_time` timestamp not null default current_timestamp comment '更新时间',
675+
primary key (`id`) using btree,
676+
unique index `u_idx_component_library` (`tenant_id`, `name`, `version`) using btree
677+
) engine = innodb comment = '组件库表';
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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.controller;
14+
15+
import com.tinyengine.it.common.base.Result;
16+
import com.tinyengine.it.common.log.SystemControllerLog;
17+
import com.tinyengine.it.model.entity.ComponentLibrary;
18+
import com.tinyengine.it.service.material.ComponentLibraryService;
19+
import io.swagger.v3.oas.annotations.Operation;
20+
import io.swagger.v3.oas.annotations.Parameter;
21+
import io.swagger.v3.oas.annotations.media.Content;
22+
import io.swagger.v3.oas.annotations.media.Schema;
23+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
24+
import io.swagger.v3.oas.annotations.tags.Tag;
25+
import org.springframework.beans.factory.annotation.Autowired;
26+
import org.springframework.validation.annotation.Validated;
27+
import org.springframework.web.bind.annotation.GetMapping;
28+
import org.springframework.web.bind.annotation.PathVariable;
29+
import org.springframework.web.bind.annotation.PostMapping;
30+
import org.springframework.web.bind.annotation.RequestBody;
31+
import org.springframework.web.bind.annotation.RequestMapping;
32+
import org.springframework.web.bind.annotation.RestController;
33+
34+
import javax.validation.Valid;
35+
import java.util.List;
36+
37+
/**
38+
* 组件库API
39+
*
40+
* @since 2025-4-02
41+
*/
42+
@Validated
43+
@RestController
44+
@RequestMapping("/componentLibrary-center/api")
45+
@Tag(name = "组件库")
46+
public class ComponentLibraryController {
47+
/**
48+
* The ComponentLibrary service.
49+
*/
50+
@Autowired
51+
private ComponentLibraryService componentLibraryService;
52+
53+
/**
54+
* 查询表ComponentLibrary信息
55+
*
56+
* @return ComponentLibrary信息 all componentLibrary
57+
*/
58+
@Operation(summary = "查询表ComponentLibrary信息",
59+
description = "查询表ComponentLibrary信息",
60+
responses = {
61+
@ApiResponse(responseCode = "200", description = "返回信息",
62+
content = @Content(mediaType = "application/json",
63+
schema = @Schema(implementation = ComponentLibrary.class))),
64+
@ApiResponse(responseCode = "400", description = "请求失败")})
65+
@SystemControllerLog(description = "查询表ComponentLibrary信息")
66+
@GetMapping("/componentLibrary/list")
67+
public Result<List<ComponentLibrary>> getAllComponentLibrary() {
68+
List<ComponentLibrary> componentLibraryHistoryList = componentLibraryService.queryAllComponentLibrary();
69+
return Result.success(componentLibraryHistoryList);
70+
}
71+
72+
/**
73+
* 创建ComponentLibrary
74+
*
75+
* @param componentLibrary the componentLibrary
76+
* @return ComponentLibrary信息 result
77+
*/
78+
@Operation(summary = "创建ComponentLibrary",
79+
description = "创建ComponentLibrary",
80+
parameters = {
81+
@Parameter(name = "ComponentLibrary", description = "ComponentLibrary入参对象")
82+
},
83+
responses = {
84+
@ApiResponse(responseCode = "200", description = "返回信息",
85+
content = @Content(mediaType = "application/json",
86+
schema = @Schema(implementation = ComponentLibrary.class))),
87+
@ApiResponse(responseCode = "400", description = "请求失败")}
88+
)
89+
@SystemControllerLog(description = "创建ComponentLibrary")
90+
@PostMapping("/component-library/create")
91+
public Result<ComponentLibrary> createComponentLibrary(@Valid @RequestBody ComponentLibrary componentLibrary) {
92+
return componentLibraryService.createComponentLibrary(componentLibrary);
93+
}
94+
95+
/**
96+
* 修改ComponentLibrary信息
97+
*
98+
* @param id the id
99+
* @param componentLibrary the componentLibrary
100+
* @return ComponentLibrary信息 result
101+
*/
102+
@Operation(summary = "修改单个ComponentLibrary信息", description = "修改单个ComponentLibrary信息", parameters = {
103+
@Parameter(name = "id", description = "appId"),
104+
@Parameter(name = "ComponentLibrary", description = "入参对象")}, responses = {
105+
@ApiResponse(responseCode = "200", description = "返回信息",
106+
content = @Content(mediaType = "application/json",
107+
schema = @Schema(implementation = ComponentLibrary.class))),
108+
@ApiResponse(responseCode = "400", description = "请求失败")})
109+
@SystemControllerLog(description = "修改单个ComponentLibrary信息")
110+
@PostMapping("/component-library/update/{id}")
111+
public Result<ComponentLibrary> updateComponentLibrary(@PathVariable Integer id, @RequestBody ComponentLibrary componentLibrary) {
112+
componentLibrary.setId(id);
113+
return componentLibraryService.updateComponentLibraryById(componentLibrary);
114+
}
115+
116+
/**
117+
* 删除ComponentLibrary信息
118+
*
119+
* @param id the id
120+
* @return app信息 result
121+
*/
122+
@Operation(summary = "删除app信息",
123+
description = "删除app信息",
124+
parameters = {
125+
@Parameter(name = "id", description = "ComponentLibrary主键id")
126+
},
127+
responses = {
128+
@ApiResponse(responseCode = "200", description = "返回信息",
129+
content = @Content(mediaType = "application/json",
130+
schema = @Schema(implementation = ComponentLibrary.class))),
131+
@ApiResponse(responseCode = "400", description = "请求失败")}
132+
)
133+
@SystemControllerLog(description = "删除app信息")
134+
@GetMapping("/component-library/delete/{id}")
135+
public Result<ComponentLibrary> deleteComponentLibrary(@PathVariable Integer id) {
136+
return componentLibraryService.deleteComponentLibraryById(id);
137+
}
138+
139+
/**
140+
* 获取应用信息详情
141+
*
142+
* @param id the id
143+
* @return the result
144+
*/
145+
@Operation(summary = "获取应用信息详情", description = "获取应用信息详情", parameters = {
146+
@Parameter(name = "id", description = "appId")}, responses = {
147+
@ApiResponse(responseCode = "200", description = "返回信息",
148+
content = @Content(mediaType = "application/json",
149+
schema = @Schema(implementation = ComponentLibrary.class))),
150+
@ApiResponse(responseCode = "400", description = "请求失败")})
151+
@SystemControllerLog(description = "获取应用信息详情")
152+
@GetMapping("/component-library/detail/{id}")
153+
public Result<ComponentLibrary> detail(@PathVariable Integer id) {
154+
return componentLibraryService.queryComponentLibraryById(id);
155+
}
156+
}

base/src/main/java/com/tinyengine/it/controller/MaterialHistoryController.java renamed to base/src/main/java/com/tinyengine/it/controller/MaterialController.java

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import com.tinyengine.it.common.base.Result;
1616
import com.tinyengine.it.common.log.SystemControllerLog;
17-
import com.tinyengine.it.model.entity.MaterialHistory;
18-
import com.tinyengine.it.service.material.MaterialHistoryService;
17+
import com.tinyengine.it.model.entity.Material;
18+
import com.tinyengine.it.service.material.MaterialService;
1919
import io.swagger.v3.oas.annotations.Operation;
2020
import io.swagger.v3.oas.annotations.Parameter;
2121
import io.swagger.v3.oas.annotations.media.Content;
@@ -32,9 +32,7 @@
3232
import org.springframework.web.bind.annotation.RestController;
3333

3434
import javax.validation.Valid;
35-
import java.util.Arrays;
3635
import java.util.List;
37-
import java.util.Map;
3836

3937
/**
4038
* 物料历史api
@@ -45,97 +43,97 @@
4543
@RestController
4644
@RequestMapping("/material-center/api")
4745
@Tag(name = "物料历史")
48-
public class MaterialHistoryController {
46+
public class MaterialController {
4947
/**
50-
* The MaterialHistory service.
48+
* The Material service.
5149
*/
5250
@Autowired
53-
private MaterialHistoryService materialHistoryService;
51+
private MaterialService materialService;
5452

5553
/**
56-
* 查询表MaterialHistory信息
54+
* 查询表Material信息
5755
*
58-
* @return MaterialHistory信息 all materialHistory
56+
* @return Material信息 all material
5957
*/
60-
@Operation(summary = "查询表MaterialHistory信息",
61-
description = "查询表MaterialHistory信息",
58+
@Operation(summary = "查询表Material信息",
59+
description = "查询表Material信息",
6260
responses = {
6361
@ApiResponse(responseCode = "200", description = "返回信息",
6462
content = @Content(mediaType = "application/json",
65-
schema = @Schema(implementation = MaterialHistory.class))),
63+
schema = @Schema(implementation = Material.class))),
6664
@ApiResponse(responseCode = "400", description = "请求失败")})
67-
@SystemControllerLog(description = "查询表MaterialHistory信息")
68-
@GetMapping("/material-history/list")
69-
public Result<List<MaterialHistory>> getAllMaterialHistory() {
70-
List<MaterialHistory> materialHistoryList = materialHistoryService.findAllMaterialHistory();
65+
@SystemControllerLog(description = "查询表Material信息")
66+
@GetMapping("/material/list")
67+
public Result<List<Material>> getAllMaterial() {
68+
List<Material> materialHistoryList = materialService.queryAllMaterial();
7169
return Result.success(materialHistoryList);
7270
}
7371

7472
/**
75-
* 创建MaterialHistory
73+
* 创建Material
7674
*
77-
* @param materialHistory the materialHistory
78-
* @return MaterialHistory信息 result
75+
* @param material the material
76+
* @return Material信息 result
7977
*/
80-
@Operation(summary = "创建MaterialHistory",
81-
description = "创建MaterialHistory",
78+
@Operation(summary = "创建Material",
79+
description = "创建Material",
8280
parameters = {
83-
@Parameter(name = "MaterialHistory", description = "MaterialHistory入参对象")
81+
@Parameter(name = "Material", description = "Material入参对象")
8482
},
8583
responses = {
8684
@ApiResponse(responseCode = "200", description = "返回信息",
8785
content = @Content(mediaType = "application/json",
88-
schema = @Schema(implementation = MaterialHistory.class))),
86+
schema = @Schema(implementation = Material.class))),
8987
@ApiResponse(responseCode = "400", description = "请求失败")}
9088
)
91-
@SystemControllerLog(description = "创建MaterialHistory")
92-
@PostMapping("/material-history/create")
93-
public Result<MaterialHistory> createMaterialHistory(@Valid @RequestBody MaterialHistory materialHistory) {
94-
return materialHistoryService.createMaterialHistory(materialHistory);
89+
@SystemControllerLog(description = "创建Material")
90+
@PostMapping("/material/create")
91+
public Result<Material> createMaterial(@Valid @RequestBody Material material) {
92+
return materialService.createMaterial(material);
9593
}
9694

9795
/**
98-
* 修改MaterialHistory信息
96+
* 修改Material信息
9997
*
10098
* @param id the id
101-
* @param materialHistory the materialHistory
102-
* @return MaterialHistory信息 result
99+
* @param material the material
100+
* @return Material信息 result
103101
*/
104-
@Operation(summary = "修改单个MaterialHistory信息", description = "修改单个MaterialHistory信息", parameters = {
102+
@Operation(summary = "修改单个Material信息", description = "修改单个Material信息", parameters = {
105103
@Parameter(name = "id", description = "appId"),
106-
@Parameter(name = "MaterialHistory", description = "入参对象")}, responses = {
104+
@Parameter(name = "Material", description = "入参对象")}, responses = {
107105
@ApiResponse(responseCode = "200", description = "返回信息",
108106
content = @Content(mediaType = "application/json",
109-
schema = @Schema(implementation = MaterialHistory.class))),
107+
schema = @Schema(implementation = Material.class))),
110108
@ApiResponse(responseCode = "400", description = "请求失败")})
111-
@SystemControllerLog(description = "修改单个MaterialHistory信息")
112-
@PostMapping("/apps/update/{id}")
113-
public Result<MaterialHistory> updateMaterialHistory(@PathVariable Integer id, @RequestBody MaterialHistory materialHistory) {
114-
materialHistory.setId(id);
115-
return materialHistoryService.updateMaterialHistoryById(materialHistory);
109+
@SystemControllerLog(description = "修改单个Material信息")
110+
@PostMapping("/material/update/{id}")
111+
public Result<Material> updateMaterial(@PathVariable Integer id, @RequestBody Material material) {
112+
material.setId(id);
113+
return materialService.updateMaterialById(material);
116114
}
117115

118116
/**
119-
* 删除MaterialHistory信息
117+
* 删除Material信息
120118
*
121119
* @param id the id
122120
* @return app信息 result
123121
*/
124122
@Operation(summary = "删除app信息",
125123
description = "删除app信息",
126124
parameters = {
127-
@Parameter(name = "id", description = "MaterialHistory主键id")
125+
@Parameter(name = "id", description = "Material主键id")
128126
},
129127
responses = {
130128
@ApiResponse(responseCode = "200", description = "返回信息",
131129
content = @Content(mediaType = "application/json",
132-
schema = @Schema(implementation = MaterialHistory.class))),
130+
schema = @Schema(implementation = Material.class))),
133131
@ApiResponse(responseCode = "400", description = "请求失败")}
134132
)
135133
@SystemControllerLog(description = "删除app信息")
136-
@GetMapping("/material-history/delete/{id}")
137-
public Result<MaterialHistory> deleteMaterialHistory(@PathVariable Integer id) {
138-
return materialHistoryService.deleteMaterialHistoryById(id);
134+
@GetMapping("/material/delete/{id}")
135+
public Result<Material> deleteMaterial(@PathVariable Integer id) {
136+
return materialService.deleteMaterialById(id);
139137
}
140138

141139
/**
@@ -148,11 +146,11 @@ public Result<MaterialHistory> deleteMaterialHistory(@PathVariable Integer id) {
148146
@Parameter(name = "id", description = "appId")}, responses = {
149147
@ApiResponse(responseCode = "200", description = "返回信息",
150148
content = @Content(mediaType = "application/json",
151-
schema = @Schema(implementation = MaterialHistory.class))),
149+
schema = @Schema(implementation = Material.class))),
152150
@ApiResponse(responseCode = "400", description = "请求失败")})
153151
@SystemControllerLog(description = "获取应用信息详情")
154-
@GetMapping("/material-history/detail/{id}")
155-
public Result<MaterialHistory> detail(@PathVariable Integer id) {
156-
return materialHistoryService.findMaterialHistoryById(id);
152+
@GetMapping("/material/detail/{id}")
153+
public Result<Material> detail(@PathVariable Integer id) {
154+
return materialService.queryMaterialById(id);
157155
}
158156
}

0 commit comments

Comments
 (0)