diff --git a/README.md b/README.md index 3e4ef51..012e8a1 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,13 @@ Java 21 / Spring Boot 3.4.4 / MyBatis-Plus 后台多模块项目。后台只保 运行代码只访问 `component`、`sys_user`、`sys_operation_log` 三张业务表。使用已重建的组件表和通用操作日志表;`sys_user` 结构和用户管理行为保持不变。 -组件存储基本信息、零件参数、两组自定义字段、STEP 对象键、URDF 目录及实际文件清单、`version`、`deleted` 删除标记和维护时间。通用日志存储模块、动作、目标快照、操作人、请求元信息和结果,不依赖组件专属列。 +组件存储基本信息、自由度、功能、形状、大小描述、扭矩、BOM 清单、URDF 信息、两组自定义字段、STEP 对象键、URDF 目录及实际文件清单、`version`、`deleted` 删除标记和维护时间。BOM 和 URDF 信息均为 JSON 对象或数组,创建和修改必填 `urdfInfo`;可选 `bomList` 缺失或为 null 时写入 `[]`。列表返回五个描述字段,BOM 和 URDF 信息仅在详情及保存结果中返回。通用日志存储模块、动作、目标快照、操作人、请求元信息和结果,不依赖组件专属列。 应用启动不建表、不迁移旧数据。本次未修改 `.sql` 文件;仓库中历史 SQL 不代表当前组件和日志结构,请使用已经建好的表。MySQL 需支持现有建表语句中的 JSON / TEXT 表达式默认值。 组件名称允许重复,编码唯一且不可修改。组件和用户均逻辑删除;已删除组件的编码和已删除用户的手机号仍被占用。组件替换资源或逻辑删除均不自动删除 OSS 文件。 -部署前需为 `component` 表添加 `deleted TINYINT UNSIGNED NOT NULL DEFAULT 0` 字段,中文注释为“删除标记:0-未删除,1-已删除”。已有记录默认未删除;运行代码通过 MyBatis-Plus 自动过滤已删除组件,列表、详情、修改和编辑上传签名均只处理未删除记录。 +现有 `component` 表包含 `deleted TINYINT UNSIGNED NOT NULL DEFAULT 0` 字段,中文注释为“删除标记:0-未删除,1-已删除”。运行代码通过 MyBatis-Plus 自动过滤已删除组件,列表、详情、修改和编辑上传签名均只处理未删除记录。 ## 配置与启动 diff --git a/cadworld-adminapi/docs/admin-api.md b/cadworld-adminapi/docs/admin-api.md index d0fef4e..3c4d82c 100644 --- a/cadworld-adminapi/docs/admin-api.md +++ b/cadworld-adminapi/docs/admin-api.md @@ -134,16 +134,22 @@ POST 和 PUT 使用扁平 JSON,字段约定相同: | --- | --- | --- | | componentName | string | 必填,非空,最多 128 字符,允许同名 | | category | string | 必填,非空,最多 64 字符,自由分类 | -| manufacturer | string | 默认 `""`,最多 128 字符 | | description | string | 默认 `""`,UTF-8 不超过 65535 字节 | | material | string | 默认 `""`,最多 128 字符 | | massKg | number | 默认 0,千克,非负 | -| lengthMm / widthMm / heightMm | number | 默认 0,毫米,非负 | -| tags | string[] | 默认 `[]`,裁剪首尾空白,移除空字符串及重复标签 | +| degreesOfFreedom | integer | 默认 0,范围 0 至 2147483647,仅接受 JSON 整数,不接受小数或字符串 | +| functionDescription | string | 默认 `""`,最多 512 字符 | +| shape | string | 默认 `""`,最多 128 字符 | +| size | string | 默认 `""`,最多 128 字符,大小描述,可包含单位 | +| torqueNm | number | 默认 0,单位 N·m,非负 | +| bomList | JSON 对象或数组 | 默认 `[]`,内部结构自由 | +| urdfInfo | JSON 对象或数组 | POST / PUT 均必填,内部结构自由,允许 `{}` 或 `[]` | | basicFields | 自定义字段数组 | 默认 `[]`,基本信息扩展字段 | | parameterFields | 自定义字段数组 | 默认 `[]`,零件参数扩展字段 | -质量和尺寸最多 12 位整数、6 位小数,与 `DECIMAL(18,6)` 一致;不要提交单位文本。可选字段省略或传 null 会恢复默认值。名称、分类、厂商、材质会裁剪首尾空白。 +质量和扭矩最多 12 位整数、6 位小数,与 `DECIMAL(18,6)` 一致;不要在数值中提交单位文本。可选字段省略或传 null 会恢复默认值。名称、分类、材质、功能、形状和大小会裁剪首尾空白。 + +`bomList` 和 `urdfInfo` 直接提交 JSON 对象或数组,不接受字符串化的 JSON、数字或布尔值。`bomList` 省略或为 null 时保存为空数组;`urdfInfo` 省略或为 null 时返回 422。两者内部字段不做固定结构校验,`urdfInfo` 由前端提供,不由后端解析 URDF 文件生成。 自定义字段格式: @@ -156,7 +162,7 @@ POST 和 PUT 使用扁平 JSON,字段约定相同: 每组最多 100 项,名称非空且最多 64 字符,值为非 null 字符串、最多 2000 字符,可以为空字符串。同组名称裁剪后不可重复,两组之间可以重名;顺序与请求一致。 -PUT 是全量表单更新,前端应提交完整表单。省略可选字段会恢复默认值,提交空数组可清空标签或自定义字段。 +PUT 是全量表单更新,前端应提交完整表单,每次都必须提交 `urdfInfo`。省略可选字段会恢复默认值,提交空数组可清空 BOM 或自定义字段。 ### 4.2 保存时的资源校验 @@ -178,14 +184,16 @@ PUT 是全量表单更新,前端应提交完整表单。省略可选字段会 { "componentName":"四孔安装板", "category":"安装板", - "manufacturer":"Linkerbot", "description":"用于固定机械组件", "material":"铝合金", "massKg":0.35, - "lengthMm":120, - "widthMm":80, - "heightMm":8, - "tags":["安装板","轻量化"], + "degreesOfFreedom":0, + "functionDescription":"固定机械组件", + "shape":"平板", + "size":"120 × 80 × 8 mm", + "torqueNm":0, + "bomList":[{"componentCode":"PART-001","name":"安装螺钉","quantity":4}], + "urdfInfo":{"robotName":"mounting_plate","links":[{"name":"base_link"}]}, "basicFields":[{"name":"供应商型号","value":"L20-RIGHT"}], "parameterFields":[{"name":"额定电压","value":"24V"}], "uploadSessionToken":"签名接口返回的令牌", @@ -209,14 +217,16 @@ PUT 是全量表单更新,前端应提交完整表单。省略可选字段会 "componentCode":"CW-0123456789ABCDEF0123456789ABCDEF", "componentName":"四孔安装板", "category":"安装板", - "manufacturer":"Linkerbot", "description":"用于固定机械组件", "material":"铝合金", "massKg":0.35, - "lengthMm":120, - "widthMm":80, - "heightMm":8, - "tags":["安装板","轻量化"], + "degreesOfFreedom":0, + "functionDescription":"固定机械组件", + "shape":"平板", + "size":"120 × 80 × 8 mm", + "torqueNm":0, + "bomList":[{"componentCode":"PART-001","name":"安装螺钉","quantity":4}], + "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", @@ -243,14 +253,16 @@ PUT 是全量表单更新,前端应提交完整表单。省略可选字段会 "version":1, "componentName":"四孔安装板 V2", "category":"安装板", - "manufacturer":"Linkerbot", "description":"更新说明", "material":"铝合金", "massKg":0.35, - "lengthMm":120, - "widthMm":80, - "heightMm":8, - "tags":[], + "degreesOfFreedom":0, + "functionDescription":"固定机械组件", + "shape":"平板", + "size":"120 × 80 × 8 mm", + "torqueNm":0, + "bomList":[], + "urdfInfo":{"robotName":"mounting_plate","links":[{"name":"base_link"}]}, "basicFields":[], "parameterFields":[{"name":"额定电压","value":"24V"}] } @@ -279,7 +291,9 @@ PUT 是全量表单更新,前端应提交完整表单。省略可选字段会 | keyword | 名称或编码模糊查询 | | category | 分类精确筛选 | -`items` 每项包含 `id`、`componentCode`、`componentName`、`category`、`manufacturer`、`description`、`tags`、`stepUrl`、`urdfUrl`、`version`、`createdAt`、`updatedAt`,不返回自定义表单和大文件清单。编辑先获取详情。 +`items` 每项包含 `id`、`componentCode`、`componentName`、`category`、`description`、`degreesOfFreedom`、`functionDescription`、`shape`、`size`、`torqueNm`、`stepUrl`、`urdfUrl`、`version`、`createdAt`、`updatedAt`。列表不查询或返回 `bomList`、`urdfInfo`、自定义表单和 URDF 文件清单。编辑先获取详情;创建和修改成功返回的详情包含全部七个新增字段。 + +列表查询参数 `size` 是每页条数,响应 `items` 内的 `size` 是组件大小描述。 ### 5.5 删除和下载 @@ -381,9 +395,10 @@ async function uploadAndSave(formValues, stepFile, urdfFiles, component = null) // formValues 只含完整表单字段,不包含详情里的资源 URL、Key 或维护字段。 const saved = await uploadAndSave({ - componentName: '四孔安装板', category: '安装板', manufacturer: '', - description: '', material: '铝合金', massKg: 0, lengthMm: 0, widthMm: 0, - heightMm: 0, tags: [], basicFields: [], parameterFields: [] + componentName: '四孔安装板', category: '安装板', + description: '', material: '铝合金', massKg: 0, degreesOfFreedom: 0, + functionDescription: '固定机械组件', shape: '平板', size: '120 × 80 × 8 mm', + torqueNm: 0, bomList: [], urdfInfo: {}, basicFields: [], parameterFields: [] }, document.querySelector('#step').files[0], document.querySelector('#urdf').files); // 编辑时第四个参数传 GET 详情返回的 component;未选择的资源保持原引用。 ``` diff --git a/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/AdminApiTest.java b/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/AdminApiTest.java index a5bcfc9..ad6be00 100644 --- a/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/AdminApiTest.java +++ b/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/AdminApiTest.java @@ -14,6 +14,7 @@ import com.linkerbot.cadworld.mapper.ComponentMapper; import com.linkerbot.cadworld.service.OperationLogService; import com.linkerbot.cadworld.service.support.ComponentUploadSessionTokenProvider; import com.linkerbot.cadworld.service.support.ComponentUploadSessionTokenProvider.UploadSessionClaims; +import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.time.Instant; import java.time.LocalDateTime; @@ -91,15 +92,15 @@ class AdminApiTest { @Test void componentDefaultsSearchUrlsAndDuplicateNamesMatchNewSchema() throws Exception { Map body = uploaded(); - body.put("manufacturer", null); - body.put("tags", List.of(" 安装板 ", "", "安装板", "轻量化")); + for (String field : List.of("degreesOfFreedom", "functionDescription", "shape", "size", "torqueNm", "bomList")) { + body.put(field, null); + } body.put("basicFields", List.of(Map.of("name", " 额定电压 ", "value", "24V"))); JsonNode created = create(body); - assertThat(created.path("manufacturer").asText()).isEmpty(); assertThat(created.path("massKg").decimalValue()).isZero(); - assertThat(created.path("lengthMm").decimalValue()).isZero(); + assertComponentDefaults(created); + assertNoRemovedComponentFields(created); assertThat(created.path("parameterFields")).isEmpty(); - assertThat(created.path("tags").toString()).isEqualTo("[\"安装板\",\"轻量化\"]"); assertThat(created.path("basicFields").get(0).path("name").asText()).isEqualTo("额定电压"); assertThat(created.path("version").asLong()).isEqualTo(1); assertThat(created.path("urdfBaseUrl").asText()).endsWith("/"); @@ -110,7 +111,9 @@ class AdminApiTest { .andExpect(status().isOk()).andExpect(jsonPath("$.data.componentCode").value(created.path("componentCode").asText())); create(uploaded()); // 同名组件允许创建,编码不同。 mvc.perform(get("/admin-api/components").param("keyword", created.path("componentCode").asText()).param("category","安装板")) - .andExpect(jsonPath("$.data.total").value(1)).andExpect(jsonPath("$.data.items[0].urdfFiles").doesNotExist()); + .andExpect(jsonPath("$.data.total").value(1)).andExpect(jsonPath("$.data.items[0].urdfFiles").doesNotExist()) + .andExpect(jsonPath("$.data.items[0].bomList").doesNotExist()) + .andExpect(jsonPath("$.data.items[0].urdfInfo").doesNotExist()); mvc.perform(get("/admin-api/components").param("category","其他")) .andExpect(jsonPath("$.data.total").value(0)); mvc.perform(get("/admin-api/components").param("size","101")) @@ -120,6 +123,198 @@ class AdminApiTest { .containsExactlyInAnyOrder("COMPONENT","SYS_USER","SYS_OPERATION_LOG"); } + @Test + void componentFieldsAndNestedJsonRoundTripWhileListOnlyReturnsDescriptions() throws Exception { + Map body = uploaded(); + body.put("degreesOfFreedom", 6); + body.put("functionDescription", " 搬运和抓取 "); + body.put("shape", " 圆柱形 "); + body.put("size", " 120 × 80 × 8 mm "); + body.put("torqueNm", new BigDecimal("20.125000")); + Map bom = Map.of("items", List.of(Map.of("componentCode", "PART-001", "quantity", 2)), "revision", 1); + Map urdf = Map.of("robot", "test", "links", List.of(Map.of("name", "base", "origin", List.of(0, 0, 0)))); + body.put("bomList", bom); + body.put("urdfInfo", urdf); + JsonNode created = create(body); + long id = created.path("id").asLong(); + assertThat(created.path("degreesOfFreedom").asInt()).isEqualTo(6); + assertThat(created.path("functionDescription").asText()).isEqualTo("搬运和抓取"); + assertThat(created.path("shape").asText()).isEqualTo("圆柱形"); + assertThat(created.path("size").asText()).isEqualTo("120 × 80 × 8 mm"); + assertThat(created.path("torqueNm").decimalValue()).isEqualByComparingTo("20.125000"); + assertThat(created.path("bomList")).isEqualTo(json.valueToTree(bom)); + assertThat(created.path("urdfInfo")).isEqualTo(json.valueToTree(urdf)); + assertNoRemovedComponentFields(created); + Component stored = componentMapper.selectById(id); + assertThat(stored.getDegreesOfFreedom()).isEqualTo(6); + assertThat(stored.getFunctionDescription()).isEqualTo("搬运和抓取"); + assertThat(stored.getShape()).isEqualTo("圆柱形"); + assertThat(stored.getSize()).isEqualTo("120 × 80 × 8 mm"); + assertThat(stored.getTorqueNm()).isEqualByComparingTo("20.125000"); + assertThat(stored.getBomList()).isEqualTo(json.valueToTree(bom)); + assertThat(stored.getUrdfInfo()).isEqualTo(json.valueToTree(urdf)); + JsonNode detail = data(mvc.perform(get("/admin-api/components/{id}", id)).andExpect(status().isOk()).andReturn()); + assertThat(detail).isEqualTo(created); + JsonNode item = data(mvc.perform(get("/admin-api/components").param("keyword", created.path("componentCode").asText())) + .andExpect(status().isOk()).andReturn()).path("items").get(0); + for (String field : List.of("degreesOfFreedom", "functionDescription", "shape", "size", "torqueNm")) { + assertThat(item.get(field)).as(field).isEqualTo(created.get(field)); + } + for (String field : List.of("bomList", "urdfInfo", "basicFields", "parameterFields", "urdfFiles")) { + assertThat(item.has(field)).as(field).isFalse(); + } + assertNoRemovedComponentFields(item); + + Map form = update(1); + form.put("degreesOfFreedom", 7); + form.put("functionDescription", " 旋转 "); + form.put("shape", " 方形 "); + form.put("size", " 小型 "); + form.put("torqueNm", new BigDecimal("33.5")); + List> newBom = List.of(Map.of("name", "连接件", "quantity", 3)); + List> newUrdf = List.of(Map.of("links", List.of(Map.of("name", "tool")))); + form.put("bomList", newBom); + form.put("urdfInfo", newUrdf); + 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("degreesOfFreedom").asInt()).isEqualTo(7); + assertThat(changed.path("functionDescription").asText()).isEqualTo("旋转"); + assertThat(changed.path("shape").asText()).isEqualTo("方形"); + assertThat(changed.path("size").asText()).isEqualTo("小型"); + assertThat(changed.path("torqueNm").decimalValue()).isEqualByComparingTo("33.5"); + assertThat(changed.path("bomList")).isEqualTo(json.valueToTree(newBom)); + assertThat(changed.path("urdfInfo")).isEqualTo(json.valueToTree(newUrdf)); + Component updated = componentMapper.selectById(id); + assertThat(updated.getBomList()).isEqualTo(json.valueToTree(newBom)); + assertThat(updated.getUrdfInfo()).isEqualTo(json.valueToTree(newUrdf)); + assertThat(data(mvc.perform(get("/admin-api/components/{id}", id)).andExpect(status().isOk()).andReturn())) + .isEqualTo(changed); + } + + @Test + void fullUpdateRestoresDefaultsForOmittedAndExplicitNullFields() throws Exception { + Map body = uploaded(); + body.put("degreesOfFreedom", 3); + body.put("functionDescription", "固定"); + body.put("shape", "圆形"); + body.put("size", "大型"); + body.put("torqueNm", 10); + body.put("bomList", Map.of("items", List.of("part"))); + JsonNode created = create(body); + long id = created.path("id").asLong(); + Map form = update(1); + for (String field : List.of("degreesOfFreedom", "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) + .content(json.writeValueAsString(form))).andExpect(status().isOk()).andReturn()); + assertComponentDefaults(cleared); + Component stored = componentMapper.selectById(id); + assertThat(stored.getDegreesOfFreedom()).isZero(); + assertThat(stored.getFunctionDescription()).isEmpty(); + assertThat(stored.getShape()).isEmpty(); + assertThat(stored.getSize()).isEmpty(); + assertThat(stored.getTorqueNm()).isZero(); + assertThat(stored.getBomList()).isEqualTo(json.createArrayNode()); + + body = uploaded(); + body.put("degreesOfFreedom", 3); + body.put("functionDescription", "固定"); + body.put("shape", "圆形"); + body.put("size", "大型"); + body.put("torqueNm", 10); + body.put("bomList", Map.of("items", List.of("part"))); + long otherId = create(body).path("id").asLong(); + 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).getBomList()).isEqualTo(json.createArrayNode()); + } + + @Test + void jsonFieldsRejectInvalidContainersAndUrdfInfoIsRequiredOnEverySave() throws Exception { + Map body = uploaded(); + body.remove("urdfInfo"); + expectCreateError(body, 422, "INVALID_REQUEST"); + body.put("urdfInfo", json.nullNode()); + expectCreateError(body, 422, "INVALID_COMPONENT_FORM"); + for (String field : List.of("bomList", "urdfInfo")) { + for (Object value : List.of("{\"name\":\"robot\"}", 6, true)) { + body.put("urdfInfo", Map.of()); + body.remove("bomList"); + body.put(field, value); + expectCreateError(body, 422, "INVALID_COMPONENT_FORM"); + } + } + assertThat(count("component")).isZero(); + body = uploaded(); + body.put("urdfInfo", List.of()); + body.put("bomList", json.nullNode()); + JsonNode created = create(body); + assertThat(created.path("urdfInfo")).isEqualTo(json.createArrayNode()); + assertComponentDefaults(created); + long id = created.path("id").asLong(); + Map form = update(1); + form.remove("urdfInfo"); + expectUpdateError(id, form, 422, "INVALID_REQUEST"); + form.put("urdfInfo", json.nullNode()); + expectUpdateError(id, form, 422, "INVALID_COMPONENT_FORM"); + for (String field : List.of("bomList", "urdfInfo")) { + for (Object value : List.of("[]", 1, false)) { + form.put("urdfInfo", Map.of()); + form.remove("bomList"); + form.put(field, value); + expectUpdateError(id, form, 422, "INVALID_COMPONENT_FORM"); + } + } + assertThat(componentMapper.selectById(id).getVersion()).isEqualTo(1L); + assertThat(componentMapper.selectById(id).getUrdfInfo()).isEqualTo(json.createArrayNode()); + } + + @Test + void componentNumericAndTextLimitsApplyToCreateAndUpdate() throws Exception { + long id = create(uploaded()).path("id").asLong(); + Map body = uploaded(); + Map form = update(1); + for (Object value : List.of(-1, new BigDecimal("1.5"), new BigDecimal("1.0"), "6", "six", true, List.of(1), + Map.of("value", 1), 2147483648L)) { + body.put("degreesOfFreedom", value); + form.put("degreesOfFreedom", value); + expectCreateError(body, 422, "INVALID_REQUEST"); + expectUpdateError(id, form, 422, "INVALID_REQUEST"); + } + body.remove("degreesOfFreedom"); + form.remove("degreesOfFreedom"); + for (BigDecimal value : List.of(new BigDecimal("-1"), new BigDecimal("1000000000000"), new BigDecimal("0.0000001"))) { + body.put("torqueNm", value); + form.put("torqueNm", value); + expectCreateError(body, 422, "INVALID_REQUEST"); + expectUpdateError(id, form, 422, "INVALID_REQUEST"); + } + body.remove("torqueNm"); + form.remove("torqueNm"); + for (String field : List.of("functionDescription", "shape", "size")) { + int limit = field.equals("functionDescription") ? 512 : 128; + body.put(field, "x".repeat(limit + 1)); + form.put(field, "x".repeat(limit + 1)); + expectCreateError(body, 422, "INVALID_REQUEST"); + expectUpdateError(id, form, 422, "INVALID_REQUEST"); + body.remove(field); + form.remove(field); + } + assertThat(count("component")).isEqualTo(1); + assertThat(componentMapper.selectById(id).getVersion()).isEqualTo(1L); + body.put("degreesOfFreedom", Integer.MAX_VALUE); + body.put("functionDescription", "x".repeat(512)); + body.put("shape", "x".repeat(128)); + body.put("size", "x".repeat(128)); + body.put("torqueNm", new BigDecimal("999999999999.999999")); + JsonNode boundary = create(body); + assertThat(boundary.path("degreesOfFreedom").asInt()).isEqualTo(Integer.MAX_VALUE); + assertThat(componentMapper.selectById(boundary.path("id").asLong()).getTorqueNm()) + .isEqualByComparingTo("999999999999.999999"); + } + @Test void duplicateCreationCannotReuseCodeAndCreateRequiresBothModels() throws Exception { Map body = uploaded(); @@ -362,7 +557,7 @@ class AdminApiTest { body.put("basicFields",List.of(Map.of("name","x","value","x".repeat(2001)))); expectCreateError(body,422,"INVALID_REQUEST"); body.remove("basicFields"); - for (String field : List.of("massKg","lengthMm","widthMm","heightMm")) { + for (String field : List.of("massKg","torqueNm","degreesOfFreedom")) { body.put(field,-1); expectCreateError(body,422,"INVALID_REQUEST"); body.remove(field); @@ -499,6 +694,9 @@ class AdminApiTest { } Map body = uploaded(); body.put("basicFields",List.of(Map.of("name","备注","value","PRIVATE_FIELD_VALUE"))); + body.put("bomList", Map.of("note", "PRIVATE_BOM_VALUE")); + body.put("urdfInfo", Map.of("note", "PRIVATE_URDF_VALUE")); + String uploadSessionToken = (String) body.get("uploadSessionToken"); Logger mapperLogger = (Logger) org.slf4j.LoggerFactory.getLogger("com.linkerbot.cadworld.mapper"); ListAppender capture = new ListAppender(); capture.start(); mapperLogger.addAppender(capture); @@ -506,13 +704,18 @@ class AdminApiTest { create(body); body.put("uploadSessionToken","PRIVATE_TOKEN"); expectCreateError(body,422,"INVALID_COMPONENT_UPLOAD_SESSION"); + body.put("uploadSessionToken", uploadSessionToken); + body.put("urdfInfo", "PRIVATE_URDF_VALUE"); + expectCreateError(body, 422, "INVALID_COMPONENT_FORM"); mvc.perform(get("/admin-api/users").param("keyword","13800000001")); String messages = String.join("\n",runtime.messages()); assertThat(messages).contains("description=新增组件","result=SUCCESS","result=FAILURE","durationMs="); - assertThat(messages).doesNotContain("PRIVATE_FIELD_VALUE","PRIVATE_TOKEN",body.get("stepObjectKey").toString(),"13800000001"); + assertThat(messages).doesNotContain("PRIVATE_FIELD_VALUE","PRIVATE_BOM_VALUE","PRIVATE_URDF_VALUE", + "PRIVATE_TOKEN",body.get("stepObjectKey").toString(),"13800000001"); assertThat(capture.list).isEmpty(); assertThat(jdbc.queryForList("SELECT * FROM sys_operation_log").toString()) - .doesNotContain("PRIVATE_FIELD_VALUE","PRIVATE_TOKEN",body.get("uploadSessionToken").toString(), + .doesNotContain("PRIVATE_FIELD_VALUE","PRIVATE_BOM_VALUE","PRIVATE_URDF_VALUE", + "PRIVATE_TOKEN",body.get("uploadSessionToken").toString(), "FAKE_TEST_POLICY","FAKE_TEST_SIGNATURE"); } finally { mapperLogger.detachAppender(capture); capture.stop(); } } @@ -547,6 +750,7 @@ class AdminApiTest { storage.simulateDirectUpload(mesh,"application/octet-stream",new byte[]{1,2,3}); Map body = new HashMap<>(); body.put("componentName","测试组件"); body.put("category","安装板"); + body.put("urdfInfo", Map.of()); body.put("uploadSessionToken",session.path("uploadSessionToken").asText()); body.put("stepObjectKey",step); body.put("urdfObjectKeys",List.of(main,mesh)); return body; @@ -554,8 +758,23 @@ class AdminApiTest { Map update(long version) { Map body = new HashMap<>(); body.put("componentName","修改后的组件"); body.put("category","安装板"); body.put("version",version); + body.put("urdfInfo", Map.of()); return body; } + void assertComponentDefaults(JsonNode response) { + assertThat(response.get("degreesOfFreedom")).isEqualTo(json.valueToTree(0)); + for (String field : List.of("functionDescription", "shape", "size")) { + assertThat(response.get(field)).isEqualTo(json.valueToTree("")); + } + assertThat(response.get("torqueNm")).isNotNull(); + assertThat(response.path("torqueNm").decimalValue()).isZero(); + assertThat(response.get("bomList")).isEqualTo(json.createArrayNode()); + } + void assertNoRemovedComponentFields(JsonNode response) { + for (String field : List.of("manufacturer", "lengthMm", "widthMm", "heightMm", "tags")) { + assertThat(response.has(field)).as(field).isFalse(); + } + } JsonNode create(Map body) throws Exception { return data(mvc.perform(post("/admin-api/components").contentType(MediaType.APPLICATION_JSON) .content(json.writeValueAsString(body))).andExpect(status().isOk()).andReturn()); diff --git a/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/TestSchemaSupport.java b/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/TestSchemaSupport.java index 7dd555f..bcb6b3c 100644 --- a/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/TestSchemaSupport.java +++ b/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/TestSchemaSupport.java @@ -15,14 +15,16 @@ final class TestSchemaSupport { component_code VARCHAR(64) NOT NULL DEFAULT '' UNIQUE, component_name VARCHAR(128) NOT NULL DEFAULT '', category VARCHAR(64) NOT NULL DEFAULT '', - manufacturer VARCHAR(128) NOT NULL DEFAULT '', description CLOB NOT NULL DEFAULT '', material VARCHAR(128) NOT NULL DEFAULT '', mass_kg DECIMAL(18,6) NOT NULL DEFAULT 0, - length_mm DECIMAL(18,6) NOT NULL DEFAULT 0, - width_mm DECIMAL(18,6) NOT NULL DEFAULT 0, - height_mm DECIMAL(18,6) NOT NULL DEFAULT 0, - tags CLOB NOT NULL DEFAULT '[]', + degrees_of_freedom INT NOT NULL DEFAULT 0 COMMENT '自由度,非负整数', + function_description VARCHAR(512) NOT NULL DEFAULT '' COMMENT '组件功能描述', + shape VARCHAR(128) NOT NULL DEFAULT '' COMMENT '组件形状描述', + size VARCHAR(128) NOT NULL DEFAULT '' COMMENT '组件大小描述', + torque_nm DECIMAL(18,6) NOT NULL DEFAULT 0 COMMENT '扭矩,单位牛顿米,非负', + bom_list CLOB NOT NULL COMMENT 'BOM清单,JSON对象或数组', + urdf_info CLOB NOT NULL COMMENT 'URDF信息', basic_fields CLOB NOT NULL DEFAULT '[]', parameter_fields CLOB NOT NULL DEFAULT '[]', step_object_key VARCHAR(512) NOT NULL DEFAULT '', diff --git a/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/UploadHttpTest.java b/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/UploadHttpTest.java index 8782a88..d1169d4 100644 --- a/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/UploadHttpTest.java +++ b/cadworld-adminapi/src/test/java/com/linkerbot/cadworld/UploadHttpTest.java @@ -34,7 +34,7 @@ class UploadHttpTest { storage.simulateDirectUpload(main,"application/xml",new byte[]{1}); ResponseEntity response = http.postForEntity("/admin-api/components",Map.of( "componentName","超限测试","category","安装板","uploadSessionToken",session.path("uploadSessionToken").asText(), - "stepObjectKey",step,"urdfObjectKeys",List.of(main)),String.class); + "stepObjectKey",step,"urdfObjectKeys",List.of(main),"urdfInfo",Map.of()),String.class); assertThat(response.getStatusCode().value()).isEqualTo(413); assertThat(response.getBody()).contains("UPLOAD_TOO_LARGE"); assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM component",Long.class)).isZero(); diff --git a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentForm.java b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentForm.java index 8895f98..da95bce 100644 --- a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentForm.java +++ b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentForm.java @@ -1,5 +1,6 @@ package com.linkerbot.cadworld.dto.component; +import com.fasterxml.jackson.databind.JsonNode; import java.math.BigDecimal; import java.util.List; @@ -7,14 +8,16 @@ import java.util.List; public interface ComponentForm { String componentName(); String category(); - String manufacturer(); String description(); String material(); BigDecimal massKg(); - BigDecimal lengthMm(); - BigDecimal widthMm(); - BigDecimal heightMm(); - List tags(); + Integer degreesOfFreedom(); + String functionDescription(); + String shape(); + String size(); + BigDecimal torqueNm(); + JsonNode bomList(); + JsonNode urdfInfo(); List basicFields(); List parameterFields(); } diff --git a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentListItemResponse.java b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentListItemResponse.java index e9592bd..b067e0e 100644 --- a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentListItemResponse.java +++ b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentListItemResponse.java @@ -1,10 +1,11 @@ package com.linkerbot.cadworld.dto.component; +import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.List; public record ComponentListItemResponse( - Long id, String componentCode, String componentName, String category, String manufacturer, - String description, List tags, String stepUrl, String urdfUrl, Long version, + Long id, String componentCode, String componentName, String category, + String description, Integer degreesOfFreedom, String functionDescription, String shape, + String size, BigDecimal torqueNm, String stepUrl, String urdfUrl, Long version, LocalDateTime createdAt, LocalDateTime updatedAt ) { } diff --git a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentResponse.java b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentResponse.java index 398221c..8d334e6 100644 --- a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentResponse.java +++ b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/ComponentResponse.java @@ -1,13 +1,15 @@ package com.linkerbot.cadworld.dto.component; +import com.fasterxml.jackson.databind.JsonNode; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; public record ComponentResponse( - Long id, String componentCode, String componentName, String category, String manufacturer, - String description, String material, BigDecimal massKg, BigDecimal lengthMm, BigDecimal widthMm, - BigDecimal heightMm, List tags, List basicFields, List parameterFields, + Long id, String componentCode, String componentName, String category, + String description, String material, BigDecimal massKg, Integer degreesOfFreedom, + String functionDescription, String shape, String size, BigDecimal torqueNm, JsonNode bomList, + JsonNode urdfInfo, List basicFields, List parameterFields, String stepObjectKey, String stepUrl, String urdfPrefix, String urdfBaseUrl, String urdfMainObjectKey, String urdfUrl, List urdfFiles, Long version, LocalDateTime createdAt, LocalDateTime updatedAt diff --git a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/CreateComponentRequest.java b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/CreateComponentRequest.java index 5244fa4..623130b 100644 --- a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/CreateComponentRequest.java +++ b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/CreateComponentRequest.java @@ -1,5 +1,7 @@ package com.linkerbot.cadworld.dto.component; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import jakarta.validation.Valid; import jakarta.validation.constraints.*; import java.math.BigDecimal; @@ -8,14 +10,16 @@ import java.util.List; public record CreateComponentRequest( @NotBlank @Size(max = 128) String componentName, @NotBlank @Size(max = 64) String category, - @Size(max = 128) String manufacturer, String description, @Size(max = 128) String material, @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal massKg, - @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal lengthMm, - @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal widthMm, - @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal heightMm, - List<@NotNull String> tags, + @Min(0) @JsonDeserialize(using = DegreesOfFreedomDeserializer.class) Integer degreesOfFreedom, + @Size(max = 512) String functionDescription, + @Size(max = 128) String shape, + @Size(max = 128) String size, + @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal torqueNm, + JsonNode bomList, + @NotNull JsonNode urdfInfo, @Size(max = 100) List<@NotNull @Valid CustomField> basicFields, @Size(max = 100) List<@NotNull @Valid CustomField> parameterFields, @NotBlank @Size(max = 4096) String uploadSessionToken, diff --git a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/DegreesOfFreedomDeserializer.java b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/DegreesOfFreedomDeserializer.java new file mode 100644 index 0000000..719d19c --- /dev/null +++ b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/DegreesOfFreedomDeserializer.java @@ -0,0 +1,22 @@ +package com.linkerbot.cadworld.dto.component; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import java.io.IOException; + +/** 自由度仅接受 JSON 整数,避免小数截断或字符串隐式转换。 */ +public class DegreesOfFreedomDeserializer extends StdDeserializer { + public DegreesOfFreedomDeserializer() { + super(Integer.class); + } + + @Override + public Integer deserialize(JsonParser parser, DeserializationContext context) throws IOException { + if (!parser.hasToken(JsonToken.VALUE_NUMBER_INT)) { + return context.reportInputMismatch(Integer.class, "自由度必须为整数"); + } + return parser.getIntValue(); + } +} diff --git a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/UpdateComponentRequest.java b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/UpdateComponentRequest.java index bec2440..73183bb 100644 --- a/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/UpdateComponentRequest.java +++ b/cadworld-bean/src/main/java/com/linkerbot/cadworld/dto/component/UpdateComponentRequest.java @@ -1,5 +1,7 @@ package com.linkerbot.cadworld.dto.component; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import jakarta.validation.Valid; import jakarta.validation.constraints.*; import java.math.BigDecimal; @@ -9,14 +11,16 @@ public record UpdateComponentRequest( @Size(max = 64) String componentCode, @NotBlank @Size(max = 128) String componentName, @NotBlank @Size(max = 64) String category, - @Size(max = 128) String manufacturer, String description, @Size(max = 128) String material, @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal massKg, - @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal lengthMm, - @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal widthMm, - @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal heightMm, - List<@NotNull String> tags, + @Min(0) @JsonDeserialize(using = DegreesOfFreedomDeserializer.class) Integer degreesOfFreedom, + @Size(max = 512) String functionDescription, + @Size(max = 128) String shape, + @Size(max = 128) String size, + @DecimalMin("0") @Digits(integer = 12, fraction = 6) BigDecimal torqueNm, + JsonNode bomList, + @NotNull JsonNode urdfInfo, @Size(max = 100) List<@NotNull @Valid CustomField> basicFields, @Size(max = 100) List<@NotNull @Valid CustomField> parameterFields, @NotNull @Min(1) @Max(4294967295L) Long version, diff --git a/cadworld-bean/src/main/java/com/linkerbot/cadworld/entity/Component.java b/cadworld-bean/src/main/java/com/linkerbot/cadworld/entity/Component.java index 1345e1e..7ce3f3f 100644 --- a/cadworld-bean/src/main/java/com/linkerbot/cadworld/entity/Component.java +++ b/cadworld-bean/src/main/java/com/linkerbot/cadworld/entity/Component.java @@ -20,15 +20,18 @@ public class Component extends BaseEntity { private String componentCode; private String componentName; private String category; - private String manufacturer; private String description; private String material; private BigDecimal massKg; - private BigDecimal lengthMm; - private BigDecimal widthMm; - private BigDecimal heightMm; + private Integer degreesOfFreedom; + private String functionDescription; + private String shape; + private String size; + private BigDecimal torqueNm; @TableField(typeHandler = JsonNodeTypeHandler.class) - private JsonNode tags; + private JsonNode bomList; + @TableField(typeHandler = JsonNodeTypeHandler.class) + private JsonNode urdfInfo; @TableField(typeHandler = JsonNodeTypeHandler.class) private JsonNode basicFields; @TableField(typeHandler = JsonNodeTypeHandler.class) diff --git a/cadworld-service/src/main/java/com/linkerbot/cadworld/service/impl/ComponentConverter.java b/cadworld-service/src/main/java/com/linkerbot/cadworld/service/impl/ComponentConverter.java index ec74614..75f4cdd 100644 --- a/cadworld-service/src/main/java/com/linkerbot/cadworld/service/impl/ComponentConverter.java +++ b/cadworld-service/src/main/java/com/linkerbot/cadworld/service/impl/ComponentConverter.java @@ -15,7 +15,6 @@ import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.List; -import java.util.Objects; import java.util.Set; import lombok.RequiredArgsConstructor; @@ -23,7 +22,6 @@ import lombok.RequiredArgsConstructor; @org.springframework.stereotype.Component @RequiredArgsConstructor public class ComponentConverter { - private static final TypeReference> TAGS = new TypeReference<>() { }; private static final TypeReference> FIELDS = new TypeReference<>() { }; private static final TypeReference> FILES = new TypeReference<>() { }; @@ -33,7 +31,6 @@ public class ComponentConverter { public void applyForm(Component component, ComponentForm form) { component.setComponentName(text(form.componentName())); component.setCategory(text(form.category())); - component.setManufacturer(text(form.manufacturer())); String description = form.description() == null ? "" : form.description(); if (description.getBytes(StandardCharsets.UTF_8).length > 65535) { throw new BizException(422, "INVALID_COMPONENT_FORM", "零件说明超过TEXT字段容量"); @@ -41,12 +38,13 @@ public class ComponentConverter { component.setDescription(description); component.setMaterial(text(form.material())); component.setMassKg(number(form.massKg())); - component.setLengthMm(number(form.lengthMm())); - component.setWidthMm(number(form.widthMm())); - component.setHeightMm(number(form.heightMm())); - List tags = form.tags() == null ? List.of() : form.tags().stream() - .filter(Objects::nonNull).map(String::trim).filter(tag -> !tag.isEmpty()).distinct().toList(); - component.setTags(objectMapper.valueToTree(tags)); + component.setDegreesOfFreedom(form.degreesOfFreedom() == null ? 0 : form.degreesOfFreedom()); + component.setFunctionDescription(text(form.functionDescription())); + component.setShape(text(form.shape())); + component.setSize(text(form.size())); + component.setTorqueNm(number(form.torqueNm())); + component.setBomList(jsonContainer(form.bomList(), "bomList", false)); + component.setUrdfInfo(jsonContainer(form.urdfInfo(), "urdfInfo", true)); component.setBasicFields(objectMapper.valueToTree(fields(form.basicFields()))); component.setParameterFields(objectMapper.valueToTree(fields(form.parameterFields()))); } @@ -59,9 +57,10 @@ public class ComponentConverter { public ComponentResponse toResponse(Component component) { return new ComponentResponse(component.getId(), component.getComponentCode(), component.getComponentName(), - component.getCategory(), component.getManufacturer(), component.getDescription(), component.getMaterial(), - component.getMassKg(), component.getLengthMm(), component.getWidthMm(), component.getHeightMm(), - read(component.getTags(), TAGS), read(component.getBasicFields(), FIELDS), + component.getCategory(), component.getDescription(), component.getMaterial(), + component.getMassKg(), component.getDegreesOfFreedom(), component.getFunctionDescription(), + component.getShape(), component.getSize(), component.getTorqueNm(), component.getBomList(), + component.getUrdfInfo(), read(component.getBasicFields(), FIELDS), read(component.getParameterFields(), FIELDS), component.getStepObjectKey(), urls.resolvePublicUrl(component.getStepObjectKey()), component.getUrdfPrefix(), urls.resolvePublicUrl(component.getUrdfPrefix()), component.getUrdfMainObjectKey(), @@ -71,12 +70,26 @@ public class ComponentConverter { public ComponentListItemResponse toListItem(Component component) { return new ComponentListItemResponse(component.getId(), component.getComponentCode(), component.getComponentName(), - component.getCategory(), component.getManufacturer(), component.getDescription(), - read(component.getTags(), TAGS), urls.resolvePublicUrl(component.getStepObjectKey()), + component.getCategory(), component.getDescription(), component.getDegreesOfFreedom(), + component.getFunctionDescription(), component.getShape(), component.getSize(), component.getTorqueNm(), + urls.resolvePublicUrl(component.getStepObjectKey()), urls.resolvePublicUrl(component.getUrdfMainObjectKey()), component.getVersion(), component.getCreatedAt(), component.getUpdatedAt()); } + private JsonNode jsonContainer(JsonNode value, String fieldName, boolean required) { + if (value == null || value.isNull()) { + if (required) { + throw new BizException(422, "INVALID_COMPONENT_FORM", fieldName + "为必填JSON字段"); + } + return objectMapper.createArrayNode(); + } + if (!value.isObject() && !value.isArray()) { + throw new BizException(422, "INVALID_COMPONENT_FORM", fieldName + "必须为JSON对象或数组"); + } + return value; + } + private List fields(List source) { if (source == null) { return List.of(); diff --git a/cadworld-service/src/main/java/com/linkerbot/cadworld/service/impl/ComponentServiceImpl.java b/cadworld-service/src/main/java/com/linkerbot/cadworld/service/impl/ComponentServiceImpl.java index 851fb4e..35fccf6 100644 --- a/cadworld-service/src/main/java/com/linkerbot/cadworld/service/impl/ComponentServiceImpl.java +++ b/cadworld-service/src/main/java/com/linkerbot/cadworld/service/impl/ComponentServiceImpl.java @@ -101,8 +101,9 @@ public class ComponentServiceImpl implements ComponentService { String normalizedCategory = text(category); LambdaQueryWrapper query = new LambdaQueryWrapper() .select(Component::getId, Component::getComponentCode, Component::getComponentName, - Component::getCategory, Component::getManufacturer, Component::getDescription, - Component::getTags, Component::getStepObjectKey, Component::getUrdfMainObjectKey, + Component::getCategory, Component::getDescription, Component::getDegreesOfFreedom, + Component::getFunctionDescription, Component::getShape, Component::getSize, + Component::getTorqueNm, Component::getStepObjectKey, Component::getUrdfMainObjectKey, Component::getVersion, Component::getCreatedAt, Component::getUpdatedAt) .eq(!normalizedCategory.isEmpty(), Component::getCategory, normalizedCategory); if (!normalizedKeyword.isEmpty()) { diff --git a/cadworld-service/src/test/java/com/linkerbot/cadworld/service/impl/ComponentServiceImplTest.java b/cadworld-service/src/test/java/com/linkerbot/cadworld/service/impl/ComponentServiceImplTest.java index e06dc75..68b2aca 100644 --- a/cadworld-service/src/test/java/com/linkerbot/cadworld/service/impl/ComponentServiceImplTest.java +++ b/cadworld-service/src/test/java/com/linkerbot/cadworld/service/impl/ComponentServiceImplTest.java @@ -34,7 +34,7 @@ class ComponentServiceImplTest { mock(ComponentUploadSessionSupport.class), mock(ComponentUploadSupport.class),new TransactionTemplate(manager)); UpdateComponentRequest request = new UpdateComponentRequest(null,"测试","分类",null,null,null, - null,null,null,null,null,null,null,1L,null,null,null); + null,null,null,null,null,null,new ObjectMapper().createObjectNode(),null,null,1L,null,null,null); try { assertThatThrownBy(() -> service.updateComponent(0L,1L,request)) .isInstanceOf(BizException.class).extracting("code").isEqualTo("COMPONENT_REVISION_CONFLICT");