Skip to content

Commit a920283

Browse files
committed
feat: material history api
2 parents 934130f + 342bb06 commit a920283

29 files changed

+559
-95
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
package com.tinyengine.it.config.context;
13+
14+
import com.tinyengine.it.common.context.LoginUserContext;
15+
16+
/**
17+
* 默认的登录用户Context实现
18+
*/
19+
public class DefaultLoginUserContext implements LoginUserContext {
20+
@Override
21+
public String getTenantId() {
22+
return "1";
23+
}
24+
25+
@Override
26+
public String getLoginUserId() {
27+
return "1";
28+
}
29+
30+
@Override
31+
public String getRenterId() {
32+
return "1";
33+
}
34+
35+
@Override
36+
public int getAppId() {
37+
return 1;
38+
}
39+
40+
@Override
41+
public int getPlatformId() {
42+
return 1;
43+
}
44+
}

base/src/main/java/com/tinyengine/it/common/base/PageQueryVo.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/**
22
* Copyright (c) 2023 - present TinyEngine Authors.
33
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
4-
* <p>
4+
*
55
* Use of this source code is governed by an MIT-style license.
6-
* <p>
6+
*
77
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
88
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
99
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10+
*
1011
*/
1112

1213
package com.tinyengine.it.common.base;
@@ -23,6 +24,7 @@ public class PageQueryVo<T> {
2324
* 最大分页数量
2425
*/
2526
public static final int PAGESIZE_MAX = 200;
27+
2628
/**
2729
* 默认分页数量
2830
*/
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright (c) 2023 - present TinyEngine Authors.
3+
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
4+
* <p>
5+
* Use of this source code is governed by an MIT-style license.
6+
* <p>
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+
package com.tinyengine.it.common.context;
13+
14+
/**
15+
* 保存用户信息的上下文
16+
* 由集成方自行实现接口
17+
*/
18+
public interface LoginUserContext {
19+
/**
20+
* 返回当前用户所诉的业务租户信息
21+
* @return 租户ID
22+
*/
23+
public String getTenantId();
24+
25+
/**
26+
* 返回当前用户信息
27+
* @return 用户ID
28+
*/
29+
public String getLoginUserId();
30+
31+
/**
32+
* 返回当前用户所属业务租户信息
33+
* @return 业务租户ID
34+
*/
35+
public String getRenterId();
36+
37+
/**
38+
* 返回当前应用信息
39+
* @return 应用ID
40+
*/
41+
public int getAppId();
42+
43+
/**
44+
* 返回当前设计器信息
45+
* @return 设计器ID
46+
*/
47+
public int getPlatformId();
48+
}

base/src/main/java/com/tinyengine/it/common/handler/MyMetaObjectHandler.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
package com.tinyengine.it.common.handler;
1414

1515
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
16+
import com.tinyengine.it.common.context.LoginUserContext;
1617

1718
import lombok.extern.slf4j.Slf4j;
1819

1920
import org.apache.ibatis.reflection.MetaObject;
21+
import org.springframework.beans.factory.annotation.Autowired;
2022
import org.springframework.stereotype.Component;
2123

2224
import java.time.LocalDateTime;
@@ -29,15 +31,17 @@
2931
@Component
3032
@Slf4j
3133
public class MyMetaObjectHandler implements MetaObjectHandler {
34+
@Autowired
35+
private LoginUserContext loginUserContext;
36+
3237
@Override
3338
public void insertFill(MetaObject metaObject) {
3439
this.setFieldValByName("createdTime", LocalDateTime.now(), metaObject);
3540
this.setFieldValByName("lastUpdatedTime", LocalDateTime.now(), metaObject);
36-
this.setFieldValByName("createdBy", "1", metaObject);
37-
this.setFieldValByName("lastUpdatedBy", "1", metaObject);
38-
this.setFieldValByName("tenantId", "1", metaObject);
39-
this.setFieldValByName("renterId", "1", metaObject);
40-
this.setFieldValByName("siteId", "1", metaObject);
41+
this.setFieldValByName("createdBy", loginUserContext.getLoginUserId(), metaObject);
42+
this.setFieldValByName("lastUpdatedBy", loginUserContext.getLoginUserId(), metaObject);
43+
this.setFieldValByName("tenantId", loginUserContext.getTenantId(), metaObject);
44+
this.setFieldValByName("renterId", loginUserContext.getRenterId(), metaObject);
4145
}
4246

4347
@Override
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright (c) 2023 - present TinyEngine Authors.
3+
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
4+
* <p>
5+
* Use of this source code is governed by an MIT-style license.
6+
* <p>
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+
package com.tinyengine.it.common.utils;
13+
14+
import java.lang.reflect.Field;
15+
16+
/**
17+
* 测试工工具类
18+
*/
19+
public class TestUtil {
20+
/**
21+
* 设置私有字段的属性值
22+
*
23+
* @param obj 对象
24+
* @param field 字段名
25+
* @param value 值
26+
* @throws NoSuchFieldException 异常
27+
* @throws IllegalAccessException 异常
28+
*/
29+
public static void setPrivateValue(Object obj, String field, Object value)
30+
throws NoSuchFieldException, IllegalAccessException {
31+
Field declaredField = obj.getClass().getDeclaredField(field);
32+
declaredField.setAccessible(true);
33+
declaredField.set(obj, value);
34+
}
35+
}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
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.MaterialHistory;
18+
import com.tinyengine.it.service.material.MaterialHistoryService;
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.Arrays;
36+
import java.util.List;
37+
import java.util.Map;
38+
39+
/**
40+
* 物料历史api
41+
*
42+
* @since 2025-4-1
43+
*/
44+
@Validated
45+
@RestController
46+
@RequestMapping("/material-center/api")
47+
@Tag(name = "物料历史")
48+
public class MaterialHistoryController {
49+
/**
50+
* The MaterialHistory service.
51+
*/
52+
@Autowired
53+
private MaterialHistoryService materialHistoryService;
54+
55+
/**
56+
* 查询表MaterialHistory信息
57+
*
58+
* @return MaterialHistory信息 all materialHistory
59+
*/
60+
@Operation(summary = "查询表MaterialHistory信息",
61+
description = "查询表MaterialHistory信息",
62+
responses = {
63+
@ApiResponse(responseCode = "200", description = "返回信息",
64+
content = @Content(mediaType = "application/json",
65+
schema = @Schema(implementation = MaterialHistory.class))),
66+
@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();
71+
return Result.success(materialHistoryList);
72+
}
73+
74+
/**
75+
* 创建MaterialHistory
76+
*
77+
* @param materialHistory the materialHistory
78+
* @return MaterialHistory信息 result
79+
*/
80+
@Operation(summary = "创建MaterialHistory",
81+
description = "创建MaterialHistory",
82+
parameters = {
83+
@Parameter(name = "MaterialHistory", description = "MaterialHistory入参对象")
84+
},
85+
responses = {
86+
@ApiResponse(responseCode = "200", description = "返回信息",
87+
content = @Content(mediaType = "application/json",
88+
schema = @Schema(implementation = MaterialHistory.class))),
89+
@ApiResponse(responseCode = "400", description = "请求失败")}
90+
)
91+
@SystemControllerLog(description = "创建MaterialHistory")
92+
@PostMapping("/material-history/create")
93+
public Result<MaterialHistory> createMaterialHistory(@Valid @RequestBody MaterialHistory materialHistory) {
94+
return materialHistoryService.createMaterialHistory(materialHistory);
95+
}
96+
97+
/**
98+
* 修改MaterialHistory信息
99+
*
100+
* @param id the id
101+
* @param materialHistory the materialHistory
102+
* @return MaterialHistory信息 result
103+
*/
104+
@Operation(summary = "修改单个MaterialHistory信息", description = "修改单个MaterialHistory信息", parameters = {
105+
@Parameter(name = "id", description = "appId"),
106+
@Parameter(name = "MaterialHistory", description = "入参对象")}, responses = {
107+
@ApiResponse(responseCode = "200", description = "返回信息",
108+
content = @Content(mediaType = "application/json",
109+
schema = @Schema(implementation = MaterialHistory.class))),
110+
@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);
116+
}
117+
118+
/**
119+
* 删除MaterialHistory信息
120+
*
121+
* @param id the id
122+
* @return app信息 result
123+
*/
124+
@Operation(summary = "删除app信息",
125+
description = "删除app信息",
126+
parameters = {
127+
@Parameter(name = "id", description = "MaterialHistory主键id")
128+
},
129+
responses = {
130+
@ApiResponse(responseCode = "200", description = "返回信息",
131+
content = @Content(mediaType = "application/json",
132+
schema = @Schema(implementation = MaterialHistory.class))),
133+
@ApiResponse(responseCode = "400", description = "请求失败")}
134+
)
135+
@SystemControllerLog(description = "删除app信息")
136+
@GetMapping("/material-history/delete/{id}")
137+
public Result<MaterialHistory> deleteMaterialHistory(@PathVariable Integer id) {
138+
return materialHistoryService.deleteMaterialHistoryById(id);
139+
}
140+
141+
/**
142+
* 获取应用信息详情
143+
*
144+
* @param id the id
145+
* @return the result
146+
*/
147+
@Operation(summary = "获取应用信息详情", description = "获取应用信息详情", parameters = {
148+
@Parameter(name = "id", description = "appId")}, responses = {
149+
@ApiResponse(responseCode = "200", description = "返回信息",
150+
content = @Content(mediaType = "application/json",
151+
schema = @Schema(implementation = MaterialHistory.class))),
152+
@ApiResponse(responseCode = "400", description = "请求失败")})
153+
@SystemControllerLog(description = "获取应用信息详情")
154+
@GetMapping("/material-history/detail/{id}")
155+
public Result<MaterialHistory> detail(@PathVariable Integer id) {
156+
return materialHistoryService.findMaterialHistoryById(id);
157+
}
158+
}

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/**
22
* Copyright (c) 2023 - present TinyEngine Authors.
33
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
4-
*
4+
* <p>
55
* Use of this source code is governed by an MIT-style license.
6-
*
6+
* <p>
77
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
88
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
99
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10-
*
1110
*/
1211

1312
package com.tinyengine.it.controller;
@@ -71,8 +70,8 @@ public class PageController {
7170
* @return allpage
7271
*/
7372
@Operation(summary = "获取页面列表", description = "获取页面列表", parameters = {
74-
@Parameter(name = "aid", description = "appId")}, responses = {
75-
@ApiResponse(responseCode = "200", description = "返回信息",
73+
@Parameter(name = "aid", description = "appId")}, responses = {
74+
@ApiResponse(responseCode = "200", description = "返回信息",
7675
content = @Content(mediaType = "application/json",
7776
schema = @Schema(implementation = Page.class))),
7877
@ApiResponse(responseCode = "400", description = "请求失败")})
@@ -207,8 +206,8 @@ public Result<PreviewDto> previewData(@ModelAttribute PreviewParam previewParam)
207206
@ApiResponse(responseCode = "400", description = "请求失败")})
208207
@SystemControllerLog(description = "页面发布")
209208
@PostMapping("/pages/deploy")
210-
public Result<Integer> pageDeploy(@RequestBody PageHistory pageHistory) {
211-
Integer result = pageHistoryService.createPageHistory(pageHistory);
212-
return Result.success(result);
209+
public Result<PageHistory> pageDeploy(@RequestBody PageHistory pageHistory) {
210+
pageHistoryService.createPageHistory(pageHistory);
211+
return Result.success(pageHistory);
213212
}
214213
}

0 commit comments

Comments
 (0)