diff --git a/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/integration/IntegrationCatalogController.java b/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/integration/IntegrationCatalogController.java index 0766206..908b833 100644 --- a/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/integration/IntegrationCatalogController.java +++ b/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/integration/IntegrationCatalogController.java @@ -1,6 +1,7 @@ package cn.craftlabs.platform.api.integration; import cn.craftlabs.platform.api.persistence.integration.PlatformBitanswerIdMapping; +import cn.craftlabs.platform.api.persistence.integration.PlatformJsonTemplate; import cn.craftlabs.platform.api.service.IntegrationCatalogService; import cn.craftlabs.platform.api.web.dto.IntegrationEnvironmentRequest; import cn.craftlabs.platform.api.web.dto.IntegrationEnvironmentResponse; @@ -117,4 +118,33 @@ public class IntegrationCatalogController { integrationCatalogService.deleteIdMapping(id); return ResponseEntity.ok().build(); } + + @GetMapping("/json-templates") + public ResponseEntity> listJsonTemplates() { + return ResponseEntity.ok(integrationCatalogService.listJsonTemplates()); + } + + @GetMapping("/json-templates/{id}") + public ResponseEntity getJsonTemplate(@PathVariable Long id) { + PlatformJsonTemplate t = integrationCatalogService.getJsonTemplate(id); + return t != null ? ResponseEntity.ok(t) : ResponseEntity.notFound().build(); + } + + @PostMapping("/json-templates") + public ResponseEntity createJsonTemplate(@RequestBody PlatformJsonTemplate body) { + return ResponseEntity.ok(integrationCatalogService.createJsonTemplate(body)); + } + + @PutMapping("/json-templates/{id}") + public ResponseEntity updateJsonTemplate( + @PathVariable Long id, @RequestBody PlatformJsonTemplate body) { + PlatformJsonTemplate result = integrationCatalogService.updateJsonTemplate(id, body); + return result != null ? ResponseEntity.ok(result) : ResponseEntity.notFound().build(); + } + + @DeleteMapping("/json-templates/{id}") + public ResponseEntity deleteJsonTemplate(@PathVariable Long id) { + integrationCatalogService.deleteJsonTemplate(id); + return ResponseEntity.ok().build(); + } } diff --git a/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/persistence/integration/PlatformJsonTemplate.java b/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/persistence/integration/PlatformJsonTemplate.java new file mode 100644 index 0000000..d18cd22 --- /dev/null +++ b/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/persistence/integration/PlatformJsonTemplate.java @@ -0,0 +1,109 @@ +package cn.craftlabs.platform.api.persistence.integration; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.time.OffsetDateTime; + +@TableName("platform_json_template") +public class PlatformJsonTemplate { + + @TableId(type = IdType.AUTO) + private Long id; + + private String name; + + private Integer version; + + @TableField("template_content") + private String templateContent; + + @TableField("schema_version") + private Integer schemaVersion; + + @TableField("change_notes") + private String changeNotes; + + @TableField("created_by") + private String createdBy; + + @TableField("created_at") + private OffsetDateTime createdAt; + + @TableField("updated_at") + private OffsetDateTime updatedAt; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getVersion() { + return version; + } + + public void setVersion(Integer version) { + this.version = version; + } + + public String getTemplateContent() { + return templateContent; + } + + public void setTemplateContent(String templateContent) { + this.templateContent = templateContent; + } + + public Integer getSchemaVersion() { + return schemaVersion; + } + + public void setSchemaVersion(Integer schemaVersion) { + this.schemaVersion = schemaVersion; + } + + public String getChangeNotes() { + return changeNotes; + } + + public void setChangeNotes(String changeNotes) { + this.changeNotes = changeNotes; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } +} diff --git a/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/persistence/integration/PlatformJsonTemplateMapper.java b/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/persistence/integration/PlatformJsonTemplateMapper.java new file mode 100644 index 0000000..3bd0542 --- /dev/null +++ b/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/persistence/integration/PlatformJsonTemplateMapper.java @@ -0,0 +1,7 @@ +package cn.craftlabs.platform.api.persistence.integration; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PlatformJsonTemplateMapper extends BaseMapper {} diff --git a/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/service/IntegrationCatalogService.java b/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/service/IntegrationCatalogService.java index 7cd45a9..634ce1a 100644 --- a/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/service/IntegrationCatalogService.java +++ b/services/delivery-platform-api/src/main/java/cn/craftlabs/platform/api/service/IntegrationCatalogService.java @@ -4,6 +4,8 @@ import cn.craftlabs.platform.api.persistence.integration.PlatformBitanswerIdMapp import cn.craftlabs.platform.api.persistence.integration.PlatformBitanswerIdMappingMapper; import cn.craftlabs.platform.api.persistence.integration.PlatformIntegrationEnvironment; import cn.craftlabs.platform.api.persistence.integration.PlatformIntegrationEnvironmentMapper; +import cn.craftlabs.platform.api.persistence.integration.PlatformJsonTemplate; +import cn.craftlabs.platform.api.persistence.integration.PlatformJsonTemplateMapper; import cn.craftlabs.platform.api.persistence.integration.PlatformProductLine; import cn.craftlabs.platform.api.persistence.integration.PlatformProductLineMapper; import cn.craftlabs.platform.api.web.dto.IntegrationEnvironmentRequest; @@ -27,14 +29,17 @@ public class IntegrationCatalogService { private final PlatformProductLineMapper productLineMapper; private final PlatformIntegrationEnvironmentMapper environmentMapper; private final PlatformBitanswerIdMappingMapper idMappingMapper; + private final PlatformJsonTemplateMapper jsonTemplateMapper; public IntegrationCatalogService( PlatformProductLineMapper productLineMapper, PlatformIntegrationEnvironmentMapper environmentMapper, - PlatformBitanswerIdMappingMapper idMappingMapper) { + PlatformBitanswerIdMappingMapper idMappingMapper, + PlatformJsonTemplateMapper jsonTemplateMapper) { this.productLineMapper = productLineMapper; this.environmentMapper = environmentMapper; this.idMappingMapper = idMappingMapper; + this.jsonTemplateMapper = jsonTemplateMapper; } @Transactional(readOnly = true) @@ -174,6 +179,42 @@ public class IntegrationCatalogService { idMappingMapper.deleteById(id); } + @Transactional + public PlatformJsonTemplate createJsonTemplate(PlatformJsonTemplate template) { + template.setVersion(1); + template.setSchemaVersion(1); + template.setCreatedAt(java.time.OffsetDateTime.now()); + template.setUpdatedAt(java.time.OffsetDateTime.now()); + jsonTemplateMapper.insert(template); + return template; + } + + public java.util.List listJsonTemplates() { + return jsonTemplateMapper.selectList( + com.baomidou.mybatisplus.core.toolkit.Wrappers.lambdaQuery(PlatformJsonTemplate.class) + .orderByDesc(PlatformJsonTemplate::getCreatedAt)); + } + + public PlatformJsonTemplate getJsonTemplate(Long id) { + return jsonTemplateMapper.selectById(id); + } + + @Transactional + public PlatformJsonTemplate updateJsonTemplate(Long id, PlatformJsonTemplate template) { + PlatformJsonTemplate existing = jsonTemplateMapper.selectById(id); + if (existing == null) return null; + template.setId(id); + template.setVersion(existing.getVersion() + 1); + template.setUpdatedAt(java.time.OffsetDateTime.now()); + jsonTemplateMapper.updateById(template); + return jsonTemplateMapper.selectById(id); + } + + @Transactional + public void deleteJsonTemplate(Long id) { + jsonTemplateMapper.deleteById(id); + } + private ProductLineResponse toProductLine(PlatformProductLine row) { ProductLineResponse r = new ProductLineResponse(); r.setId(row.getId()); diff --git a/services/delivery-platform-api/src/main/resources/db/migration/V14__m6_json_template.sql b/services/delivery-platform-api/src/main/resources/db/migration/V14__m6_json_template.sql new file mode 100644 index 0000000..509b85e --- /dev/null +++ b/services/delivery-platform-api/src/main/resources/db/migration/V14__m6_json_template.sql @@ -0,0 +1,12 @@ +-- V14__m6_json_template.sql +CREATE TABLE platform_json_template ( + id BIGSERIAL PRIMARY KEY, + name VARCHAR(128) NOT NULL, + version INT NOT NULL DEFAULT 1, + template_content TEXT NOT NULL, + schema_version INT NOT NULL DEFAULT 1, + change_notes TEXT, + created_by VARCHAR(256), + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP +); diff --git a/web/delivery-platform-ui/src/api/platform.js b/web/delivery-platform-ui/src/api/platform.js index f2044d0..f680555 100644 --- a/web/delivery-platform-ui/src/api/platform.js +++ b/web/delivery-platform-ui/src/api/platform.js @@ -401,3 +401,20 @@ export function updateIdMapping(id, body) { export function deleteIdMapping(id) { return axios.delete(`/api/v1/integration/id-mappings/${id}`); } + +// —— I12-2 M6 JSON 模板 —————————————————————— +export function listJsonTemplates() { + return axios.get('/api/v1/integration/json-templates'); +} +export function getJsonTemplate(id) { + return axios.get(`/api/v1/integration/json-templates/${id}`); +} +export function createJsonTemplate(body) { + return axios.post('/api/v1/integration/json-templates', body); +} +export function updateJsonTemplate(id, body) { + return axios.put(`/api/v1/integration/json-templates/${id}`, body); +} +export function deleteJsonTemplate(id) { + return axios.delete(`/api/v1/integration/json-templates/${id}`); +} diff --git a/web/delivery-platform-ui/src/router/index.js b/web/delivery-platform-ui/src/router/index.js index 5f07081..a2ce79f 100644 --- a/web/delivery-platform-ui/src/router/index.js +++ b/web/delivery-platform-ui/src/router/index.js @@ -86,6 +86,12 @@ const routes = [ component: () => import("../views/IntegrationIdMappingView.vue"), meta: { roles: ["SYS_ADMIN", "DEVELOPER"], title: "ID 映射" }, }, + { + path: "integration/json-templates", + name: "integration-json-templates", + component: () => import("../views/IntegrationJsonTemplateView.vue"), + meta: { roles: ["SYS_ADMIN"], title: "JSON 模板" }, + }, { path: "callbacks/:id", name: "callback-inbox-detail", diff --git a/web/delivery-platform-ui/src/views/IntegrationJsonTemplateView.vue b/web/delivery-platform-ui/src/views/IntegrationJsonTemplateView.vue new file mode 100644 index 0000000..59de014 --- /dev/null +++ b/web/delivery-platform-ui/src/views/IntegrationJsonTemplateView.vue @@ -0,0 +1,189 @@ + + + + +