AI不追问,组件新增旋转轴字段
This commit is contained in:
@@ -59,7 +59,9 @@ JSON 请求设置 `Content-Type: application/json`。当前没有登录认证,
|
||||
| 已有组件替换模型 | `{"componentId":123}` |
|
||||
| 原会话签名到期后续签 | `{"uploadSessionToken":"原令牌"}` |
|
||||
|
||||
新增无需组件编码。后端生成 `CW-` 加无连字符的大写 UUID,例如 `CW-0123456789ABCDEF0123456789ABCDEF`,申请签名不创建组件记录。编辑使用原编码,生成新的上传批次;组件不存在返回 404。
|
||||
新增无需组件编码。后端生成 `CW-` 加 16 位随机字符,总长 19,例如 `CW-7K3M9Q2R6V8X4T5N`。随机字符使用数字及大写字母,排除容易混淆的 `I/L/O/U`;使用密码学安全随机数生成,具有 80 位随机空间,保存时仍由 `component_code` 唯一索引约束。申请签名不创建组件记录。编辑使用原编码,生成新的上传批次;组件不存在返回 404。
|
||||
|
||||
旧版 `CW-` 加 32 位大写十六进制字符的组件编码和上传会话继续有效,包括升级前申请、尚未保存的上传会话。已有组件不重编码,资源目录保持原编码;前端必须直接使用接口返回的编码,不能假定固定为 35 字符。
|
||||
|
||||
续签不能同时提交 `componentId`。续签验证签名、有效期、操作人、环境及绑定组件,保持原编码、批次、令牌和目录。默认会话有效期 30 分钟、OSS 授权有效期 5 分钟;授权不超过会话到期时间,续签不延长会话。
|
||||
|
||||
@@ -73,13 +75,13 @@ JSON 请求设置 `Content-Type: application/json`。当前没有登录认证,
|
||||
"message":"success",
|
||||
"requestId":"请求编号",
|
||||
"data":{
|
||||
"componentCode":"CW-0123456789ABCDEF0123456789ABCDEF",
|
||||
"componentCode":"CW-7K3M9Q2R6V8X4T5N",
|
||||
"uploadSessionToken":"组件上传令牌",
|
||||
"sessionExpiresAt":"2026-10-10T08:30:00Z",
|
||||
"expiresAt":"2026-10-10T08:05:00Z",
|
||||
"step":{
|
||||
"uploadUrl":"https://linkerbot.oss-cn-beijing.aliyuncs.com/",
|
||||
"keyPrefix":"cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/step/abcdef0123456789abcdef0123456789/",
|
||||
"keyPrefix":"cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/step/abcdef0123456789abcdef0123456789/",
|
||||
"uploadMethod":"POST",
|
||||
"uploadFields":{
|
||||
"x-oss-signature-version":"OSS4-HMAC-SHA256",
|
||||
@@ -93,7 +95,7 @@ JSON 请求设置 `Content-Type: application/json`。当前没有登录认证,
|
||||
},
|
||||
"urdf":{
|
||||
"uploadUrl":"https://linkerbot.oss-cn-beijing.aliyuncs.com/",
|
||||
"keyPrefix":"cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/urdf/abcdef0123456789abcdef0123456789/",
|
||||
"keyPrefix":"cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/urdf/abcdef0123456789abcdef0123456789/",
|
||||
"uploadMethod":"POST",
|
||||
"uploadFields":{
|
||||
"x-oss-signature-version":"OSS4-HMAC-SHA256",
|
||||
@@ -142,6 +144,7 @@ POST 和 PUT 使用扁平 JSON。新增业务字段仅 `stepObjectKey` 必填,
|
||||
| material | string | 默认 `""`,最多 128 字符 |
|
||||
| massKg | number | 默认 0,千克,非负 |
|
||||
| degreesOfFreedom | integer | 默认 0,范围 0 至 2147483647,仅接受 JSON 整数,不接受小数或字符串 |
|
||||
| rotationAxis | string / null | 可选,默认 null;仅接受大写 `X`、`Y`、`Z`,不接受空字符串、小写或数字 |
|
||||
| functionDescription | string | 默认 `""`,最多 512 字符 |
|
||||
| shape | string | 默认 `""`,最多 128 字符 |
|
||||
| size | string | 默认 `""`,最多 128 字符,大小描述,可包含单位 |
|
||||
@@ -168,6 +171,8 @@ POST 和 PUT 使用扁平 JSON。新增业务字段仅 `stepObjectKey` 必填,
|
||||
|
||||
PUT 是全量表单更新,前端应提交完整表单,每次都必须提交 `urdfInfo`。省略可选字段会恢复默认值,提交空数组可清空 BOM 或自定义字段。
|
||||
|
||||
`rotationAxis` 对应数据库 `rotation_axis`,下拉选项值使用 `X`、`Y`、`Z`;未设置时返回 null。PUT 省略该字段或传 null 会清空已有旋转轴。该字段是组件元数据,不替代 `urdfInfo` 中每个关节的 axis。
|
||||
|
||||
### 4.2 保存时的资源校验
|
||||
|
||||
新增必须提交 STEP,URDF 可选,`urdfObjectKeys` 省略、为 null 或空数组均表示未上传 URDF;此时 `urdfPrefix`、`urdfMainObjectKey` 保存为 `""`,`urdfFiles` 保存为 `[]`。修改可只替换一种,未提交的资源保持原引用。文件引用只能来自当前操作人、当前组件的有效令牌和对应目录。
|
||||
@@ -178,6 +183,19 @@ PUT 是全量表单更新,前端应提交完整表单,每次都必须提交
|
||||
|
||||
检查全部通过才写数据库。失败不切换原资源引用。旧批次、上传后未保存及删除组件后的文件暂不自动清理。校验覆盖清单的结构和对象存在性,不解析 URDF XML 内部的依赖引用。
|
||||
|
||||
### 4.3 旋转轴字段部署
|
||||
|
||||
部署管理端和用户端新代码前,在两端使用的组件数据库中执行以下 SQL。已有记录保持 null,应用不会自动执行迁移;仓库 `.sql` 文件不修改。
|
||||
|
||||
```sql
|
||||
ALTER TABLE `component`
|
||||
ADD COLUMN `rotation_axis` ENUM('X','Y','Z')
|
||||
CHARACTER SET ascii COLLATE ascii_bin
|
||||
NULL DEFAULT NULL
|
||||
COMMENT '旋转轴:X、Y、Z;NULL表示未设置'
|
||||
AFTER `degrees_of_freedom`;
|
||||
```
|
||||
|
||||
## 5. 组件接口
|
||||
|
||||
### 5.1 新增
|
||||
@@ -187,11 +205,11 @@ PUT 是全量表单更新,前端应提交完整表单,每次都必须提交
|
||||
```json
|
||||
{
|
||||
"uploadSessionToken":"签名接口返回的令牌",
|
||||
"stepObjectKey":"cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/step/abcdef0123456789abcdef0123456789/model.step"
|
||||
"stepObjectKey":"cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/step/abcdef0123456789abcdef0123456789/model.step"
|
||||
}
|
||||
```
|
||||
|
||||
其余业务字段按默认值保存,无需修改现有组件表结构;`bomList`、`urdfInfo` 虽为 NOT NULL,后端会显式写入空数组。需要填写元数据或上传 URDF 时,可提交完整请求:
|
||||
其余业务字段按默认值保存;`bomList`、`urdfInfo` 虽为 NOT NULL,后端会显式写入空数组。部署前须完成上面的旋转轴字段迁移。需要填写元数据或上传 URDF 时,可提交完整请求:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -201,6 +219,7 @@ PUT 是全量表单更新,前端应提交完整表单,每次都必须提交
|
||||
"material":"铝合金",
|
||||
"massKg":0.35,
|
||||
"degreesOfFreedom":0,
|
||||
"rotationAxis":"Z",
|
||||
"functionDescription":"固定机械组件",
|
||||
"shape":"平板",
|
||||
"size":"120 × 80 × 8 mm",
|
||||
@@ -210,10 +229,10 @@ PUT 是全量表单更新,前端应提交完整表单,每次都必须提交
|
||||
"basicFields":[{"name":"供应商型号","value":"L20-RIGHT"}],
|
||||
"parameterFields":[{"name":"额定电压","value":"24V"}],
|
||||
"uploadSessionToken":"签名接口返回的令牌",
|
||||
"stepObjectKey":"cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/step/abcdef0123456789abcdef0123456789/model.step",
|
||||
"stepObjectKey":"cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/step/abcdef0123456789abcdef0123456789/model.step",
|
||||
"urdfObjectKeys":[
|
||||
"cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/urdf/abcdef0123456789abcdef0123456789/robot.urdf",
|
||||
"cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/urdf/abcdef0123456789abcdef0123456789/meshes/base.stl"
|
||||
"cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/urdf/abcdef0123456789abcdef0123456789/robot.urdf",
|
||||
"cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/urdf/abcdef0123456789abcdef0123456789/meshes/base.stl"
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -227,13 +246,14 @@ PUT 是全量表单更新,前端应提交完整表单,每次都必须提交
|
||||
```json
|
||||
{
|
||||
"id":123,
|
||||
"componentCode":"CW-0123456789ABCDEF0123456789ABCDEF",
|
||||
"componentCode":"CW-7K3M9Q2R6V8X4T5N",
|
||||
"componentName":"四孔安装板",
|
||||
"category":"安装板",
|
||||
"description":"用于固定机械组件",
|
||||
"material":"铝合金",
|
||||
"massKg":0.35,
|
||||
"degreesOfFreedom":0,
|
||||
"rotationAxis":"Z",
|
||||
"functionDescription":"固定机械组件",
|
||||
"shape":"平板",
|
||||
"size":"120 × 80 × 8 mm",
|
||||
@@ -242,12 +262,12 @@ PUT 是全量表单更新,前端应提交完整表单,每次都必须提交
|
||||
"urdfInfo":{"robotName":"mounting_plate","links":[{"name":"base_link"}]},
|
||||
"basicFields":[{"name":"供应商型号","value":"L20-RIGHT"}],
|
||||
"parameterFields":[{"name":"额定电压","value":"24V"}],
|
||||
"stepObjectKey":"cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/step/abcdef0123456789abcdef0123456789/model.step",
|
||||
"stepUrl":"http://127.0.0.1:8992/admin-api/component-assets/cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/step/abcdef0123456789abcdef0123456789/model.step",
|
||||
"urdfPrefix":"cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/urdf/abcdef0123456789abcdef0123456789/",
|
||||
"urdfBaseUrl":"http://127.0.0.1:8992/admin-api/component-assets/cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/urdf/abcdef0123456789abcdef0123456789/",
|
||||
"urdfMainObjectKey":"cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/urdf/abcdef0123456789abcdef0123456789/robot.urdf",
|
||||
"urdfUrl":"http://127.0.0.1:8992/admin-api/component-assets/cadworld_dev/components/CW-0123456789ABCDEF0123456789ABCDEF/urdf/abcdef0123456789abcdef0123456789/robot.urdf",
|
||||
"stepObjectKey":"cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/step/abcdef0123456789abcdef0123456789/model.step",
|
||||
"stepUrl":"http://127.0.0.1:8992/admin-api/component-assets/cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/step/abcdef0123456789abcdef0123456789/model.step",
|
||||
"urdfPrefix":"cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/urdf/abcdef0123456789abcdef0123456789/",
|
||||
"urdfBaseUrl":"http://127.0.0.1:8992/admin-api/component-assets/cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/urdf/abcdef0123456789abcdef0123456789/",
|
||||
"urdfMainObjectKey":"cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/urdf/abcdef0123456789abcdef0123456789/robot.urdf",
|
||||
"urdfUrl":"http://127.0.0.1:8992/admin-api/component-assets/cadworld_dev/components/CW-7K3M9Q2R6V8X4T5N/urdf/abcdef0123456789abcdef0123456789/robot.urdf",
|
||||
"urdfFiles":[{"relativePath":"robot.urdf","sizeBytes":4200},{"relativePath":"meshes/base.stl","sizeBytes":15000}],
|
||||
"version":1,
|
||||
"createdAt":"2026-10-10T16:01:00.123",
|
||||
@@ -270,6 +290,7 @@ PUT 是全量表单更新,前端应提交完整表单,每次都必须提交
|
||||
"material":"铝合金",
|
||||
"massKg":0.35,
|
||||
"degreesOfFreedom":0,
|
||||
"rotationAxis":"Z",
|
||||
"functionDescription":"固定机械组件",
|
||||
"shape":"平板",
|
||||
"size":"120 × 80 × 8 mm",
|
||||
@@ -304,7 +325,7 @@ PUT 是全量表单更新,前端应提交完整表单,每次都必须提交
|
||||
| keyword | 名称或编码模糊查询 |
|
||||
| category | 分类精确筛选 |
|
||||
|
||||
`items` 每项包含 `id`、`componentCode`、`componentName`、`category`、`description`、`degreesOfFreedom`、`functionDescription`、`shape`、`size`、`torqueNm`、`stepUrl`、`urdfUrl`、`version`、`createdAt`、`updatedAt`。列表不查询或返回 `bomList`、`urdfInfo`、自定义表单和 URDF 文件清单。编辑先获取详情;创建和修改成功返回的详情包含全部七个新增字段。
|
||||
`items` 每项包含 `id`、`componentCode`、`componentName`、`category`、`description`、`degreesOfFreedom`、`rotationAxis`、`functionDescription`、`shape`、`size`、`torqueNm`、`stepUrl`、`urdfUrl`、`version`、`createdAt`、`updatedAt`。列表不查询或返回 `bomList`、`urdfInfo`、自定义表单和 URDF 文件清单。编辑先获取详情;创建和修改成功返回完整组件详情,包含旋转轴。
|
||||
|
||||
列表查询参数 `size` 是每页条数,响应 `items` 内的 `size` 是组件大小描述。
|
||||
|
||||
@@ -409,7 +430,7 @@ async function uploadAndSave(formValues, stepFile, urdfFiles, component = null)
|
||||
// formValues 只含完整表单字段,不包含详情里的资源 URL、Key 或维护字段。
|
||||
const saved = await uploadAndSave({
|
||||
componentName: '四孔安装板', category: '安装板',
|
||||
description: '', material: '铝合金', massKg: 0, degreesOfFreedom: 0,
|
||||
description: '', material: '铝合金', massKg: 0, degreesOfFreedom: 0, rotationAxis: 'Z',
|
||||
functionDescription: '固定机械组件', shape: '平板', size: '120 × 80 × 8 mm',
|
||||
torqueNm: 0, bomList: [], urdfInfo: {}, basicFields: [], parameterFields: []
|
||||
}, document.querySelector('#step').files[0], document.querySelector('#urdf').files);
|
||||
@@ -463,7 +484,7 @@ POST / PUT 请求:
|
||||
"action":"DELETE",
|
||||
"targetType":"COMPONENT",
|
||||
"targetId":"123",
|
||||
"targetCode":"CW-0123456789ABCDEF0123456789ABCDEF",
|
||||
"targetCode":"CW-7K3M9Q2R6V8X4T5N",
|
||||
"targetName":"四孔安装板",
|
||||
"operatorId":0,
|
||||
"operatorName":"TEST_OPERATOR",
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -67,7 +69,7 @@ class AdminApiTest {
|
||||
@Test
|
||||
void oneSignatureEndpointGeneratesCodeWithoutDatabaseRecordAndRenewsSameBatch() throws Exception {
|
||||
JsonNode first = sign(Map.of());
|
||||
assertThat(first.path("componentCode").asText()).matches("CW-[A-F0-9]{32}");
|
||||
assertThat(first.path("componentCode").asText()).matches("CW-[0-9A-HJKMNP-TV-Z]{16}");
|
||||
String step = first.path("step").path("keyPrefix").asText();
|
||||
String urdf = first.path("urdf").path("keyPrefix").asText();
|
||||
assertThat(step).startsWith("cadworld_dev/components/" + first.path("componentCode").asText() + "/step/");
|
||||
@@ -89,6 +91,31 @@ class AdminApiTest {
|
||||
.content("{\"componentId\":999}")).andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@Test
|
||||
void legacyUploadSessionCanRenewCreateAndEditWithoutChangingCode() throws Exception {
|
||||
String code = "CW-0123456789ABCDEF0123456789ABCDEF";
|
||||
String batch = "abcdef0123456789abcdef0123456789";
|
||||
String prefix = "cadworld_dev/components/" + code;
|
||||
UploadSessionClaims session = new UploadSessionClaims(0L, null, code, batch,
|
||||
prefix + "/step/" + batch + "/", prefix + "/urdf/" + batch + "/",
|
||||
Instant.now().plusSeconds(300));
|
||||
String token = tokens.generateToken(session);
|
||||
JsonNode renewed = sign(Map.of("uploadSessionToken", token));
|
||||
assertThat(renewed.path("componentCode").asText()).isEqualTo(code);
|
||||
assertThat(renewed.path("uploadSessionToken").asText()).isEqualTo(token);
|
||||
assertThat(renewed.path("step").path("keyPrefix").asText()).isEqualTo(session.stepPrefix());
|
||||
|
||||
String step = session.stepPrefix() + "model.STEP";
|
||||
storage.simulateDirectUpload(step, "application/octet-stream", new byte[]{1, 2});
|
||||
JsonNode created = create(Map.of("uploadSessionToken", token, "stepObjectKey", step));
|
||||
assertThat(created.path("componentCode").asText()).isEqualTo(code);
|
||||
JsonNode editing = sign(Map.of("componentId", created.path("id").asLong()));
|
||||
assertThat(editing.path("componentCode").asText()).isEqualTo(code);
|
||||
assertThat(editing.path("step").path("keyPrefix").asText()).isNotEqualTo(session.stepPrefix());
|
||||
JsonNode editingRenewed = sign(Map.of("uploadSessionToken", editing.path("uploadSessionToken").asText()));
|
||||
assertThat(editingRenewed.path("componentCode").asText()).isEqualTo(code);
|
||||
}
|
||||
|
||||
@Test
|
||||
void componentDefaultsSearchUrlsAndDuplicateNamesMatchNewSchema() throws Exception {
|
||||
Map<String,Object> body = uploaded();
|
||||
@@ -191,10 +218,53 @@ class AdminApiTest {
|
||||
.isEqualTo(changed);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"X", "Y", "Z"})
|
||||
void rotationAxisRoundTripsThroughCreateUpdateDetailAndList(String axis) throws Exception {
|
||||
Map<String, Object> body = uploaded();
|
||||
body.put("rotationAxis", axis);
|
||||
JsonNode created = create(body);
|
||||
long id = created.path("id").asLong();
|
||||
assertThat(created.path("rotationAxis").asText()).isEqualTo(axis);
|
||||
assertThat(jdbc.queryForObject("SELECT rotation_axis FROM component WHERE id=?", String.class, id)).isEqualTo(axis);
|
||||
mvc.perform(get("/admin-api/components/{id}", id)).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.rotationAxis").value(axis));
|
||||
mvc.perform(get("/admin-api/components").param("keyword", created.path("componentCode").asText()))
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.data.items[0].rotationAxis").value(axis));
|
||||
String nextAxis = "X".equals(axis) ? "Y" : "X";
|
||||
Map<String, Object> form = update(1);
|
||||
form.put("rotationAxis", nextAxis);
|
||||
JsonNode changed = data(mvc.perform(put("/admin-api/components/{id}", id).contentType(MediaType.APPLICATION_JSON)
|
||||
.content(json.writeValueAsString(form))).andExpect(status().isOk()).andReturn());
|
||||
assertThat(changed.path("rotationAxis").asText()).isEqualTo(nextAxis);
|
||||
assertThat(componentMapper.selectById(id).getRotationAxis().name()).isEqualTo(nextAxis);
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidRotationAxisValuesNeverCreateOrUpdateComponents() throws Exception {
|
||||
Map<String, Object> original = uploaded();
|
||||
original.put("rotationAxis", "Z");
|
||||
long id = create(original).path("id").asLong();
|
||||
Map<String, Object> body = uploaded();
|
||||
Map<String, Object> form = update(1);
|
||||
for (Object invalid : List.of("", "x", " X ", "XY", "A", 0, 1, 2, true, List.of("X"), Map.of("axis", "X"))) {
|
||||
body.put("rotationAxis", invalid);
|
||||
form.put("rotationAxis", invalid);
|
||||
expectCreateError(body, 422, "INVALID_REQUEST");
|
||||
mvc.perform(put("/admin-api/components/{id}", id).contentType(MediaType.APPLICATION_JSON)
|
||||
.content(json.writeValueAsString(form))).andExpect(status().isUnprocessableEntity())
|
||||
.andExpect(jsonPath("$.code").value("INVALID_REQUEST"));
|
||||
}
|
||||
assertThat(count("component")).isEqualTo(1);
|
||||
assertThat(componentMapper.selectById(id).getRotationAxis().name()).isEqualTo("Z");
|
||||
assertThat(componentMapper.selectById(id).getVersion()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void fullUpdateRestoresDefaultsForOmittedAndExplicitNullFields() throws Exception {
|
||||
Map<String,Object> body = uploaded();
|
||||
body.put("degreesOfFreedom", 3);
|
||||
body.put("rotationAxis", "Z");
|
||||
body.put("functionDescription", "固定");
|
||||
body.put("shape", "圆形");
|
||||
body.put("size", "大型");
|
||||
@@ -203,7 +273,7 @@ class AdminApiTest {
|
||||
JsonNode created = create(body);
|
||||
long id = created.path("id").asLong();
|
||||
Map<String,Object> form = update(1);
|
||||
for (String field : List.of("degreesOfFreedom", "functionDescription", "shape", "size", "torqueNm", "bomList")) {
|
||||
for (String field : List.of("degreesOfFreedom", "rotationAxis", "functionDescription", "shape", "size", "torqueNm", "bomList")) {
|
||||
form.put(field, json.nullNode());
|
||||
}
|
||||
JsonNode cleared = data(mvc.perform(put("/admin-api/components/{id}", id).contentType(MediaType.APPLICATION_JSON)
|
||||
@@ -211,6 +281,7 @@ class AdminApiTest {
|
||||
assertComponentDefaults(cleared);
|
||||
Component stored = componentMapper.selectById(id);
|
||||
assertThat(stored.getDegreesOfFreedom()).isZero();
|
||||
assertThat(stored.getRotationAxis()).isNull();
|
||||
assertThat(stored.getFunctionDescription()).isEmpty();
|
||||
assertThat(stored.getShape()).isEmpty();
|
||||
assertThat(stored.getSize()).isEmpty();
|
||||
@@ -219,6 +290,7 @@ class AdminApiTest {
|
||||
|
||||
body = uploaded();
|
||||
body.put("degreesOfFreedom", 3);
|
||||
body.put("rotationAxis", "Y");
|
||||
body.put("functionDescription", "固定");
|
||||
body.put("shape", "圆形");
|
||||
body.put("size", "大型");
|
||||
@@ -228,6 +300,7 @@ class AdminApiTest {
|
||||
JsonNode omitted = data(mvc.perform(put("/admin-api/components/{id}", otherId).contentType(MediaType.APPLICATION_JSON)
|
||||
.content(json.writeValueAsString(update(1)))).andExpect(status().isOk()).andReturn());
|
||||
assertComponentDefaults(omitted);
|
||||
assertThat(componentMapper.selectById(otherId).getRotationAxis()).isNull();
|
||||
assertThat(componentMapper.selectById(otherId).getBomList()).isEqualTo(json.createArrayNode());
|
||||
}
|
||||
|
||||
@@ -820,6 +893,8 @@ class AdminApiTest {
|
||||
return body;
|
||||
}
|
||||
void assertComponentDefaults(JsonNode response) {
|
||||
assertThat(response.has("rotationAxis")).isTrue();
|
||||
assertThat(response.get("rotationAxis").isNull()).isTrue();
|
||||
assertThat(response.get("degreesOfFreedom")).isEqualTo(json.valueToTree(0));
|
||||
for (String field : List.of("functionDescription", "shape", "size")) {
|
||||
assertThat(response.get(field)).isEqualTo(json.valueToTree(""));
|
||||
|
||||
@@ -19,6 +19,7 @@ final class TestSchemaSupport {
|
||||
material VARCHAR(128) NOT NULL DEFAULT '',
|
||||
mass_kg DECIMAL(18,6) NOT NULL DEFAULT 0,
|
||||
degrees_of_freedom INT NOT NULL DEFAULT 0 COMMENT '自由度,非负整数',
|
||||
rotation_axis CHAR(1) DEFAULT NULL CHECK (rotation_axis IN ('X','Y','Z')) COMMENT '旋转轴:X、Y、Z;NULL表示未设置',
|
||||
function_description VARCHAR(512) NOT NULL DEFAULT '' COMMENT '组件功能描述',
|
||||
shape VARCHAR(128) NOT NULL DEFAULT '' COMMENT '组件形状描述',
|
||||
size VARCHAR(128) NOT NULL DEFAULT '' COMMENT '组件大小描述',
|
||||
|
||||
Reference in New Issue
Block a user