From b97583e91a0f31c3e4951ea2d4906cd326b0fca2 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 26 Dec 2024 00:15:51 -0800 Subject: [PATCH 01/72] fix: update page history bug --- .../it/controller/BlockController.java | 18 ++++++++++-------- .../it/service/material/BlockService.java | 7 ++++--- .../material/impl/BlockServiceImpl.java | 10 ++++++---- .../resources/mappers/PageHistoryMapper.xml | 2 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/BlockController.java b/base/src/main/java/com/tinyengine/it/controller/BlockController.java index 5f503d15..2a79c98d 100644 --- a/base/src/main/java/com/tinyengine/it/controller/BlockController.java +++ b/base/src/main/java/com/tinyengine/it/controller/BlockController.java @@ -399,24 +399,26 @@ public Result updateBlocks(@Valid @RequestBody BlockDto blockDto, @Pat } /** - * 根据label查询区块详情 + * 通过lable和appId查询区块 * - * @param label the label + * @param label label + * @param appId appId * @return the result */ - @Operation(summary = "根据label查询区块详情", - description = "根据label查询区块详情", + @Operation(summary = "根据lable和appId查询区块详情", + description = "根据lable和appId查询区块详情", responses = { @ApiResponse(responseCode = "200", description = "返回信息", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), @ApiResponse(responseCode = "400", description = "请求失败")} ) - @SystemControllerLog(description = "获取所有用户api") + @SystemControllerLog(description = "根据lable和appId查询区块详情api") @GetMapping("/block/label") - public Result getBlockByLabel(@RequestParam(value = "label") - String label) { - return blockService.getBlockByLabel(label); + public Result getBlockByLabel( + @RequestParam(value = "label") String label, + @RequestParam(value = "appId") Integer appId) { + return blockService.getBlockByLabel(label, appId); } /** diff --git a/base/src/main/java/com/tinyengine/it/service/material/BlockService.java b/base/src/main/java/com/tinyengine/it/service/material/BlockService.java index 459e33e4..20e675bf 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/BlockService.java +++ b/base/src/main/java/com/tinyengine/it/service/material/BlockService.java @@ -130,12 +130,13 @@ public interface BlockService { /** - * 通过lable查询区块 + * 通过label和appId查询区块 * - * @param lable lable + * @param label label + * @param appId appId * @return the BlockDto */ - Result getBlockByLabel(String lable); + Result getBlockByLabel(String label, Integer appId); /** * block发布 diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java index 73c5df3f..36c1b2a0 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java @@ -405,15 +405,17 @@ public List getNotInGroupBlocks(Integer groupId) { } /** - * 通过lable查询区块 + * 通过label和appId查询区块 * - * @param lable lable + * @param label label + * @param appId appId * @return the BlockDto */ @Override - public Result getBlockByLabel(String lable) { + public Result getBlockByLabel(String label, Integer appId) { Block block = new Block(); - block.setLabel(lable); + block.setLabel(label); + block.setAppId(appId); List blockList = blockMapper.queryBlockByCondition(block); if (blockList.isEmpty()) { return Result.success(); diff --git a/base/src/main/resources/mappers/PageHistoryMapper.xml b/base/src/main/resources/mappers/PageHistoryMapper.xml index 164db6fe..bafe37b3 100644 --- a/base/src/main/resources/mappers/PageHistoryMapper.xml +++ b/base/src/main/resources/mappers/PageHistoryMapper.xml @@ -193,7 +193,7 @@ FROM t_page_history - AND ref_id = #{id} + AND id = #{id} From d30877c880df7e4bf6b040921850f237af20473b Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Mon, 6 Jan 2025 17:53:06 -0800 Subject: [PATCH 02/72] fix: format code and fix style issue --- .../com/tinyengine/it/service/app/impl/PageServiceImpl.java | 6 ------ base/src/main/resources/mappers/PageHistoryMapper.xml | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java index 1adcc94b..db2431c8 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java @@ -20,7 +20,6 @@ import com.tinyengine.it.common.log.SystemServiceLog; import com.tinyengine.it.mapper.AppExtensionMapper; import com.tinyengine.it.mapper.AppMapper; -import com.tinyengine.it.mapper.BlockHistoryMapper; import com.tinyengine.it.mapper.BlockMapper; import com.tinyengine.it.mapper.I18nEntryMapper; import com.tinyengine.it.mapper.PageMapper; @@ -107,11 +106,6 @@ public class PageServiceImpl implements PageService { @Autowired private AppV1ServiceImpl appV1ServiceImpl; - /** - * The Block history mapper. - */ - @Autowired - private BlockHistoryMapper blockHistoryMapper; /** * The App extension mapper. diff --git a/base/src/main/resources/mappers/PageHistoryMapper.xml b/base/src/main/resources/mappers/PageHistoryMapper.xml index bafe37b3..164db6fe 100644 --- a/base/src/main/resources/mappers/PageHistoryMapper.xml +++ b/base/src/main/resources/mappers/PageHistoryMapper.xml @@ -193,7 +193,7 @@ FROM t_page_history - AND id = #{id} + AND ref_id = #{id} From 7fc6507af5333696f946f819f42505a0b1d366ed Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Mon, 6 Jan 2025 18:06:45 -0800 Subject: [PATCH 03/72] fix: modify page histiry entity --- .../it/model/entity/PageHistory.java | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/model/entity/PageHistory.java b/base/src/main/java/com/tinyengine/it/model/entity/PageHistory.java index 17fc59f2..903980b5 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/PageHistory.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/PageHistory.java @@ -12,10 +12,13 @@ package com.tinyengine.it.model.entity; +import com.baomidou.mybatisplus.annotation.FieldFill; +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 com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import com.tinyengine.it.common.base.HistoryEntity; import com.tinyengine.it.common.handler.ListTypeHandler; import com.tinyengine.it.common.handler.MapTypeHandler; import com.tinyengine.it.model.dto.BlockVersionDto; @@ -24,6 +27,7 @@ import lombok.Getter; import lombok.Setter; +import java.time.LocalDateTime; import java.util.List; import java.util.Map; @@ -39,7 +43,11 @@ @Setter @TableName("t_page_history") @Schema(name = "PageHistory", description = "页面历史") -public class PageHistory extends HistoryEntity { +public class PageHistory { + @Schema(name = "id", description = "主键id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + @Schema(name = "name", description = "名称") private String name; @@ -89,4 +97,36 @@ public class PageHistory extends HistoryEntity { @Schema(name = "contentBlocks", description = "*设计预留字段*") @TableField(typeHandler = ListTypeHandler.class) private List contentBlocks; + + + @TableField(fill = FieldFill.INSERT) + @Schema(name = "createdBy", description = "创建人") + private String createdBy; + + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(name = "lastUpdatedBy", description = "最后修改人") + private String lastUpdatedBy; + + @TableField(fill = FieldFill.INSERT) + @Schema(name = "created_at", description = "创建时间") + @JsonProperty("created_at") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createdTime; + + @TableField(fill = FieldFill.INSERT_UPDATE) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonProperty("updated_at") + @Schema(name = "updated_at", description = "更新时间") + private LocalDateTime lastUpdatedTime; + + @TableField(fill = FieldFill.INSERT) + @Schema(name = "tenantId", description = "租户ID") + private String tenantId; + + @TableField(fill = FieldFill.INSERT) + @Schema(name = "renterId", description = "业务租户ID") + private String renterId; + + @Schema(name = "siteId", description = "站点ID") + private String siteId; } From 24474b89c1387a4271e524ce622e8ac7e73ed624 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 9 Jan 2025 00:16:05 -0800 Subject: [PATCH 04/72] feat: add code submission rules --- .github/ISSUE_TEMPLATE/bug-report.yml | 73 +++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 5 ++ .github/ISSUE_TEMPLATE/feature-request.yml | 23 ++++++ .github/PULL_REQUEST_TEMPLATE.md | 52 +++++++++++++ .../PULL_REQUEST_TEMPLATE.zh-CN.md | 52 +++++++++++++ .github/release.yml | 26 +++++++ .github/workflows/ai-code-review.yml | 23 ++++++ .github/workflows/issue-translator.yml | 18 +++++ app/src/main/resources/logback.xml | 2 +- pom.xml | 2 +- 10 files changed, 274 insertions(+), 2 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.zh-CN.md create mode 100644 .github/release.yml create mode 100644 .github/workflows/ai-code-review.yml create mode 100644 .github/workflows/issue-translator.yml diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000..00f3a624 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,73 @@ +name: '🐛 Bug report' +description: Create a report to help us improve Tiny Engine +title: '🐛 [Bug]: ' +labels: ['🐛 bug'] +body: + - type: markdown + attributes: + value: | + Please fill out the following carefully in order to better fix the problem. + - type: input + id: Environment + attributes: + label: Environment + description: | + **Depending on your browser and operating system, websites may behave differently from one environment to another. Make sure your developers know your technical environment.** + placeholder: Please browser information. + validations: + required: true + - type: input + id: node-version + attributes: + label: Version + description: | + ### **Check if the issue is reproducible with the latest stable version.** + You can use the command `node -v` to view it + placeholder: latest + validations: + required: true + - type: input + id: tiny-vue-version + attributes: + label: Version + description: | + ### **Check if the issue is reproducible with the latest stable version.** + You can use the command `npm ls @opentiny/vue` to view it + placeholder: latest + validations: + required: true + - type: textarea + id: minimal-repo + attributes: + label: Link to minimal reproduction + description: | + **Provide a streamlined CodePen / CodeSandbox or GitHub repository link as much as possible. Please don't fill in a link randomly, it will only close your issue directly.** + placeholder: Please Input + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: Step to reproduce + description: | + **After the replay is turned on, what actions do we need to perform to make the bug appear? Simple and clear steps can help us locate the problem more quickly. Please clearly describe the steps of reproducing the issue. Issues without clear reproducing steps will not be repaired. If the issue marked with 'need reproduction' does not provide relevant steps within 7 days, it will be closed directly.** + placeholder: Please Input + validations: + required: true + - type: textarea + id: expected + attributes: + label: What is expected + placeholder: Please Input + - type: textarea + id: actually + attributes: + label: What is actually happening + placeholder: Please Input + - type: textarea + id: additional-comments + attributes: + label: Any additional comments (optional) + description: | + **Some background / context of how you ran into this bug.** + placeholder: Please Input diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..1f521648 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: true +contact_links: + - name: Questions or need help + url: https://github.com/opentiny/tiny-engine/discussions + about: Add this WeChat(opentiny), we will invite you to the WeChat discussion group later. diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 00000000..d3be2079 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,23 @@ +name: ✨ Feature Request +description: Propose new features to @opentiny/tiny-engine-backend-java to improve it. +title: '✨ [Feature]: ' +labels: ['✨ feature'] +body: + - type: textarea + id: feature-solve + attributes: + label: What problem does this feature solve + description: | + Explain your use case, context, and rationale behind this feature request. More importantly, what is the end user experience you are trying to build that led to the need for this feature? + placeholder: Please Input + validations: + required: true + - type: textarea + id: feature-api + attributes: + label: What does the proposed API look like + description: | + Describe how you propose to solve the problem and provide code samples of how the API would work once implemented. Note that you can use Markdown to format your code blocks. + placeholder: Please Input + validations: + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..617bddd1 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,52 @@ +English | [简体中文](https://github.com/opentiny/tiny-engine-backend-java/blob/main/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.zh-CN.md) + +# PR + +## PR Checklist + +Please check if your PR fulfills the following requirements: + +- [ ] The commit message follows our [Commit Message Guidelines](https://github.com/opentiny/tiny-engine-backend-java/blob/main/CONTRIBUTING.md) +- [ ] Tests for the changes have been added (for bug fixes / features) +- [ ] Docs have been added / updated (for bug fixes / features) +- [ ] Built its own designer, fully self-validated + +## PR Type + +What kind of change does this PR introduce? + + + +- [ ] Bugfix +- [ ] Feature +- [ ] Code style update (formatting, local variables) +- [ ] Refactoring (no functional changes, no api changes) +- [ ] Build related changes +- [ ] CI related changes +- [ ] Documentation content changes +- [ ] Other... Please describe: + +## Background and solution + + +### What is the current behavior? + + + +Issue Number: N/A + +### What is the new behavior? + + +## Does this PR introduce a breaking change? + +- [ ] Yes +- [ ] No + + + +## Other information diff --git a/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.zh-CN.md b/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.zh-CN.md new file mode 100644 index 00000000..32916663 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -0,0 +1,52 @@ +[English](https://github.com/opentiny/tiny-engine-backend-java/blob/main/.github/PULL_REQUEST_TEMPLATE.md) | 简体中文 + +# PR + +## PR Checklist + +请检查您的 PR 是否满足以下要求: + +- [ ] commit message遵循我们的[提交贡献指南](https://github.com/opentiny/tiny-engine-backend-java/blob/main/CONTRIBUTING.zh-CN.md) +- [ ] 添加了更改内容的测试用例(用于bugfix/功能) +- [ ] 文档已添加/更新(用于bugfix/功能) +- [ ] 是否构建了自己的设计器,经过了充分的自验证 + +## PR 类型 + +这个PR的类型是? + +- [ ] 日常 bug 修复 +- [ ] 新特性支持 +- [ ] 代码风格优化 +- [ ] 重构 +- [ ] 构建优化 +- [ ] 测试用例 +- [ ] 文档更新 +- [ ] 分支合并 +- [ ] 其他改动(请补充) + + +## 需求背景和解决方案 + + + + +Issue Number: N/A + +### 修改前 + + +### 修改后 + +## 此PR是否含有 breaking change? + +- [ ] 是 +- [ ] 否 + + + +## Other information diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000..274543b2 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,26 @@ +changelog: + exclude: + labels: + - ignore-for-release + authors: + - allcontributors[bot] + categories: + - title: Breaking Changes 🛠 + labels: + - Semver-Major + - breaking-change + - title: Exciting New Features 🎉 + labels: + - Semver-Minor + - feature + - enhancement + - title: Bug Fixes 🐛 + labels: + - Semver-Patch + - bug + - title: Other Changes + labels: + - documentation + - refactoring + - unit-test + - ci diff --git a/.github/workflows/ai-code-review.yml b/.github/workflows/ai-code-review.yml new file mode 100644 index 00000000..29777ff3 --- /dev/null +++ b/.github/workflows/ai-code-review.yml @@ -0,0 +1,23 @@ +name: AI Code Review + +permissions: + contents: read + pull-requests: write + +on: + pull_request: + types: [opened, reopened, synchronize] + +jobs: + review: + runs-on: ubuntu-latest + steps: + - uses: anc95/ChatGPT-CodeReview@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + LANGUAGE: Chinese + OPENAI_API_ENDPOINT: https://api.openai.com/v1 + MODEL: gpt-3.5-turbo + MAX_TOKENS: 4096 + MAX_PATCH_LENGTH: 10000 diff --git a/.github/workflows/issue-translator.yml b/.github/workflows/issue-translator.yml new file mode 100644 index 00000000..8b3397bf --- /dev/null +++ b/.github/workflows/issue-translator.yml @@ -0,0 +1,18 @@ +name: 'issue-translator' +on: + issue_comment: + types: [created] + issues: + types: [opened] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: usthe/issues-translate-action@v2.7 + with: + IS_MODIFY_TITLE: false + # 非必须,决定是否需要修改issue标题内容 + # 若是true,则机器人账户@Issues-translate-bot必须拥有修改此仓库issue权限。可以通过邀请@Issues-translate-bot加入仓库协作者实现。 + CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. + # 非必须,自定义机器人翻译的前缀开始内容。 diff --git a/app/src/main/resources/logback.xml b/app/src/main/resources/logback.xml index 7aa24fbe..be616676 100644 --- a/app/src/main/resources/logback.xml +++ b/app/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - + diff --git a/pom.xml b/pom.xml index 39ed64e6..d33fc973 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ tiny-engine-service pom 1.0-SNAPSHOT - tiny-engine-webservice-java Maven Webapp + tiny-engine-backend-java Maven Webapp org.springframework.boot From b77f2f4a4caaf1144b43fb625b18a43631518bf7 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 9 Jan 2025 00:58:33 -0800 Subject: [PATCH 05/72] fix: modify app schema for test --- .../tinyengine/it/service/app/impl/v1/AppV1ServiceImplTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/src/test/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImplTest.java index 6a87cc1c..0a7aa221 100644 --- a/base/src/test/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImplTest.java @@ -107,6 +107,7 @@ void testAppSchema() { int appId = 2; app.setId(appId); app.setHomePage(1); + app.setPlatformId(1); when(appMapper.queryAppById(anyInt())).thenReturn(app); Page page = new Page(); page.setIsPage(true); @@ -141,6 +142,7 @@ void testMergeEntries() { @Test void testGetMetaDto() { App app = new App(); + app.setPlatformId(1); when(appMapper.queryAppById(anyInt())).thenReturn(app); when(i18nEntryMapper.findI18nEntriesByHostandHostType(anyInt(), anyString())) .thenReturn(Arrays.asList(new I18nEntryDto())); From 6559becaa5b13bb46e430a885d84fde0c3a95fa2 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Wed, 22 Jan 2025 00:52:04 -0800 Subject: [PATCH 06/72] fix: modify t_i18n_entry u_idx_i18n_entity --- .../main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql b/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql index fb58b6f9..a4d5333f 100644 --- a/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql +++ b/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql @@ -511,7 +511,7 @@ create table `t_i18n_entry` `last_updated_by` varchar(60) not null comment '最后修改人', `last_updated_time` timestamp not null default current_timestamp comment '更新时间', primary key (`id`) using btree, - unique index `u_idx_i18n_entity` (`key`, `host_id`, `host_type`) using btree + unique index `u_idx_i18n_entity` (`key`, `host_id`, `host_type`,`lang_id`) using btree ) engine = innodb comment = '国际化语言配置表'; drop table if exists `t_i18n_lang`; From 656a4a1c765f37a09152eda05e6160ce8b73431c Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Wed, 22 Jan 2025 03:06:39 -0800 Subject: [PATCH 07/72] fix: modify t_i18n_entry u_idx_i18n_entity --- .../material/impl/BlockGroupServiceImpl.java | 5 +-- .../material/impl/BlockServiceImpl.java | 31 ++++++++++++++++--- ...oupBlock.xml => BlockGroupBlockMapper.xml} | 0 .../resources/mappers/BlockGroupMapper.xml | 12 +++---- .../impl/BlockGroupServiceImplTest.java | 12 ++++++- .../material/impl/BlockServiceImplTest.java | 14 ++++----- 6 files changed, 53 insertions(+), 21 deletions(-) rename base/src/main/resources/mappers/{BlockGroupBlock.xml => BlockGroupBlockMapper.xml} (100%) diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java index bbf8df11..24aef050 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java @@ -103,7 +103,6 @@ public Integer deleteBlockGroupById(@Param("id") Integer id) { public Integer updateBlockGroupById(BlockGroup blockGroup) { // 判断是对正常的分组修改,还是在分组下添加区块操作的修改 List blockList = blockGroup.getBlocks(); - List blockIds = blockList.stream().map(Block::getId).collect(Collectors.toList()); List blockGroupBlocks = blockGroupBlockMapper.findBlockGroupBlockByBlockGroupId(blockGroup.getId()); List groupBlockIds = blockGroupBlocks.stream().map(BlockGroupBlock::getBlockId).collect(Collectors.toList()); @@ -113,9 +112,11 @@ public Integer updateBlockGroupById(BlockGroup blockGroup) { // 删除区块分组与区块历史版本关系 blockCarriersRelationMapper.deleteBlockCarriersRelation(blockGroup.getId(), hostType, null); // 删除区块分组与区块关系 - return blockGroupBlockMapper.deleteBlockGroupBlockByGroupId(blockGroup.getId()); + blockGroupBlockMapper.deleteBlockGroupBlockByGroupId(blockGroup.getId()); + return blockGroupMapper.updateBlockGroupById(blockGroup); } // 处理参数分组区块 + List blockIds = blockList.stream().map(Block::getId).collect(Collectors.toList()); int result = getBlockGroupIds(groupBlockIds, blockIds, blockGroup.getId()); // 更新区块分组和区块历史关系表 List blockCarriersRelations = new ArrayList<>(); diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java index 531cfcdd..90c47ed2 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java @@ -24,6 +24,7 @@ import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.common.log.SystemServiceLog; import com.tinyengine.it.mapper.AppMapper; +import com.tinyengine.it.mapper.BlockGroupBlockMapper; import com.tinyengine.it.mapper.BlockGroupMapper; import com.tinyengine.it.mapper.BlockHistoryMapper; import com.tinyengine.it.mapper.BlockMapper; @@ -37,7 +38,9 @@ import com.tinyengine.it.model.dto.SchemaI18n; import com.tinyengine.it.model.entity.App; import com.tinyengine.it.model.entity.Block; +import com.tinyengine.it.model.entity.BlockCarriersRelation; import com.tinyengine.it.model.entity.BlockGroup; +import com.tinyengine.it.model.entity.BlockGroupBlock; import com.tinyengine.it.model.entity.BlockHistory; import com.tinyengine.it.model.entity.User; import com.tinyengine.it.service.app.I18nEntryService; @@ -88,6 +91,8 @@ public class BlockServiceImpl implements BlockService { private I18nEntryMapper i18nEntryMapper; @Autowired private BlockGroupMapper blockGroupMapper; + @Autowired + private BlockGroupBlockMapper blockGroupBlockMapper; /** * 查询表t_block所有数据 @@ -150,12 +155,19 @@ public Integer updateBlockById(BlockDto blockDto) { Block blocks = new Block(); BeanUtils.copyProperties(blockDto, blocks); blocks.setOccupierBy(String.valueOf(1)); - blocks.setLatestHistoryId(blockDto.getLatestHistoryId().getId()); + if(blockDto.getLatestHistoryId() != null){ + blocks.setLatestHistoryId(blockDto.getLatestHistoryId().getId()); + } // 处理区块截图 if (!blockDto.getScreenshot().isEmpty() && !blockDto.getLabel().isEmpty()) { // 图片上传,此处给默认值空字符 blocks.setScreenshot(""); } + + if(blockDto.getGroups().isEmpty()){ + return blockMapper.updateBlockById(blocks); + } + // 过滤出 Integer 类型的对象 // 转换为 Integer 类型 // 收集为 List; @@ -163,10 +175,13 @@ public Integer updateBlockById(BlockDto blockDto) { .filter(obj -> obj instanceof Integer) .map(obj -> (Integer) obj) .collect(Collectors.toList()); - if (!groups.isEmpty()) { + int groupId = groups.get(0); - blocks.setBlockGroupId(groupId); - } + BlockGroupBlock blockGroupBlock = new BlockGroupBlock(); + blockGroupBlock.setBlockGroupId(groupId); + blockGroupBlock.setBlockId(blockDto.getId()); + blockGroupBlockMapper.createBlockGroupBlock(blockGroupBlock); + return blockMapper.updateBlockById(blocks); } @@ -190,7 +205,10 @@ public Result createBlock(BlockDto blockDto) { List groups = blockDto.getGroups(); if (!groups.isEmpty() && groups.get(0) instanceof Integer) { Integer groupId = (Integer) groups.get(0); // 强制类型转换 - blocks.setBlockGroupId(groupId); + BlockGroupBlock blockGroupBlock = new BlockGroupBlock(); + blockGroupBlock.setBlockGroupId(groupId); + blockGroupBlock.setBlockId(blockDto.getId()); + blockGroupBlockMapper.createBlockGroupBlock(blockGroupBlock); } int result = blockMapper.createBlock(blocks); if (result < 1) { @@ -394,6 +412,9 @@ public List getNotInGroupBlocks(NotGroupDto notGroupDto) { int userId = 1; User user = userMapper.queryUserById(userId); List blocksList = blockMapper.findBlocksReturn(notGroupDto); + if(blocksList == null || blocksList.isEmpty()){ + return blocksList; + } for (BlockDto blockDto : blocksList) { List blockGroups = blockGroupMapper.findBlockGroupByBlockId(blockDto.getId()); List objectGroups = new ArrayList<>(blockGroups); diff --git a/base/src/main/resources/mappers/BlockGroupBlock.xml b/base/src/main/resources/mappers/BlockGroupBlockMapper.xml similarity index 100% rename from base/src/main/resources/mappers/BlockGroupBlock.xml rename to base/src/main/resources/mappers/BlockGroupBlockMapper.xml diff --git a/base/src/main/resources/mappers/BlockGroupMapper.xml b/base/src/main/resources/mappers/BlockGroupMapper.xml index 64fbc803..b7f2daaa 100644 --- a/base/src/main/resources/mappers/BlockGroupMapper.xml +++ b/base/src/main/resources/mappers/BlockGroupMapper.xml @@ -181,9 +181,9 @@ b.renter_id as block_renter_id, b.site_id as block_site_id FROM t_block_group bg - JOIN + LEFT JOIN r_block_group_block rbg ON rbg.block_group_id = bg.id - JOIN + LEFT JOIN t_block b ON b.id = rbg.block_id AND b.created_by = #{createdBy} @@ -240,9 +240,9 @@ b.renter_id as block_renter_id, b.site_id as block_site_id FROM t_block_group bg - JOIN + LEFT JOIN r_block_group_block rbg ON rbg.block_group_id = bg.id - JOIN + LEFT JOIN t_block b ON b.id = rbg.block_id AND b.created_by = #{createdBy} @@ -303,9 +303,9 @@ b.renter_id as block_renter_id, b.site_id as block_site_id FROM t_block_group bg - JOIN + LEFT JOIN r_block_group_block rbg ON rbg.block_group_id = bg.id - JOIN + LEFT JOIN t_block b ON b.id = rbg.block_id AND b.created_by = #{createdBy} diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java index 54f2dd36..9e92239d 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java @@ -16,6 +16,8 @@ import static org.mockito.Mockito.when; import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.mapper.BlockCarriersRelationMapper; +import com.tinyengine.it.mapper.BlockGroupBlockMapper; import com.tinyengine.it.mapper.BlockGroupMapper; import com.tinyengine.it.model.dto.BlockGroupDto; import com.tinyengine.it.model.entity.BlockGroup; @@ -26,6 +28,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; import java.util.Arrays; @@ -41,6 +44,10 @@ class BlockGroupServiceImplTest { private BlockGroupMapper blockGroupMapper; @InjectMocks private BlockGroupServiceImpl blockGroupServiceImpl; + @Mock + private BlockCarriersRelationMapper blockCarriersRelationMapper; + @Mock + private BlockGroupBlockMapper blockGroupBlockMapper; @BeforeEach void setUp() { @@ -86,8 +93,11 @@ void testDeleteBlockGroupById() { @Test void testUpdateBlockGroupById() { BlockGroup param = new BlockGroup(); + param.setId(1); + param.setBlocks(new ArrayList<>()); when(blockGroupMapper.updateBlockGroupById(param)).thenReturn(1); - + when(blockGroupBlockMapper.deleteBlockGroupBlockByGroupId(null)).thenReturn(1); + when(blockCarriersRelationMapper.deleteBlockCarriersRelation(null, null, null)).thenReturn(1); Integer result = blockGroupServiceImpl.updateBlockGroupById(param); Assertions.assertEquals(1, result); } diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java index 725a46e4..256ede34 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java @@ -25,6 +25,7 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.common.enums.Enums; import com.tinyengine.it.mapper.AppMapper; +import com.tinyengine.it.mapper.BlockGroupMapper; import com.tinyengine.it.mapper.BlockMapper; import com.tinyengine.it.mapper.UserMapper; import com.tinyengine.it.model.dto.BlockDto; @@ -32,6 +33,7 @@ import com.tinyengine.it.model.dto.NotGroupDto; import com.tinyengine.it.model.entity.App; import com.tinyengine.it.model.entity.Block; +import com.tinyengine.it.model.entity.BlockGroup; import com.tinyengine.it.model.entity.User; import org.junit.jupiter.api.Assertions; @@ -63,6 +65,8 @@ class BlockServiceImplTest { private UserMapper userMapper; @Mock private AppMapper appMapper; + @Mock + private BlockGroupMapper blockGroupMapper; @BeforeEach void setUp() { @@ -118,7 +122,6 @@ void testCreateBlock() { blockDto.setFramework("cc"); blockDto.setPlatformId(1); blockDto.setAppId(1); - blockDto.setGroups(asList(1)); blockDto.setName("testBlock"); Result result = blockServiceImpl.createBlock(blockDto); Assertions.assertEquals("test", result.getData().getName()); @@ -238,18 +241,15 @@ void testAllTags() { @Test void testGetNotInGroupBlocks() { BlockDto blockDto = new BlockDto(); - blockDto.setLastBuildInfo(new HashMap<>()); - blockDto.setContent(new HashMap<>()); - blockDto.setAssets(new HashMap<>()); - blockDto.setPublicStatus(Enums.Scope.PUBLIC_IN_TENANTS.getValue()); List mockData = Arrays.asList(blockDto); NotGroupDto notGroupDto =new NotGroupDto(); - notGroupDto.setGroupId(1); + List blockGroups = new ArrayList<>(); when(blockMapper.findBlocksReturn(notGroupDto)).thenReturn(mockData); when(userMapper.queryUserById(anyInt())).thenReturn(new User()); + when(blockGroupMapper.findBlockGroupByBlockId(blockDto.getId())).thenReturn(blockGroups); List result = blockServiceImpl.getNotInGroupBlocks(notGroupDto); - Assertions.assertEquals(blockDto, result.get(0)); + Assertions.assertEquals(new ArrayList<>(), result); } @Test From e9aa592a066a8de5a6edacf874fc92c614e61297 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 23 Jan 2025 00:35:13 -0800 Subject: [PATCH 08/72] fix: modify block update api --- .../exception/GlobalExceptionAdvice.java | 2 +- .../it/controller/BlockController.java | 10 +--- .../it/mapper/BlockGroupBlockMapper.java | 10 ++++ .../it/mapper/BlockGroupMapper.java | 7 ++- .../it/service/material/BlockService.java | 2 +- .../material/impl/BlockServiceImpl.java | 58 +++++++++++++------ .../mappers/BlockGroupBlockMapper.xml | 2 +- .../exception/GlobalExceptionAdviceTest.java | 5 +- .../it/controller/BlockControllerTest.java | 5 +- .../material/impl/BlockServiceImplTest.java | 17 +++--- 10 files changed, 74 insertions(+), 44 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/common/exception/GlobalExceptionAdvice.java b/base/src/main/java/com/tinyengine/it/common/exception/GlobalExceptionAdvice.java index d398d579..4e0e0f30 100644 --- a/base/src/main/java/com/tinyengine/it/common/exception/GlobalExceptionAdvice.java +++ b/base/src/main/java/com/tinyengine/it/common/exception/GlobalExceptionAdvice.java @@ -41,7 +41,7 @@ public class GlobalExceptionAdvice { * @param e the e * @return the result */ - @ResponseStatus(HttpStatus.OK) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(Exception.class) public Result> handleException(Exception e) { // 修改为 log.error,传递异常对象以打印堆栈信息 diff --git a/base/src/main/java/com/tinyengine/it/controller/BlockController.java b/base/src/main/java/com/tinyengine/it/controller/BlockController.java index cc076582..1b737136 100644 --- a/base/src/main/java/com/tinyengine/it/controller/BlockController.java +++ b/base/src/main/java/com/tinyengine/it/controller/BlockController.java @@ -398,14 +398,10 @@ public Result> getBlockGroups( ) @SystemControllerLog(description = "区块修改api") @PostMapping("/block/update/{id}") - public Result updateBlocks(@Valid @RequestBody BlockDto blockDto, @PathVariable Integer id) { + public Result updateBlocks(@Valid @RequestBody BlockDto blockDto, @PathVariable Integer id, + @RequestParam(value = "appId", required = false) Integer appId) { blockDto.setId(id); - int result = blockService.updateBlockById(blockDto); - if (result < 1) { - return Result.failed(ExceptionEnum.CM001); - } - BlockDto blocksResult = blockService.queryBlockById(blockDto.getId()); - return Result.success(blocksResult); + return blockService.updateBlockById(blockDto,appId); } /** diff --git a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupBlockMapper.java b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupBlockMapper.java index 3add05c7..7eced891 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupBlockMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupBlockMapper.java @@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.tinyengine.it.model.entity.BlockGroupBlock; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -87,4 +88,13 @@ public interface BlockGroupBlockMapper extends BaseMapper { */ @Select("select * from r_block_group_block where block_group_id = #{blockGroupId}") List findBlockGroupBlockByBlockGroupId(Integer blockGroupId); + + /** + * 通过区块分组id查询分组下区块 + * @param blockId the block id + * @param groupId the block group id + * @return the list + */ + @Delete("delete from r_block_group_block where block_group_id = #{groupId} and block_id = #{blockId}") + Integer deleteByGroupIdAndBlockId(Integer groupId, Integer blockId); } diff --git a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java index 91d25d28..9b92094b 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java @@ -139,12 +139,13 @@ public interface BlockGroupMapper extends BaseMapper { /** * 根据区块id查询区块分组信息 - * + * @param createdBy the user id * @param blockId the block id * @return the list */ @Select("select * from t_block_group bg " + "left join r_block_group_block bgb on bgb.block_group_id = bg.id " - + "where bgb.block_id = #{blockId}") - List findBlockGroupByBlockId(Integer blockId); + + "where bgb.block_id = #{blockId} and created_by = #{createdBy}") + List findBlockGroupByBlockId(Integer blockId,String createdBy); + } \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/service/material/BlockService.java b/base/src/main/java/com/tinyengine/it/service/material/BlockService.java index 1b3485dd..32cb4df7 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/BlockService.java +++ b/base/src/main/java/com/tinyengine/it/service/material/BlockService.java @@ -69,7 +69,7 @@ public interface BlockService { * @param blockDto the block dto * @return the BlockDto */ - Integer updateBlockById(BlockDto blockDto); + Result updateBlockById(BlockDto blockDto, Integer appId); /** * 新增表t_block数据 diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java index 90c47ed2..2e824198 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java @@ -38,7 +38,6 @@ import com.tinyengine.it.model.dto.SchemaI18n; import com.tinyengine.it.model.entity.App; import com.tinyengine.it.model.entity.Block; -import com.tinyengine.it.model.entity.BlockCarriersRelation; import com.tinyengine.it.model.entity.BlockGroup; import com.tinyengine.it.model.entity.BlockGroupBlock; import com.tinyengine.it.model.entity.BlockHistory; @@ -113,6 +112,9 @@ public List queryAllBlock() { @Override public BlockDto queryBlockById(@Param("id") Integer id) { BlockDto blockDto = blockMapper.findBlockAndGroupAndHistoByBlockId(id); + if (blockDto == null) { + return blockDto; + } boolean isPublished = blockDto.getLastBuildInfo() != null && blockDto.getLastBuildInfo().get("result") instanceof Boolean ? (Boolean) blockDto.getLastBuildInfo().get("result") : Boolean.FALSE; @@ -149,23 +151,28 @@ public Integer deleteBlockById(@Param("id") Integer id) { * @return blockDto */ @Override - public Integer updateBlockById(BlockDto blockDto) { - // public 不是部分公开, 则public_scope_tenants为空数组 + public Result updateBlockById(BlockDto blockDto, Integer appId) { + Block blockResult = blockMapper.queryBlockById(blockDto.getId()); + if (blockResult.getAppId() != appId) { + return Result.failed(ExceptionEnum.CM007); + } // 把前端传参赋值给实体 Block blocks = new Block(); BeanUtils.copyProperties(blockDto, blocks); blocks.setOccupierBy(String.valueOf(1)); - if(blockDto.getLatestHistoryId() != null){ + if (blockDto.getLatestHistoryId() != null) { blocks.setLatestHistoryId(blockDto.getLatestHistoryId().getId()); } // 处理区块截图 - if (!blockDto.getScreenshot().isEmpty() && !blockDto.getLabel().isEmpty()) { + if (blockDto.getScreenshot() != null && blockDto.getLabel() != null) { // 图片上传,此处给默认值空字符 blocks.setScreenshot(""); } - - if(blockDto.getGroups().isEmpty()){ - return blockMapper.updateBlockById(blocks); + Integer result; + if (blockDto.getGroups() == null || blockDto.getGroups().isEmpty()) { + blockMapper.updateBlockById(blocks); + BlockDto blockDtoResult = queryBlockById(blocks.getId()); + return Result.success(blockDtoResult); } // 过滤出 Integer 类型的对象 @@ -176,13 +183,29 @@ public Integer updateBlockById(BlockDto blockDto) { .map(obj -> (Integer) obj) .collect(Collectors.toList()); - int groupId = groups.get(0); + // 对接登录后获取用户id + String createdBy = "1"; + // 根据区块id获取区块所在分组 + List blockGroups = blockGroupMapper.findBlockGroupByBlockId(blocks.getId(), createdBy); + if (!blockGroups.isEmpty()) { + List blockGroupIds = blockGroups.stream().map(BlockGroup::getId).collect(Collectors.toList()); + for (Integer id : blockGroupIds) { + blockGroupBlockMapper.deleteByGroupIdAndBlockId(id, blocks.getId()); + } + } + + for (Integer groupId : groups) { BlockGroupBlock blockGroupBlock = new BlockGroupBlock(); - blockGroupBlock.setBlockGroupId(groupId); blockGroupBlock.setBlockId(blockDto.getId()); + blockGroupBlock.setBlockGroupId(groupId); blockGroupBlockMapper.createBlockGroupBlock(blockGroupBlock); + } + - return blockMapper.updateBlockById(blocks); + blockMapper.updateBlockById(blocks); + + BlockDto blockDtoResult = queryBlockById(blocks.getId()); + return Result.success(blockDtoResult); } /** @@ -412,11 +435,12 @@ public List getNotInGroupBlocks(NotGroupDto notGroupDto) { int userId = 1; User user = userMapper.queryUserById(userId); List blocksList = blockMapper.findBlocksReturn(notGroupDto); - if(blocksList == null || blocksList.isEmpty()){ + if (blocksList == null || blocksList.isEmpty()) { return blocksList; } + for (BlockDto blockDto : blocksList) { - List blockGroups = blockGroupMapper.findBlockGroupByBlockId(blockDto.getId()); + List blockGroups = blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(), String.valueOf(userId)); List objectGroups = new ArrayList<>(blockGroups); blockDto.setGroups(objectGroups); } @@ -518,12 +542,8 @@ public Result deploy(BlockBuildDto blockBuildDto) { } blockDto.setLastBuildInfo(buildInfo); blockDto.setLatestHistoryId(blockHistory); - int blockResult = updateBlockById(blockDto); - if (blockResult < 1) { - return Result.failed(ExceptionEnum.CM008); - } - BlockDto result = queryBlockById(id); - return Result.success(result); + + return updateBlockById(blockDto, blockDto.getAppId()); } /** diff --git a/base/src/main/resources/mappers/BlockGroupBlockMapper.xml b/base/src/main/resources/mappers/BlockGroupBlockMapper.xml index 34df2193..1adf5c70 100644 --- a/base/src/main/resources/mappers/BlockGroupBlockMapper.xml +++ b/base/src/main/resources/mappers/BlockGroupBlockMapper.xml @@ -98,6 +98,6 @@ UPDATE block_id = VALUES (block_id), block_group_id = - VALUES (block_group_id) + VALUES (block_group_id); diff --git a/base/src/test/java/com/tinyengine/it/common/exception/GlobalExceptionAdviceTest.java b/base/src/test/java/com/tinyengine/it/common/exception/GlobalExceptionAdviceTest.java index 16ffb2bc..fb078966 100644 --- a/base/src/test/java/com/tinyengine/it/common/exception/GlobalExceptionAdviceTest.java +++ b/base/src/test/java/com/tinyengine/it/common/exception/GlobalExceptionAdviceTest.java @@ -36,8 +36,9 @@ class GlobalExceptionAdviceTest { @Test void testHandleException() { - Result> result = globalExceptionAdvice.handleException(new Exception("message", - new Throwable("message"))); + // 创建一个新的异常对象并传递给 handleException + Exception e = new Exception("message", new Throwable("message")); + Result> result = globalExceptionAdvice.handleException(e); Assertions.assertEquals(ExceptionEnum.CM001.getResultMsg(), result.getMessage()); Assertions.assertEquals(ExceptionEnum.CM001.getResultCode(), result.getCode()); } diff --git a/base/src/test/java/com/tinyengine/it/controller/BlockControllerTest.java b/base/src/test/java/com/tinyengine/it/controller/BlockControllerTest.java index 9dc2891c..ba0bb146 100644 --- a/base/src/test/java/com/tinyengine/it/controller/BlockControllerTest.java +++ b/base/src/test/java/com/tinyengine/it/controller/BlockControllerTest.java @@ -179,11 +179,12 @@ void testGetAllBlockCategories() { @Test void testUpdateBlocks() { - when(blockService.updateBlockById(any(BlockDto.class))).thenReturn(1); BlockDto returnData = new BlockDto(); + when(blockService.updateBlockById(any(BlockDto.class), anyInt())).thenReturn(Result.success(returnData)); + when(blockService.queryBlockById(anyInt())).thenReturn(returnData); - Result result = blockController.updateBlocks(returnData, Integer.valueOf(0)); + Result result = blockController.updateBlocks(returnData, Integer.valueOf(0), Integer.valueOf(1)); Assertions.assertEquals(returnData, result.getData()); } } diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java index 256ede34..ee5d586d 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java @@ -129,14 +129,15 @@ void testCreateBlock() { @Test void testUpdateBlockById() { - when(blockMapper.updateBlockById(any())).thenReturn(1); BlockDto blockDto = new BlockDto(); - blockDto.setId(1); - blockDto.setName("BlockTest1"); - blockDto.setScreenshot("aa"); - blockDto.setLabel("bb"); - Integer result = blockServiceImpl.updateBlockById(blockDto); - Assertions.assertEquals(1, result); + when(blockMapper.updateBlockById(any())).thenReturn(1); + when(blockMapper.findBlockAndGroupAndHistoByBlockId(anyInt())).thenReturn(new BlockDto()); + Block block = new Block(); + block.setAppId(1); + when(blockMapper.queryBlockById(blockDto.getId())).thenReturn(block); + + Result result = blockServiceImpl.updateBlockById(blockDto,1); + Assertions.assertEquals(null, result.getData()); } @Test @@ -246,7 +247,7 @@ void testGetNotInGroupBlocks() { List blockGroups = new ArrayList<>(); when(blockMapper.findBlocksReturn(notGroupDto)).thenReturn(mockData); when(userMapper.queryUserById(anyInt())).thenReturn(new User()); - when(blockGroupMapper.findBlockGroupByBlockId(blockDto.getId())).thenReturn(blockGroups); + when(blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(),blockDto.getCreatedBy())).thenReturn(blockGroups); List result = blockServiceImpl.getNotInGroupBlocks(notGroupDto); Assertions.assertEquals(new ArrayList<>(), result); From ed7483d1e4f0ec535278833039d55dde399043ad Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 23 Jan 2025 02:28:41 -0800 Subject: [PATCH 09/72] fix: Modify code format --- .../it/controller/BlockController.java | 2 -- .../mapper/BlockCarriersRelationMapper.java | 19 ++++++++----------- .../it/mapper/BlockGroupMapper.java | 2 +- .../it/model/dto/BlockGroupDto.java | 1 - .../tinyengine/it/model/dto/NotGroupDto.java | 2 -- .../service/app/impl/AiChatServiceImpl.java | 19 ++++++++++++++----- .../service/app/impl/v1/AppV1ServiceImpl.java | 1 - .../material/impl/BlockGroupServiceImpl.java | 14 +++++++------- .../material/impl/BlockServiceImpl.java | 2 +- .../impl/BlockGroupServiceImplTest.java | 1 - .../material/impl/BlockServiceImplTest.java | 7 +++---- 11 files changed, 34 insertions(+), 36 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/BlockController.java b/base/src/main/java/com/tinyengine/it/controller/BlockController.java index 1b737136..1f1fdd18 100644 --- a/base/src/main/java/com/tinyengine/it/controller/BlockController.java +++ b/base/src/main/java/com/tinyengine/it/controller/BlockController.java @@ -14,7 +14,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.tinyengine.it.common.base.Result; -import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.common.log.SystemControllerLog; import com.tinyengine.it.mapper.BlockMapper; import com.tinyengine.it.mapper.TenantMapper; @@ -46,7 +45,6 @@ import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; diff --git a/base/src/main/java/com/tinyengine/it/mapper/BlockCarriersRelationMapper.java b/base/src/main/java/com/tinyengine/it/mapper/BlockCarriersRelationMapper.java index 75be087a..7162a576 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/BlockCarriersRelationMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/BlockCarriersRelationMapper.java @@ -16,7 +16,6 @@ import com.tinyengine.it.model.entity.BlockCarriersRelation; import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; import java.util.List; @@ -44,10 +43,10 @@ public interface BlockCarriersRelationMapper extends BaseMapper queryBlockCarriersRelationByCondition(BlockCarriersRelation BlockCarriersRelation); + List queryBlockCarriersRelationByCondition(BlockCarriersRelation blockCarriersRelation); /** * 根据主键id删除表t_block_carriers_relation数据 @@ -60,31 +59,29 @@ public interface BlockCarriersRelationMapper extends BaseMapper { @Select("select * from t_block_group bg " + "left join r_block_group_block bgb on bgb.block_group_id = bg.id " + "where bgb.block_id = #{blockId} and created_by = #{createdBy}") - List findBlockGroupByBlockId(Integer blockId,String createdBy); + List findBlockGroupByBlockId(Integer blockId, String createdBy); } \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/model/dto/BlockGroupDto.java b/base/src/main/java/com/tinyengine/it/model/dto/BlockGroupDto.java index ee0887c8..cdd8819b 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/BlockGroupDto.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/BlockGroupDto.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.tinyengine.it.common.base.BaseEntity; import com.tinyengine.it.model.entity.App; -import com.tinyengine.it.model.entity.Block; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/base/src/main/java/com/tinyengine/it/model/dto/NotGroupDto.java b/base/src/main/java/com/tinyengine/it/model/dto/NotGroupDto.java index 09bcca6b..451dd26e 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/NotGroupDto.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/NotGroupDto.java @@ -15,8 +15,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.util.List; - /** *

* 条件查询不在区块分组参数 diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java index eb887956..97fc1434 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java @@ -14,6 +14,8 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.common.enums.Enums; +import com.tinyengine.it.common.exception.ExceptionEnum; +import com.tinyengine.it.common.exception.ServiceException; import com.tinyengine.it.common.log.SystemServiceLog; import com.tinyengine.it.gateway.ai.AiChatClient; import com.tinyengine.it.model.dto.AiMessages; @@ -89,15 +91,19 @@ public Result> getAnswerFromAi(AiParam aiParam) { } List> choices = (List>) data.get("choices"); Map message = (Map) choices.get(0).get("message"); - boolean isFinish = false; + String answerContent = ""; - isFinish = choices.get(0).get("finish_reason") != null || isFinish; + String isFinish = ""; + Object finishReason = choices.get(0).get("finish_reason"); + if (finishReason instanceof String) { + isFinish = (String) finishReason; + } if (!"length".equals(isFinish)) { answerContent = message.get("content"); } // 若内容被截断,继续请求AI - while (isFinish) { + while ("length".equals(isFinish)) { String prefix = message.get("content"); answerContent = answerContent + prefix; @@ -115,12 +121,15 @@ public Result> getAnswerFromAi(AiParam aiParam) { try { data = requestAnswerFromAi(aiParam.getMessages(), model).getData(); } catch (Exception e) { - e.printStackTrace(); + new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg()); } choices = (List>) data.get("choices"); message = (Map) choices.get(0).get("message"); answerContent += message.get("content"); - isFinish = (boolean) choices.get(0).get("finish_reason"); + finishReason = choices.get(0).get("finish_reason"); + if (finishReason instanceof String) { + isFinish = (String) finishReason; + } } diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java index e75bec94..05345f0b 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java @@ -32,7 +32,6 @@ import com.tinyengine.it.model.dto.I18nEntryDto; import com.tinyengine.it.model.dto.MaterialHistoryMsg; import com.tinyengine.it.model.dto.MetaDto; -import com.tinyengine.it.model.dto.SchemaDataSource; import com.tinyengine.it.model.dto.SchemaDto; import com.tinyengine.it.model.dto.SchemaI18n; import com.tinyengine.it.model.dto.SchemaMeta; diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java index 24aef050..e06537d4 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java @@ -187,17 +187,17 @@ public List getBlockGroupByIdsOrAppId(List ids, Integer app } // 对查询的结果的区块赋值current_version for (BlockGroup blockGroupTemp : blockGroupsListResult) { - for (Block block: blockGroupTemp.getBlocks()){ + for (Block block : blockGroupTemp.getBlocks()) { BlockCarriersRelation queryParam = new BlockCarriersRelation(); queryParam.setBlockId(block.getId()); queryParam.setHostId(blockGroup.getId()); queryParam.setHostType(Enums.BlockGroup.BLOCK_GROUP.getValue()); - List blockCarriersRelations = blockCarriersRelationMapper.queryBlockCarriersRelationByCondition(queryParam); - if (blockCarriersRelations.isEmpty()){ - continue; - } - String version = blockCarriersRelations.get(0).getVersion(); - block.setCurrentVersion(version); + List blockCarriersRelations = blockCarriersRelationMapper.queryBlockCarriersRelationByCondition(queryParam); + if (blockCarriersRelations.isEmpty()) { + continue; + } + String version = blockCarriersRelations.get(0).getVersion(); + block.setCurrentVersion(version); } } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java index 2e824198..464f1676 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java @@ -153,7 +153,7 @@ public Integer deleteBlockById(@Param("id") Integer id) { @Override public Result updateBlockById(BlockDto blockDto, Integer appId) { Block blockResult = blockMapper.queryBlockById(blockDto.getId()); - if (blockResult.getAppId() != appId) { + if (!Objects.equals(blockResult.getAppId(), appId)) { return Result.failed(ExceptionEnum.CM007); } // 把前端传参赋值给实体 diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java index 9e92239d..99305c57 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java @@ -28,7 +28,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; import java.util.Arrays; diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java index ee5d586d..7cabdb16 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java @@ -23,7 +23,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.core.JsonProcessingException; import com.tinyengine.it.common.base.Result; -import com.tinyengine.it.common.enums.Enums; import com.tinyengine.it.mapper.AppMapper; import com.tinyengine.it.mapper.BlockGroupMapper; import com.tinyengine.it.mapper.BlockMapper; @@ -136,7 +135,7 @@ void testUpdateBlockById() { block.setAppId(1); when(blockMapper.queryBlockById(blockDto.getId())).thenReturn(block); - Result result = blockServiceImpl.updateBlockById(blockDto,1); + Result result = blockServiceImpl.updateBlockById(blockDto, 1); Assertions.assertEquals(null, result.getData()); } @@ -243,11 +242,11 @@ void testAllTags() { void testGetNotInGroupBlocks() { BlockDto blockDto = new BlockDto(); List mockData = Arrays.asList(blockDto); - NotGroupDto notGroupDto =new NotGroupDto(); + NotGroupDto notGroupDto = new NotGroupDto(); List blockGroups = new ArrayList<>(); when(blockMapper.findBlocksReturn(notGroupDto)).thenReturn(mockData); when(userMapper.queryUserById(anyInt())).thenReturn(new User()); - when(blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(),blockDto.getCreatedBy())).thenReturn(blockGroups); + when(blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(), blockDto.getCreatedBy())).thenReturn(blockGroups); List result = blockServiceImpl.getNotInGroupBlocks(notGroupDto); Assertions.assertEquals(new ArrayList<>(), result); From cabb3093640b7c72d6e1638ec884e72e2c4f5750 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 23 Jan 2025 02:36:13 -0800 Subject: [PATCH 10/72] fix: Modify code format --- .../src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java index f632d886..9b92094b 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java @@ -146,7 +146,6 @@ public interface BlockGroupMapper extends BaseMapper { @Select("select * from t_block_group bg " + "left join r_block_group_block bgb on bgb.block_group_id = bg.id " + "where bgb.block_id = #{blockId} and created_by = #{createdBy}") - List findBlockGroupByBlockId(Integer blockId,String createdBy); } \ No newline at end of file From 83cb48a37581bf787c52c02315328f24f71af80c Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 23 Jan 2025 18:37:12 -0800 Subject: [PATCH 11/72] fix: Modify code format --- .../java/com/tinyengine/it/controller/BlockController.java | 2 +- .../main/java/com/tinyengine/it/mapper/BlockGroupMapper.java | 2 +- .../tinyengine/it/service/app/impl/AiChatServiceImpl.java | 5 +++-- .../it/service/app/impl/AiChatServiceImplTest.java | 2 +- .../it/service/material/impl/BlockServiceImplTest.java | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/BlockController.java b/base/src/main/java/com/tinyengine/it/controller/BlockController.java index 1f1fdd18..54c15b1f 100644 --- a/base/src/main/java/com/tinyengine/it/controller/BlockController.java +++ b/base/src/main/java/com/tinyengine/it/controller/BlockController.java @@ -399,7 +399,7 @@ public Result> getBlockGroups( public Result updateBlocks(@Valid @RequestBody BlockDto blockDto, @PathVariable Integer id, @RequestParam(value = "appId", required = false) Integer appId) { blockDto.setId(id); - return blockService.updateBlockById(blockDto,appId); + return blockService.updateBlockById(blockDto, appId); } /** diff --git a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java index 9b92094b..25790ccf 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java @@ -146,6 +146,6 @@ public interface BlockGroupMapper extends BaseMapper { @Select("select * from t_block_group bg " + "left join r_block_group_block bgb on bgb.block_group_id = bg.id " + "where bgb.block_id = #{blockId} and created_by = #{createdBy}") - List findBlockGroupByBlockId(Integer blockId,String createdBy); + List findBlockGroupByBlockId(Integer blockId, String createdBy); } \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java index 97fc1434..08191e17 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java @@ -121,11 +121,12 @@ public Result> getAnswerFromAi(AiParam aiParam) { try { data = requestAnswerFromAi(aiParam.getMessages(), model).getData(); } catch (Exception e) { - new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg()); + throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg()); } choices = (List>) data.get("choices"); message = (Map) choices.get(0).get("message"); - answerContent += message.get("content"); + StringBuilder sb = new StringBuilder(); + answerContent = String.valueOf(sb.append(message.get("content"))); finishReason = choices.get(0).get("finish_reason"); if (finishReason instanceof String) { isFinish = (String) finishReason; diff --git a/base/src/test/java/com/tinyengine/it/service/app/impl/AiChatServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/app/impl/AiChatServiceImplTest.java index 92a01b1a..76ad7a7b 100644 --- a/base/src/test/java/com/tinyengine/it/service/app/impl/AiChatServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/app/impl/AiChatServiceImplTest.java @@ -87,7 +87,7 @@ void testGetAnswerFromAi() { Map response = new HashMap<>(); response.put("data", dataMap); - response.put("result",(String) ""); + response.put("result", (String) ""); when(aiChatClient.executeChatRequest(any(OpenAiBodyDto.class))).thenReturn(response); Result> result = aiChatServiceImpl.getAnswerFromAi(aiParam); Map resultData = result.getData(); diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java index c72031dc..7cabdb16 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockServiceImplTest.java @@ -135,7 +135,7 @@ void testUpdateBlockById() { block.setAppId(1); when(blockMapper.queryBlockById(blockDto.getId())).thenReturn(block); - Result result = blockServiceImpl.updateBlockById(blockDto,1); + Result result = blockServiceImpl.updateBlockById(blockDto, 1); Assertions.assertEquals(null, result.getData()); } @@ -246,7 +246,7 @@ void testGetNotInGroupBlocks() { List blockGroups = new ArrayList<>(); when(blockMapper.findBlocksReturn(notGroupDto)).thenReturn(mockData); when(userMapper.queryUserById(anyInt())).thenReturn(new User()); - when(blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(),blockDto.getCreatedBy())).thenReturn(blockGroups); + when(blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(), blockDto.getCreatedBy())).thenReturn(blockGroups); List result = blockServiceImpl.getNotInGroupBlocks(notGroupDto); Assertions.assertEquals(new ArrayList<>(), result); From 48645e1f0f86b4ec8df6ebe1cf6537508d3883a8 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 26 Jan 2025 00:14:37 -0800 Subject: [PATCH 12/72] fix: modify block group api --- .github/workflows/checkstyle.yml | 45 ++++ app/src/main/resources/checkstyle.xml | 226 ++++++++++++++++++ .../it/common/base/PageQueryVo.java | 2 +- .../it/controller/PageController.java | 4 +- .../it/mapper/BlockGroupMapper.java | 28 +-- .../it/mapper/BlockHistoryMapper.java | 4 +- .../com/tinyengine/it/mapper/BlockMapper.java | 19 +- .../com/tinyengine/it/model/dto/BlockDto.java | 4 - .../com/tinyengine/it/model/entity/Block.java | 4 - .../service/app/impl/v1/AppV1ServiceImpl.java | 2 +- .../material/impl/BlockGroupServiceImpl.java | 12 +- .../material/impl/BlockServiceImpl.java | 15 +- .../resources/mappers/BlockGroupMapper.xml | 29 ++- .../main/resources/mappers/BlockMapper.xml | 38 +-- .../impl/BlockGroupServiceImplTest.java | 6 +- .../material/impl/BlockServiceImplTest.java | 2 +- pom.xml | 31 ++- 17 files changed, 382 insertions(+), 89 deletions(-) create mode 100644 .github/workflows/checkstyle.yml create mode 100644 app/src/main/resources/checkstyle.xml diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml new file mode 100644 index 00000000..e1e7ad25 --- /dev/null +++ b/.github/workflows/checkstyle.yml @@ -0,0 +1,45 @@ +name: Checkstyle Code Quality + +on: + push: + branches: + - develop # 或者你想要检查的分支 + pull_request: + branches: + - develop # 你可以在 PR 时检查代码 + +jobs: + check: + runs-on: ubuntu-24.04 + + steps: + # 检出代码 + - name: Checkout code + uses: actions/checkout@v4 + + # 设置 JDK(如果是 Java 项目) + - name: Set up JDK 8.* + uses: actions/setup-java@v4 + with: + java-version: '8.*' + + # 安装 Checkstyle(如果你是用 Maven 或 Gradle) + - name: Install dependencies + run: | + ./mvnw install # 如果是 Maven 项目 + # 或者 + # ./gradlew build # 如果是 Gradle 项目 + + # 运行 Checkstyle + - name: Run Checkstyle + run: | + ./mvnw checkstyle:check # 如果是 Maven 项目 + # 或者 + # ./gradlew check # 如果是 Gradle 项目 + + # 查看 Checkstyle 检查报告 + - name: Upload Checkstyle report + uses: actions/upload-artifact@v4 + with: + name: checkstyle-report + path: target/checkstyle-result.xml # 如果是 Maven 项目 \ No newline at end of file diff --git a/app/src/main/resources/checkstyle.xml b/app/src/main/resources/checkstyle.xml new file mode 100644 index 00000000..c0d6cc9e --- /dev/null +++ b/app/src/main/resources/checkstyle.xml @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/common/base/PageQueryVo.java b/base/src/main/java/com/tinyengine/it/common/base/PageQueryVo.java index 551beae9..9eb6df88 100644 --- a/base/src/main/java/com/tinyengine/it/common/base/PageQueryVo.java +++ b/base/src/main/java/com/tinyengine/it/common/base/PageQueryVo.java @@ -96,7 +96,7 @@ public void setData(T data) { /** * 分页查询对象 - * + * @param 泛型类型参数 E,代表分页数据的类型 * @return page */ public Page getPage() { diff --git a/base/src/main/java/com/tinyengine/it/controller/PageController.java b/base/src/main/java/com/tinyengine/it/controller/PageController.java index d840cef0..8fefcb94 100644 --- a/base/src/main/java/com/tinyengine/it/controller/PageController.java +++ b/base/src/main/java/com/tinyengine/it/controller/PageController.java @@ -71,8 +71,8 @@ public class PageController { * @return allpage */ @Operation(summary = "获取页面列表", description = "获取页面列表", parameters = { - @Parameter(name = "aid", description = "appId")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", + @Parameter(name = "aid", description = "appId")}, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Page.class))), @ApiResponse(responseCode = "400", description = "请求失败")}) diff --git a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java index 25790ccf..2ddca53d 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/BlockGroupMapper.java @@ -33,11 +33,11 @@ public interface BlockGroupMapper extends BaseMapper { /** * 查询表t_block_group所有信息及关联的区块信息 - * - * @param createdBy createdBy + * @param blockCreatedBy the blockCreatedBy + * @param groupCreatedBy the groupCreatedBy * @return the list */ - List queryAllBlockGroupAndBlock(String createdBy); + List queryAllBlockGroupAndBlock(String blockCreatedBy, String groupCreatedBy); /** * 查询表t_block_group所有信息 @@ -51,10 +51,11 @@ public interface BlockGroupMapper extends BaseMapper { * 根据主键id查询表t_block_group数据 * * @param id the id - * @param createdBy createdBy + * @param blockCreatedBy the lockCreatedBy + * @param groupCreatedBy the groupCreatedBy * @return the block group */ - BlockGroup queryBlockGroupAndBlockById(@Param("id") Integer id, String createdBy); + BlockGroup queryBlockGroupAndBlockById(@Param("id") Integer id, String blockCreatedBy, String groupCreatedBy); /** * 通过ID查询分组信息 @@ -101,10 +102,11 @@ public interface BlockGroupMapper extends BaseMapper { * 通过appId和createdBy查区块分组关联的区块信息 * * @param appId the app id - * @param createdBy createdBy + * @param blockCreatedBy the blockCreatedBy + * @param groupCreatedBy the groupCreatedBy * @return the list */ - List queryBlockGroupByAppId(Integer appId, String createdBy); + List queryBlockGroupByAppId(Integer appId, String blockCreatedBy, String groupCreatedBy); /** * 通过appId获取分组信息 @@ -125,15 +127,13 @@ public interface BlockGroupMapper extends BaseMapper { @Result(column = "app", property = "appId"), @Result(column = "app", property = "app", one = @One(select = "com.tinyengine.it.mapper.AppMapper.queryAppById")), - @Result(column = "block_group_id", javaType = List.class, property = "blocks", - many = @Many(select = "com.tinyengine.it.mapper.BlockMapper.findBlocksByBlockGroupId")) + @Result(column = "id", javaType = List.class, property = "blocks", + many = @Many(select = "com.tinyengine.it.mapper.BlockMapper.findBlockByBlockGroupId")) }) - @Select("SELECT bg.*, bs.block_group_id as block_group_id, a.id as app " + @Select("SELECT bg.*, a.id as app " + "FROM t_block_group bg " + "left join t_app a on bg.app_id = a.id " - + "left join t_block bs on bg.id = bs.block_group_id " - + "WHERE bg.id = #{blockGroupId} " - + "GROUP BY bg.id") + + "WHERE bg.id = #{blockGroupId} ") List getBlockGroupsById(int blockGroupId); @@ -145,7 +145,7 @@ public interface BlockGroupMapper extends BaseMapper { */ @Select("select * from t_block_group bg " + "left join r_block_group_block bgb on bgb.block_group_id = bg.id " - + "where bgb.block_id = #{blockId} and created_by = #{createdBy}") + + "where bgb.block_id = #{blockId} and bg.created_by = #{createdBy}") List findBlockGroupByBlockId(Integer blockId, String createdBy); } \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/mapper/BlockHistoryMapper.java b/base/src/main/java/com/tinyengine/it/mapper/BlockHistoryMapper.java index 89f61550..1b6dcdfc 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/BlockHistoryMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/BlockHistoryMapper.java @@ -104,8 +104,10 @@ public interface BlockHistoryMapper extends BaseMapper { */ @Select({""}) List queryBlockAndVersion(@Param("ids") List ids, @Param("materialHistoryId") Integer materialHistoryId); diff --git a/base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java b/base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java index 6a449823..debca3cd 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java @@ -79,16 +79,6 @@ public interface BlockMapper extends BaseMapper { */ Integer createBlock(Block block); - /** - * 通过区块分组id获取区块信息 - * - * @param blockGroupId the block group id - * @return the list - */ - @Select("select b.* from t_block b " - + "where b.block_group_id = #{blockGroupId} ") - List findBlocksByBlockGroupId(int blockGroupId); - /** * 根据name或者description查询表t_block信息 * @@ -118,10 +108,7 @@ public interface BlockMapper extends BaseMapper { }) @Select("select b.*, b.id as block_id " + "from t_block b " - + "left join t_block_group bg on b.block_group_id = bg.id " - + "left join t_block_history bh on b.latest_history_id = bh.id " - + "where b.id = #{blockId} " - + "group by b.id") + + "where b.id = #{blockId} ") BlockDto findBlockAndGroupAndHistoByBlockId(Integer blockId); @@ -156,7 +143,7 @@ public interface BlockMapper extends BaseMapper { List findBlocksByBlockGroupIdAppId(int appId); /** - * 根据分组id返回对应的区块信息及关联分组信息 + * 根据条件返回对应的区块信息及关联分组信息 * * @return the list */ @@ -191,7 +178,5 @@ public interface BlockMapper extends BaseMapper { * @param createdBy createdBy * @return the list */ - @Select("select b.* from t_block b " - + "where b.block_group_id = #{blockGroupId} and b.created_by = #{createdBy}") List findBlockByBlockGroupId(int blockGroupId, String createdBy); } \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/model/dto/BlockDto.java b/base/src/main/java/com/tinyengine/it/model/dto/BlockDto.java index de9940e3..b0c0fc6e 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/BlockDto.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/BlockDto.java @@ -123,10 +123,6 @@ public class BlockDto extends BaseEntity { @JsonProperty("platform_id") private Integer platformId; - @Schema(name = "blockGroupId", description = "区块分组id,关联t_block_group表id") - @JsonProperty("block_group_id") - private Integer blockGroupId; - @JsonProperty("occupier") @Schema(name = "occupierBy", description = "当前锁定人") private User occupier; diff --git a/base/src/main/java/com/tinyengine/it/model/entity/Block.java b/base/src/main/java/com/tinyengine/it/model/entity/Block.java index 37ceb6ed..dd063cd1 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/Block.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/Block.java @@ -127,10 +127,6 @@ public class Block extends BaseEntity { @JsonProperty("content_blocks") private String contentBlocks; - @Schema(name = "blockGroupId", description = "区块分组id,关联t_block_group表id") - @JsonProperty("block_group_id") - private Integer blockGroupId; - @TableField(exist = false) @JsonProperty("public_scope_tenants") private List publicScopeTenants = new ArrayList<>(); diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java index 05345f0b..58270f05 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java @@ -362,7 +362,7 @@ public List getBlockHistoryIdBySemver(List blocksVersi historyMap.put(version, item.getHistoryId()); itemMap.put("historyMap", historyMap); itemMap.put("versions", versionList); - blocksVersionMap.put("blockId", itemMap); + blocksVersionMap.put(String.valueOf(item.getBlockId()), itemMap); } // 遍历区块历史记录 综合信息映射关系 diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java index e06537d4..70e0eac0 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java @@ -164,22 +164,23 @@ public Result> createBlockGroup(BlockGroup blockGroup) { */ @Override public List getBlockGroupByIdsOrAppId(List ids, Integer appId, String from) { - String createdBy = "1"; // 获取登录用户信息 // 此接收到的两个参数不一定同时存在 List blockGroupsListResult = new ArrayList<>(); - createdBy = (Enums.BlockGroup.BLOCK.getValue()).equals(from) ? createdBy : null; // from值为block在区块管理处增加createdBy条件 + String groupCreatedBy = "1"; // 获取登录用户id + String blockCreatedBy = "1"; + blockCreatedBy = (Enums.BlockGroup.BLOCK.getValue()).equals(from) ? blockCreatedBy : null; // from值为block在区块管理处增加createdBy条件 BlockGroup blockGroup = new BlockGroup(); if (ids != null) { for (int blockgroupId : ids) { - blockGroup = blockGroupMapper.queryBlockGroupAndBlockById(blockgroupId, createdBy); + blockGroup = blockGroupMapper.queryBlockGroupAndBlockById(blockgroupId, blockCreatedBy, groupCreatedBy); blockGroupsListResult.add(blockGroup); } } if (appId != null) { - blockGroupsListResult = blockGroupMapper.queryBlockGroupByAppId(appId, createdBy); + blockGroupsListResult = blockGroupMapper.queryBlockGroupByAppId(appId, blockCreatedBy, groupCreatedBy); } if (ids == null && appId == null) { - blockGroupsListResult = blockGroupMapper.queryAllBlockGroupAndBlock(createdBy); + blockGroupsListResult = blockGroupMapper.queryAllBlockGroupAndBlock( blockCreatedBy, groupCreatedBy); } if (blockGroupsListResult.isEmpty()) { @@ -216,7 +217,6 @@ private Integer getBlockGroupIds(List groupBlockIds, List para int result = 0; if (groupBlockIds.size() > paramIds.size()) { Block block = new Block(); - block.setBlockGroupId(null); for (Integer blockId : groupBlockIds) { if (!paramIds.contains(blockId)) { result = blockId; diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java index 11569c48..d2eb05b8 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java @@ -226,20 +226,21 @@ public Result createBlock(BlockDto blockDto) { blocks.setIsDefault(false); blocks.setIsOfficial(false); blocks.setPlatformId(1); // 新建区块给默认值 + + int result = blockMapper.createBlock(blocks); + if (result < 1) { + return Result.failed(ExceptionEnum.CM001); + } + int id = blocks.getId(); + BlockDto blocksResult = queryBlockById(id); List groups = blockDto.getGroups(); if (!groups.isEmpty() && groups.get(0) instanceof Integer) { Integer groupId = (Integer) groups.get(0); // 强制类型转换 BlockGroupBlock blockGroupBlock = new BlockGroupBlock(); blockGroupBlock.setBlockGroupId(groupId); - blockGroupBlock.setBlockId(blockDto.getId()); + blockGroupBlock.setBlockId(id); blockGroupBlockMapper.createBlockGroupBlock(blockGroupBlock); } - int result = blockMapper.createBlock(blocks); - if (result < 1) { - return Result.failed(ExceptionEnum.CM001); - } - int id = blocks.getId(); - BlockDto blocksResult = queryBlockById(id); return Result.success(blocksResult); } diff --git a/base/src/main/resources/mappers/BlockGroupMapper.xml b/base/src/main/resources/mappers/BlockGroupMapper.xml index b7f2daaa..51eaad35 100644 --- a/base/src/main/resources/mappers/BlockGroupMapper.xml +++ b/base/src/main/resources/mappers/BlockGroupMapper.xml @@ -185,12 +185,17 @@ r_block_group_block rbg ON rbg.block_group_id = bg.id LEFT JOIN t_block b ON b.id = rbg.block_id - - AND b.created_by = #{createdBy} + + AND b.created_by = #{blockCreatedBy} - + AND b.last_build_info is not null and b.content is not null and b.assets is not null + + + AND bg.created_by = #{groupCreatedBy} + + @@ -244,16 +249,19 @@ r_block_group_block rbg ON rbg.block_group_id = bg.id LEFT JOIN t_block b ON b.id = rbg.block_id - - AND b.created_by = #{createdBy} + + AND b.created_by = #{blockCreatedBy} - + AND b.last_build_info is not null and b.content is not null and b.assets is not null AND bg.app_id = #{appId} + + AND bg.created_by = #{groupCreatedBy} + @@ -307,16 +315,19 @@ r_block_group_block rbg ON rbg.block_group_id = bg.id LEFT JOIN t_block b ON b.id = rbg.block_id - - AND b.created_by = #{createdBy} + + AND b.created_by = #{blockCreatedBy} - + AND b.last_build_info is not null and b.content is not null and b.assets is not null AND bg.id = #{id} + + AND bg.created_by = #{groupCreatedBy} + diff --git a/base/src/main/resources/mappers/BlockMapper.xml b/base/src/main/resources/mappers/BlockMapper.xml index 7d08fbf5..c6a8a47b 100644 --- a/base/src/main/resources/mappers/BlockMapper.xml +++ b/base/src/main/resources/mappers/BlockMapper.xml @@ -9,7 +9,7 @@ id , label, name, framework, content, assets, last_build_info, description, tags, latest_version, latest_history_id, screenshot, path, occupier_by, is_official, `public`, is_default, tiny_reserved, npm_name, - i18n, platform_id, app_id, content_blocks, block_group_id, created_by, last_updated_by, created_time, + i18n, platform_id, app_id, content_blocks, created_by, last_updated_by, created_time, last_updated_time, tenant_id, renter_id, site_id @@ -81,9 +81,6 @@ AND content_blocks = #{contentBlocks} - - AND block_group_id = #{blockGroupId} - AND created_by = #{createdBy} @@ -175,9 +172,6 @@ content_blocks = #{contentBlocks}, - - block_group_id = #{blockGroupId}, - created_by = #{createdBy}, @@ -227,7 +221,6 @@ - @@ -267,14 +260,27 @@ + - + + SELECT + + FROM t_component_library + + + + + + + + + + + DELETE + FROM t_component_library + WHERE id = #{id} + + + + + UPDATE t_component_library + + + + WHERE + id=#{id} + + + + + INSERT INTO t_component_library ( id + , version + , `name` + , package + , registry + , framework + , description + , script + , css + , bundle + , dependencies + , `others` + , thumbnail + , `public` + , is_started + , is_official + , is_default + , created_by + , last_updated_by + , created_time + , last_updated_time + , tenant_id + , renter_id + , site_id) + VALUES ( #{id} + , #{version} + , #{name} + , #{packageName} + , #{registry} + , #{framework} + , #{description} + , #{script} + , #{css} + , #{bundle} + , #{dependencies} + , #{others} + , #{thumbnail} + , #{publicStatus} + , #{isStarted} + , #{isOfficial} + , #{isDefault} + , #{createdBy} + , #{lastUpdatedBy} + , #{createdTime} + , #{lastUpdatedTime} + , #{tenantId} + , #{renterId} + , #{siteId}) + + diff --git a/base/src/main/resources/mappers/MaterialHistoryMapper.xml b/base/src/main/resources/mappers/MaterialHistoryMapper.xml index 889dab52..f91843aa 100644 --- a/base/src/main/resources/mappers/MaterialHistoryMapper.xml +++ b/base/src/main/resources/mappers/MaterialHistoryMapper.xml @@ -8,7 +8,7 @@ id , ref_id, version, content, name, npm_name, framework, assets_url, image_url, build_info, description, - material_size, tgz_url, unzip_tgz_root_path_url, unzip_tgz_files, created_by, last_updated_by, created_time, + material_size, tgz_url, unzip_tgz_root_path_url, unzip_tgz_files, is_started, created_by, last_updated_by, created_time, last_updated_time, tenant_id, renter_id, site_id @@ -56,6 +56,9 @@ AND unzip_tgz_files = #{unzipTgzFiles} + + AND is_started = #{isStarted} + AND created_by = #{createdBy} @@ -123,6 +126,9 @@ unzip_tgz_files = #{unzipTgzFiles}, + + is_started = #{isStarted}, + created_by = #{createdBy}, @@ -164,6 +170,7 @@ + @@ -210,47 +217,49 @@ INSERT INTO t_material_history ( id - , ref_id - , version - , content - , name - , npm_name - , framework - , assets_url - , image_url - , build_info - , description - , material_size - , tgz_url - , unzip_tgz_root_path_url - , unzip_tgz_files - , created_by - , last_updated_by - , created_time - , last_updated_time - , tenant_id, renter_id - , site_id) + , ref_id + , version + , content + , name + , npm_name + , framework + , assets_url + , image_url + , build_info + , description + , material_size + , tgz_url + , unzip_tgz_root_path_url + , unzip_tgz_files + , is_started + , created_by + , last_updated_by + , created_time + , last_updated_time + , tenant_id, renter_id + , site_id) VALUES ( #{id} - , #{refId} - , #{version} - , #{content} - , #{name} - , #{npmName} - , #{framework} - , #{assetsUrl} - , #{imageUrl} - , #{buildInfo} - , #{description} - , #{materialSize} - , #{tgzUrl} - , #{unzipTgzRootPathUrl} - , #{unzipTgzFiles} - , #{createdBy} - , #{lastUpdatedBy} - , #{createdTime} - , #{lastUpdatedTime} - , #{tenantId} - , #{renterId} - , #{siteId}) + , #{refId} + , #{version} + , #{content} + , #{name} + , #{npmName} + , #{framework} + , #{assetsUrl} + , #{imageUrl} + , #{buildInfo} + , #{description} + , #{materialSize} + , #{tgzUrl} + , #{unzipTgzRootPathUrl} + , #{unzipTgzFiles} + , #{isStarted} + , #{createdBy} + , #{lastUpdatedBy} + , #{createdTime} + , #{lastUpdatedTime} + , #{tenantId} + , #{renterId} + , #{siteId}) diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImplTest.java index 9f425ef8..2b9503ad 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImplTest.java @@ -1,13 +1,12 @@ /** * Copyright (c) 2023 - present TinyEngine Authors. * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. - * + *

* Use of this source code is governed by an MIT-style license. - * + *

* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. - * */ package com.tinyengine.it.service.material.impl; @@ -75,11 +74,11 @@ void testFindMaterialHistoryByCondition() { @Test void testDeleteMaterialHistoryById() { MaterialHistory param = new MaterialHistory(); - Result.success(param); when(materialHistoryMapper.deleteMaterialHistoryById(1)).thenReturn(1); when(materialHistoryMapper.queryMaterialHistoryById(1)).thenReturn(param); + Result result = materialHistoryServiceImpl.deleteMaterialHistoryById(1); - Assertions.assertEquals( Result.success(param), result); + Assertions.assertEquals(Result.success(param), result); } @Test @@ -87,6 +86,7 @@ void testUpdateMaterialHistoryById() { MaterialHistory param = new MaterialHistory(); when(materialHistoryMapper.updateMaterialHistoryById(param)).thenReturn(1); when(materialHistoryMapper.queryMaterialHistoryById(1)).thenReturn(param); + Result result = materialHistoryServiceImpl.updateMaterialHistoryById(param); Assertions.assertEquals(Result.success(param), result); } @@ -94,9 +94,9 @@ void testUpdateMaterialHistoryById() { @Test void testCreateMaterialHistory() { MaterialHistory param = new MaterialHistory(); - Result.success(param); when(materialHistoryMapper.createMaterialHistory(param)).thenReturn(1); when(materialHistoryMapper.queryMaterialHistoryById(1)).thenReturn(param); + Result result = materialHistoryServiceImpl.createMaterialHistory(param); Assertions.assertEquals(result, Result.success(param)); } diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java index 3c50e8d6..99285deb 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java @@ -1,22 +1,23 @@ /** * Copyright (c) 2023 - present TinyEngine Authors. * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. - * + *

* Use of this source code is governed by an MIT-style license. - * + *

* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. - * */ package com.tinyengine.it.service.material.impl; import static org.mockito.Mockito.when; +import com.tinyengine.it.common.base.Result; import com.tinyengine.it.mapper.MaterialMapper; import com.tinyengine.it.model.entity.Material; +import com.tinyengine.it.model.entity.MaterialHistory; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -57,8 +58,8 @@ void testQueryMaterialById() { Material mockData = new Material(); when(materialMapper.queryMaterialById(1)).thenReturn(mockData); - Material result = materialServiceImpl.queryMaterialById(1); - Assertions.assertEquals(mockData, result); + Result result = materialServiceImpl.queryMaterialById(1); + Assertions.assertEquals(Result.success(mockData), result); } @Test @@ -74,26 +75,30 @@ void testQueryMaterialByCondition() { @Test void testDeleteMaterialById() { when(materialMapper.deleteMaterialById(1)).thenReturn(2); + Material mockData = new Material(); + when(materialMapper.queryMaterialById(1)).thenReturn(mockData); - Integer result = materialServiceImpl.deleteMaterialById(1); - Assertions.assertEquals(2, result); + Result result = materialServiceImpl.deleteMaterialById(1); + Assertions.assertEquals(Result.success(mockData), result); } @Test void testUpdateMaterialById() { Material param = new Material(); when(materialMapper.updateMaterialById(param)).thenReturn(1); + when(materialMapper.queryMaterialById(1)).thenReturn(param); - Integer result = materialServiceImpl.updateMaterialById(param); - Assertions.assertEquals(1, result); + Result result = materialServiceImpl.updateMaterialById(param); + Assertions.assertEquals(Result.success(param), result); } @Test void testCreateMaterial() { Material param = new Material(); when(materialMapper.createMaterial(param)).thenReturn(1); + when(materialMapper.queryMaterialById(1)).thenReturn(param); - Integer result = materialServiceImpl.createMaterial(param); - Assertions.assertEquals(1, result); + Result result = materialServiceImpl.createMaterial(param); + Assertions.assertEquals(Result.success(param), result); } } From 05f4473e6b12c4f110dabd2183b8da8b43d74a25 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 6 Apr 2025 19:05:24 -0700 Subject: [PATCH 36/72] feat: component library api --- ...tarted_column_to_t_material_history.h2.sql | 2 - ...ted_column_to_t_material_history.mysql.sql | 2 - .../com/tinyengine/it/common/utils/Utils.java | 17 +- .../it/controller/ComponentController.java | 29 ++- .../ComponentLibraryController.java | 26 +-- .../it/controller/MaterialController.java | 18 +- .../it/mapper/ComponentLibraryMapper.java | 42 +--- .../it/model/dto/BundleMaterial.java | 3 +- .../it/model/dto/BundleResultDto.java | 30 +++ .../it/model/dto/CustComponentDto.java | 29 +++ .../tinyengine/it/model/dto/PackagesDto.java | 36 +++ .../tinyengine/it/model/dto/SchemaDto.java | 1 + .../tinyengine/it/model/entity/Component.java | 4 +- .../it/model/entity/ComponentLibrary.java | 9 +- .../it/model/entity/MaterialHistory.java | 3 - .../service/app/impl/v1/AppV1ServiceImpl.java | 35 +++ .../it/service/material/ComponentService.java | 9 +- .../material/impl/ComponentServiceImpl.java | 135 ++++++++---- .../impl/MaterialHistoryServiceImpl.java | 11 +- .../mappers/ComponentLibraryMapper.xml | 208 +++++++++++++++--- .../mappers/MaterialHistoryMapper.xml | 11 +- .../app/impl/v1/AppV1ServiceImplTest.java | 11 +- 22 files changed, 495 insertions(+), 176 deletions(-) delete mode 100644 app/src/main/resources/sql/h2/add_is_started_column_to_t_material_history.h2.sql delete mode 100644 app/src/main/resources/sql/mysql/add_is_started_column_to_t_material_history.mysql.sql create mode 100644 base/src/main/java/com/tinyengine/it/model/dto/BundleResultDto.java create mode 100644 base/src/main/java/com/tinyengine/it/model/dto/CustComponentDto.java create mode 100644 base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java diff --git a/app/src/main/resources/sql/h2/add_is_started_column_to_t_material_history.h2.sql b/app/src/main/resources/sql/h2/add_is_started_column_to_t_material_history.h2.sql deleted file mode 100644 index 80ff1574..00000000 --- a/app/src/main/resources/sql/h2/add_is_started_column_to_t_material_history.h2.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE t_material_history - ADD COLUMN is_started TINYINT(1) DEFAULT 0; \ No newline at end of file diff --git a/app/src/main/resources/sql/mysql/add_is_started_column_to_t_material_history.mysql.sql b/app/src/main/resources/sql/mysql/add_is_started_column_to_t_material_history.mysql.sql deleted file mode 100644 index 80ff1574..00000000 --- a/app/src/main/resources/sql/mysql/add_is_started_column_to_t_material_history.mysql.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE t_material_history - ADD COLUMN is_started TINYINT(1) DEFAULT 0; \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/common/utils/Utils.java b/base/src/main/java/com/tinyengine/it/common/utils/Utils.java index 1d3b3eb0..bf173001 100644 --- a/base/src/main/java/com/tinyengine/it/common/utils/Utils.java +++ b/base/src/main/java/com/tinyengine/it/common/utils/Utils.java @@ -384,9 +384,11 @@ public static Result parseJsonFileStream(MultipartFile file) { // 使用 try-with-resources 自动管理输入流 byte[] fileBytes = Utils.readAllBytes(file.getInputStream()); String jsonContent = new String(fileBytes, StandardCharsets.UTF_8); + + String jsonString = removeBOM(jsonContent); ObjectMapper objectMapper = new ObjectMapper(); Map jsonData = - objectMapper.readValue(jsonContent, new TypeReference>() { + objectMapper.readValue(jsonString, new TypeReference>() { }); jsonFile.setFileName(fileName); @@ -398,7 +400,18 @@ public static Result parseJsonFileStream(MultipartFile file) { log.info("Successfully parsed JSON file: {}", fileName); return Result.success(jsonFile); } - + /** + * 去除文件BOM字符 + * + * @param input the inpu + * @return input the input + */ + public static String removeBOM(String input) { + if (input != null && input.startsWith("\uFEFF")) { + return input.substring(1); + } + return input; + } /** * 校验文件流合法性 * diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java index 631eaf5a..44172583 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java @@ -15,7 +15,9 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.common.log.SystemControllerLog; +import com.tinyengine.it.model.dto.CustComponentDto; import com.tinyengine.it.model.dto.FileResult; +import com.tinyengine.it.model.entity.Component; import com.tinyengine.it.service.material.ComponentService; import io.swagger.v3.oas.annotations.Operation; @@ -33,6 +35,8 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import java.util.List; + /** * 组件api * @@ -43,6 +47,9 @@ @RequestMapping("/material-center/api") @Tag(name = "组件") public class ComponentController { + /** + * The component service. + */ @Autowired private ComponentService componentService; @@ -58,12 +65,30 @@ public class ComponentController { content = @Content(mediaType = "application/json", schema = @Schema())), @ApiResponse(responseCode = "400", description = "请求失败")}) @SystemControllerLog(description = "上传bunled.json文件处理自定义组件") - @PostMapping("/component/custom/create") - public Result createCustComponent(@RequestParam MultipartFile file) { + @PostMapping("/component/bundle/split") + public Result bundleSplit(@RequestParam MultipartFile file) { if (file.isEmpty()) { return Result.failed(ExceptionEnum.CM307); } // 返回插入和更新的条数 return componentService.readFileAndBulkCreate(file); } + + /** + * 批量创建自定义组件 + * + * @param custComponentDto the custComponentDto + * @return result + */ + @Operation(summary = "批量创建自定义组件", description = "批量创建自定义组件", parameters = { + @Parameter(name = "file", description = "文件参数对象")}, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "批量创建自定义组件") + @PostMapping("/component/batch/create") + public Result createCustComponent(@RequestParam CustComponentDto custComponentDto) { + // 返回插入和更新的条数 + return componentService.custComponentBatchCreate(custComponentDto); + } } diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java index d6282a67..64adb5c3 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java @@ -41,7 +41,7 @@ */ @Validated @RestController -@RequestMapping("/componentLibrary-center/api") +@RequestMapping("/material-center/api") @Tag(name = "组件库") public class ComponentLibraryController { /** @@ -51,19 +51,19 @@ public class ComponentLibraryController { private ComponentLibraryService componentLibraryService; /** - * 查询表ComponentLibrary信息 + * 查询表ComponentLibrary信息列表 * * @return ComponentLibrary信息 all componentLibrary */ - @Operation(summary = "查询表ComponentLibrary信息", - description = "查询表ComponentLibrary信息", + @Operation(summary = "查询表ComponentLibrary信息列表", + description = "查询表ComponentLibrary信息列表", responses = { @ApiResponse(responseCode = "200", description = "返回信息", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ComponentLibrary.class))), @ApiResponse(responseCode = "400", description = "请求失败")}) - @SystemControllerLog(description = "查询表ComponentLibrary信息") - @GetMapping("/componentLibrary/list") + @SystemControllerLog(description = "查询表ComponentLibrary信息列表") + @GetMapping("/component-library/list") public Result> getAllComponentLibrary() { List componentLibraryHistoryList = componentLibraryService.queryAllComponentLibrary(); return Result.success(componentLibraryHistoryList); @@ -117,10 +117,10 @@ public Result updateComponentLibrary(@PathVariable Integer id, * 删除ComponentLibrary信息 * * @param id the id - * @return app信息 result + * @return ComponentLibrary信息 result */ - @Operation(summary = "删除app信息", - description = "删除app信息", + @Operation(summary = "删除ComponentLibrary信息", + description = "删除ComponentLibrary信息", parameters = { @Parameter(name = "id", description = "ComponentLibrary主键id") }, @@ -130,25 +130,25 @@ public Result updateComponentLibrary(@PathVariable Integer id, schema = @Schema(implementation = ComponentLibrary.class))), @ApiResponse(responseCode = "400", description = "请求失败")} ) - @SystemControllerLog(description = "删除app信息") + @SystemControllerLog(description = "删除ComponentLibrary信息") @GetMapping("/component-library/delete/{id}") public Result deleteComponentLibrary(@PathVariable Integer id) { return componentLibraryService.deleteComponentLibraryById(id); } /** - * 获取应用信息详情 + * 获取ComponentLibrary信息详情 * * @param id the id * @return the result */ - @Operation(summary = "获取应用信息详情", description = "获取应用信息详情", parameters = { + @Operation(summary = "获取ComponentLibrary信息详情", description = "获取ComponentLibrary信息详情", parameters = { @Parameter(name = "id", description = "appId")}, responses = { @ApiResponse(responseCode = "200", description = "返回信息", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ComponentLibrary.class))), @ApiResponse(responseCode = "400", description = "请求失败")}) - @SystemControllerLog(description = "获取应用信息详情") + @SystemControllerLog(description = "获取ComponentLibrary信息详情") @GetMapping("/component-library/detail/{id}") public Result detail(@PathVariable Integer id) { return componentLibraryService.queryComponentLibraryById(id); diff --git a/base/src/main/java/com/tinyengine/it/controller/MaterialController.java b/base/src/main/java/com/tinyengine/it/controller/MaterialController.java index 6fbbde69..6c4f91bf 100644 --- a/base/src/main/java/com/tinyengine/it/controller/MaterialController.java +++ b/base/src/main/java/com/tinyengine/it/controller/MaterialController.java @@ -55,14 +55,14 @@ public class MaterialController { * * @return Material信息 all material */ - @Operation(summary = "查询表Material信息", - description = "查询表Material信息", + @Operation(summary = "查询表Material信息列表", + description = "查询表Material信息列表", responses = { @ApiResponse(responseCode = "200", description = "返回信息", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Material.class))), @ApiResponse(responseCode = "400", description = "请求失败")}) - @SystemControllerLog(description = "查询表Material信息") + @SystemControllerLog(description = "查询表Material信息列表") @GetMapping("/material/list") public Result> getAllMaterial() { List materialHistoryList = materialService.queryAllMaterial(); @@ -119,8 +119,8 @@ public Result updateMaterial(@PathVariable Integer id, @RequestBody Ma * @param id the id * @return app信息 result */ - @Operation(summary = "删除app信息", - description = "删除app信息", + @Operation(summary = "删除Material信息", + description = "删除Material信息", parameters = { @Parameter(name = "id", description = "Material主键id") }, @@ -130,25 +130,25 @@ public Result updateMaterial(@PathVariable Integer id, @RequestBody Ma schema = @Schema(implementation = Material.class))), @ApiResponse(responseCode = "400", description = "请求失败")} ) - @SystemControllerLog(description = "删除app信息") + @SystemControllerLog(description = "删除Material信息") @GetMapping("/material/delete/{id}") public Result deleteMaterial(@PathVariable Integer id) { return materialService.deleteMaterialById(id); } /** - * 获取应用信息详情 + * 获取Material信息详情 * * @param id the id * @return the result */ - @Operation(summary = "获取应用信息详情", description = "获取应用信息详情", parameters = { + @Operation(summary = "获取Material信息详情", description = "获取Material信息详情", parameters = { @Parameter(name = "id", description = "appId")}, responses = { @ApiResponse(responseCode = "200", description = "返回信息", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Material.class))), @ApiResponse(responseCode = "400", description = "请求失败")}) - @SystemControllerLog(description = "获取应用信息详情") + @SystemControllerLog(description = "获取Material信息详情") @GetMapping("/material/detail/{id}") public Result detail(@PathVariable Integer id) { return materialService.queryMaterialById(id); diff --git a/base/src/main/java/com/tinyengine/it/mapper/ComponentLibraryMapper.java b/base/src/main/java/com/tinyengine/it/mapper/ComponentLibraryMapper.java index 8c1888d5..1de56202 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/ComponentLibraryMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/ComponentLibraryMapper.java @@ -15,7 +15,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.tinyengine.it.model.entity.ComponentLibrary; -import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -44,10 +43,10 @@ public interface ComponentLibraryMapper extends BaseMapper { /** * 根据条件查询表t_component_library数据 * - * @param component the component + * @param componentLibrary the componentLibrary * @return the list */ - List queryComponentLibraryByCondition(ComponentLibrary component); + List queryComponentLibraryByCondition(ComponentLibrary componentLibrary); /** * 根据主键id删除表t_component_library数据 @@ -60,45 +59,16 @@ public interface ComponentLibraryMapper extends BaseMapper { /** * 根据主键id更新表t_component_library数据 * - * @param component the component + * @param componentLibrary the componentLibrary * @return the integer */ - Integer updateComponentLibraryById(ComponentLibrary component); + Integer updateComponentLibraryById(ComponentLibrary componentLibrary); /** * 新增表t_component_library数据 * - * @param component the component + * @param componentLibrary the componentLibrary * @return the integer */ - Integer createComponentLibrary(ComponentLibrary component); - - /** - * Find user components by material history id list. - * - * @param id the id - * @return the list - */ - List findUserComponentLibrarysByMaterialHistoryId(@Param("id") Integer id); - - /** - * 新增表r_material_component数据 - * - * @param materialComponentLibrary the materialComponentLibrary - * @return the integer - */ - @Insert("INSERT INTO r_material_component (id,material_id,component_id )" - + "values (#{id},#{materialId},#{componentId})") - Integer createMaterialComponentLibrary(MaterialComponentLibrary materialComponentLibrary); - - - /** - * 新增表r_material_component数据 - * - * @param materialHistoryComponentLibrary the materialHistoryComponentLibrary - * @return the integer - */ - @Insert("INSERT INTO r_material_history_component (id,material_history_id,component_id )" - + "values (#{id},#{materialHistoryId},#{componentId})") - Integer createMaterialHistoryComponentLibrary(MaterialHistoryComponentLibrary materialHistoryComponentLibrary); + Integer createComponentLibrary(ComponentLibrary componentLibrary); } \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/model/dto/BundleMaterial.java b/base/src/main/java/com/tinyengine/it/model/dto/BundleMaterial.java index d2d3080d..f894b304 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/BundleMaterial.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/BundleMaterial.java @@ -20,11 +20,12 @@ /** * BundleMaterial * - * @since 2024-11-13 + * @since 2025-04-02 */ @Data public class BundleMaterial { private List> components; private List snippets; private List> blocks; + private List> packages; } diff --git a/base/src/main/java/com/tinyengine/it/model/dto/BundleResultDto.java b/base/src/main/java/com/tinyengine/it/model/dto/BundleResultDto.java new file mode 100644 index 00000000..d5237fad --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/model/dto/BundleResultDto.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.model.dto; + +import com.tinyengine.it.model.entity.Component; +import com.tinyengine.it.model.entity.ComponentLibrary; +import lombok.Data; + +import java.util.List; + +/** + * BundleResultDto + * + * @since 2025-04-02 + */ +@Data +public class BundleResultDto { + private List packageList; + private List componentList; +} diff --git a/base/src/main/java/com/tinyengine/it/model/dto/CustComponentDto.java b/base/src/main/java/com/tinyengine/it/model/dto/CustComponentDto.java new file mode 100644 index 00000000..dccc870e --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/model/dto/CustComponentDto.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.model.dto; + +import com.tinyengine.it.model.entity.Component; +import lombok.Data; + +import java.util.List; + +/** + * CustComponentDto + * + * @since 2025-04-03 + */ +@Data +public class CustComponentDto { + private List components; + private Integer componentLibraryId; +} diff --git a/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java b/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java new file mode 100644 index 00000000..d511636f --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.model.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +import java.util.Map; + +/** + * PackagesDto + * + * @since 2025-04-03 + */ +@Setter +@Getter +public class PackagesDto { + private String name; + @JsonProperty("package") + private String packageName; + private String version; + private String script; + private String css; + private Map others; +} diff --git a/base/src/main/java/com/tinyengine/it/model/dto/SchemaDto.java b/base/src/main/java/com/tinyengine/it/model/dto/SchemaDto.java index 4b2eb6a7..76b20047 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/SchemaDto.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/SchemaDto.java @@ -37,4 +37,5 @@ public class SchemaDto { private SchemaMeta meta; private List utils; private String version; + private List packages; } diff --git a/base/src/main/java/com/tinyengine/it/model/entity/Component.java b/base/src/main/java/com/tinyengine/it/model/entity/Component.java index 9b46d989..01653160 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/Component.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/Component.java @@ -87,9 +87,9 @@ public class Component extends BaseEntity { @Schema(name = "snippets", description = "schema片段") private List> snippets; - @JsonProperty("schema") + @TableField(typeHandler = MapTypeHandler.class) @Schema(name = "schemaFragment", description = "schema片段") - private String schemaFragment; + private Map schemaFragment; @Schema(name = "configure", description = "配置信息") @JsonProperty("configure") diff --git a/base/src/main/java/com/tinyengine/it/model/entity/ComponentLibrary.java b/base/src/main/java/com/tinyengine/it/model/entity/ComponentLibrary.java index 79f04d88..86d16712 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/ComponentLibrary.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/ComponentLibrary.java @@ -16,7 +16,6 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; import com.tinyengine.it.common.base.BaseEntity; -import com.tinyengine.it.common.handler.ListTypeHandler; import com.tinyengine.it.common.handler.MapTypeHandler; import io.swagger.v3.oas.annotations.media.Schema; @@ -42,9 +41,8 @@ public class ComponentLibrary extends BaseEntity { @Schema(name = "version", description = "版本") private String version; - @TableField(typeHandler = MapTypeHandler.class) @Schema(name = "name", description = "名称") - private Map name; + private String name; @JsonProperty("package") @Schema(name = "package", description = "包名") @@ -84,11 +82,14 @@ public class ComponentLibrary extends BaseEntity { private Integer publicStatus; @Schema(name = "isStarted", description = "标识启用") - private Integer isStarted; + private Boolean isStarted; @Schema(name = "isOfficial", description = "标识官方组件") private Boolean isOfficial; @Schema(name = "isDefault", description = "标识默认组件") private Boolean isDefault; + + @Schema(name = "components", description = "组件库组件") + private List components; } diff --git a/base/src/main/java/com/tinyengine/it/model/entity/MaterialHistory.java b/base/src/main/java/com/tinyengine/it/model/entity/MaterialHistory.java index 205771db..6403debf 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/MaterialHistory.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/MaterialHistory.java @@ -79,9 +79,6 @@ public class MaterialHistory extends HistoryEntity { @Schema(name = "unzipTgzFiles", description = "物料压缩包解压后文件地址") private String unzipTgzFiles; - @Schema(name = "isStarted", description = "是否启动") - private String isStarted; - @Schema(name = "components", description = "组件") private List components; } diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java index 71545703..cf55c7c4 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java @@ -22,6 +22,7 @@ import com.tinyengine.it.mapper.AppMapper; import com.tinyengine.it.mapper.BlockGroupMapper; import com.tinyengine.it.mapper.BlockHistoryMapper; +import com.tinyengine.it.mapper.ComponentLibraryMapper; import com.tinyengine.it.mapper.DatasourceMapper; import com.tinyengine.it.mapper.I18nEntryMapper; import com.tinyengine.it.mapper.MaterialHistoryMapper; @@ -32,6 +33,7 @@ import com.tinyengine.it.model.dto.I18nEntryDto; import com.tinyengine.it.model.dto.MaterialHistoryMsg; import com.tinyengine.it.model.dto.MetaDto; +import com.tinyengine.it.model.dto.PackagesDto; import com.tinyengine.it.model.dto.SchemaDto; import com.tinyengine.it.model.dto.SchemaI18n; import com.tinyengine.it.model.dto.SchemaMeta; @@ -41,6 +43,7 @@ import com.tinyengine.it.model.entity.BlockGroup; import com.tinyengine.it.model.entity.BlockHistory; import com.tinyengine.it.model.entity.Component; +import com.tinyengine.it.model.entity.ComponentLibrary; import com.tinyengine.it.model.entity.Datasource; import com.tinyengine.it.model.entity.MaterialHistory; import com.tinyengine.it.model.entity.Page; @@ -52,6 +55,7 @@ import cn.hutool.core.bean.BeanUtil; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -133,6 +137,9 @@ public class AppV1ServiceImpl implements AppV1Service { @Autowired private PlatformService platformService; + @Autowired + private ComponentLibraryMapper componentLibraryMapper; + /** * 获取应用schema * @@ -163,6 +170,9 @@ public SchemaDto appSchema(Integer id) { List> componentsMap = getSchemaComponentsMap(metaDto); schema.setComponentsMap(componentsMap); + List packages = getPackages(); + schema.setPackages(packages); + // 单独处理混合了bridge和utils的extensions Map> extensions = getSchemaExtensions(metaDto.getExtension()); schema.setUtils(extensions.get("utils")); @@ -237,6 +247,24 @@ private SchemaMeta getSchemaMeta(MetaDto metaDto) { return BeanUtil.mapToBean(meta, SchemaMeta.class, true); } + /** + * 获取组件库信息 + * + * @return List the List + */ + private List getPackages(){ + List componentLibraryList = componentLibraryMapper.queryAllComponentLibrary(); + List packagesDtoList = new ArrayList<>(); + if(componentLibraryList.isEmpty()){ + return packagesDtoList; + } + for (ComponentLibrary componentLibrary: componentLibraryList){ + PackagesDto pakagesDto = new PackagesDto(); + BeanUtils.copyProperties(componentLibrary, pakagesDto); + packagesDtoList.add(pakagesDto); + } + return packagesDtoList; + } /** * 获取应用信息 * @@ -468,6 +496,13 @@ public List> getSchemaComponentsMap(MetaDto metaDto) { List> blocksSchema = getBlockSchema(blockHistories); // 转换组件数据为schema List components = materialHistory.getComponents(); + List componentLibraryList = componentLibraryMapper.queryAllComponentLibrary(); + if(!componentLibraryList.isEmpty()){ + List componentList = componentLibraryList.stream() + .flatMap(componentLibrary -> componentLibrary.getComponents().stream()) // 扁平化每个 List + .collect(Collectors.toList()); // 收集到一个新的 List + components.addAll(componentList); + } List> componentsSchema = getComponentSchema(components); // 合并两个 List List> componentsMap = new ArrayList<>(componentsSchema); diff --git a/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java b/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java index e7f4b330..4033bb1c 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java +++ b/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java @@ -13,6 +13,8 @@ package com.tinyengine.it.service.material; import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.model.dto.BundleResultDto; +import com.tinyengine.it.model.dto.CustComponentDto; import com.tinyengine.it.model.dto.FileResult; import com.tinyengine.it.model.entity.Component; @@ -88,16 +90,15 @@ public interface ComponentService { * @param file the file * @return result the result */ - Result> bundleSplit(MultipartFile file); + Result bundleSplit(MultipartFile file); /** * 批量创建component * - * @param componentList the componentList - * @param materialId the materialId + * @param custComponentDto the custComponentDto * @return result the result */ - Result custComponentBulkCreate(List componentList, Integer materialId); + Result custComponentBatchCreate(CustComponentDto custComponentDto); } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java index 88d583ec..295fa127 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java @@ -1,31 +1,33 @@ /** * Copyright (c) 2023 - present TinyEngine Authors. * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. - *

+ * * Use of this source code is governed by an MIT-style license. - *

+ * * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * */ package com.tinyengine.it.service.material.impl; import com.tinyengine.it.common.base.Result; import com.tinyengine.it.common.exception.ExceptionEnum; +import com.tinyengine.it.common.log.SystemServiceLog; import com.tinyengine.it.common.utils.Utils; +import com.tinyengine.it.mapper.ComponentLibraryMapper; import com.tinyengine.it.mapper.ComponentMapper; -import com.tinyengine.it.mapper.MaterialHistoryMapper; -import com.tinyengine.it.mapper.MaterialMapper; import com.tinyengine.it.model.dto.BundleDto; +import com.tinyengine.it.model.dto.BundleResultDto; import com.tinyengine.it.model.dto.Child; +import com.tinyengine.it.model.dto.CustComponentDto; import com.tinyengine.it.model.dto.FileResult; import com.tinyengine.it.model.dto.JsonFile; import com.tinyengine.it.model.dto.Snippet; import com.tinyengine.it.model.entity.Component; -import com.tinyengine.it.model.entity.Material; +import com.tinyengine.it.model.entity.ComponentLibrary; import com.tinyengine.it.model.entity.MaterialComponent; -import com.tinyengine.it.model.entity.MaterialHistory; import com.tinyengine.it.model.entity.MaterialHistoryComponent; import com.tinyengine.it.service.material.ComponentService; @@ -33,7 +35,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.annotations.Param; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -52,10 +53,18 @@ @Service @Slf4j public class ComponentServiceImpl implements ComponentService { + /** + * The component mapper. + */ @Autowired private ComponentMapper componentMapper; - private MaterialMapper materialMapper; - private MaterialHistoryMapper materialHistoryMapper; + + /** + * The component library mapper. + */ + @Autowired + private ComponentLibraryMapper componentLibraryMapper; + /** * 查询表t_component所有数据 @@ -128,9 +137,33 @@ public Integer createComponent(Component component) { * @param file the file * @return result the result */ + @SystemServiceLog(description = "readFileAndBulkCreate 创建组件库及组件实现方法") @Override public Result readFileAndBulkCreate(MultipartFile file) { - List componentList = this.bundleSplit(file).getData(); + List componentList = this.bundleSplit(file).getData().getComponentList(); + List packageList = this.bundleSplit(file).getData().getPackageList(); + for (ComponentLibrary componentLibrary : packageList) { + componentLibrary.setIsDefault(true); + componentLibrary.setIsStarted(true); + ComponentLibrary library = new ComponentLibrary(); + library.setName(componentLibrary.getName()); + library.setVersion(componentLibrary.getVersion()); + // 查询是否存在组件库 + List componentLibraryList = componentLibraryMapper.queryComponentLibraryByCondition(library); + int result = 0; + if (!componentLibraryList.isEmpty()) { + componentLibrary.setId(componentLibraryList.get(0).getId()); + result = componentLibraryMapper.updateComponentLibraryById(componentLibrary); + if (result != 1) { + return Result.failed(ExceptionEnum.CM008); + } + continue; + } + result = componentLibraryMapper.createComponentLibrary(componentLibrary); + if (result != 1) { + return Result.failed(ExceptionEnum.CM008); + } + } return bulkCreate(componentList); } @@ -141,7 +174,8 @@ public Result readFileAndBulkCreate(MultipartFile file) { * @return result the result */ @Override - public Result> bundleSplit(MultipartFile file) { + @SystemServiceLog(description = "bundleSplit 拆分bundle.json实现方法") + public Result bundleSplit(MultipartFile file) { // 获取bundle.json数据 Result result = Utils.parseJsonFileStream(file); if (!result.isSuccess()) { @@ -174,6 +208,10 @@ public Result> bundleSplit(MultipartFile file) { component.setFramework(bundleDto.getFramework()); component.setPublicStatus(1); component.setIsTinyReserved(false); + Object schemaObject = comp.get("schema"); + if (schemaObject instanceof Map) { + component.setSchemaFragment((Map) schemaObject); + } if (snippets == null || snippets.isEmpty()) { componentList.add(component); continue; @@ -194,36 +232,43 @@ public Result> bundleSplit(MultipartFile file) { } componentList.add(component); } - - return Result.success(componentList); + List> packages = bundleDto.getMaterials().getPackages(); + List packageList = new ArrayList<>(); + for (Map library : packages) { + ComponentLibrary componentLibrary = BeanUtil.mapToBean(library, ComponentLibrary.class, true); + componentLibrary.setPackageName(String.valueOf(library.get("package"))); + componentLibrary.setFramework("Vue"); + packageList.add(componentLibrary); + } + BundleResultDto bundleList = new BundleResultDto(); + bundleList.setComponentList(componentList); + bundleList.setPackageList(packageList); + return Result.success(bundleList); } /** * 批量创建component * - * @param componentList the componentList - * @param materialHistoryId the materialHistoryId + * @param custComponentDto the custComponentDto * @return result the result */ @Override - public Result custComponentBulkCreate(List componentList, Integer materialId) { + @SystemServiceLog(description = "custComponentBatchCreate 批量新增自定义组件实现方法") + public Result custComponentBatchCreate(CustComponentDto custComponentDto) { int addNum = 0; int updateNum = 0; + List componentList = custComponentDto.getComponents(); + if (componentList.isEmpty()) { + return Result.failed(ExceptionEnum.CM002); + } + Integer id = custComponentDto.getComponentLibraryId(); + if (null == id) { + return Result.failed(ExceptionEnum.CM002); + } for (Component component : componentList) { - + component.setLibraryId(id); // 插入新记录 - Integer result = createComponent(component); - if (result != 1) { - continue; - } - int materialHistoryId = this.createMaterialHistory(materialId); - if (materialHistoryId == 0) { - continue; - } - MaterialHistoryComponent materialHistoryComponent = new MaterialHistoryComponent(); - materialHistoryComponent.setComponentId(component.getId()); - materialHistoryComponent.setMaterialHistoryId(materialHistoryId); - componentMapper.createMaterialHistoryComponent(materialHistoryComponent); + createComponent(component); } addNum = addNum + 1; @@ -234,30 +279,13 @@ public Result custComponentBulkCreate(List componentList, return Result.success(fileResult); } - public int createMaterialHistory(Integer materialId) { - int materialHistoryId = 0; - Material material = materialMapper.queryMaterialById(materialId); - MaterialHistory materialHistory = new MaterialHistory(); - // 把material中的属性值赋值到materialHistories中 - BeanUtils.copyProperties(material, materialHistory); - materialHistory.setId(null); - materialHistory.setRefId(materialId); - materialHistory.setVersion(material.getLatestVersion()); - materialHistory.setContent(new HashMap<>()); - int result = materialHistoryMapper.createMaterialHistory(materialHistory); - if (result != 1) { - return materialHistoryId; - } - materialHistoryId = materialHistory.getId(); - return materialHistoryId; - } - /** * 批量创建组件 * * @param componentList the componentList * @return result the result */ + @SystemServiceLog(description = "bulkCreate 批量创建组件实现方法") public Result bulkCreate(List componentList) { int addNum = 0; int updateNum = 0; @@ -267,9 +295,20 @@ public Result bulkCreate(List componentList) { Component componentParam = new Component(); componentParam.setComponent(component.getComponent()); componentParam.setName(component.getName()); + componentParam.setVersion(component.getVersion()); List queryComponent = findComponentByCondition(componentParam); - + // 查询组件库id + ComponentLibrary componentLibrary = new ComponentLibrary(); + componentLibrary.setPackageName(String.valueOf(component.getNpm().get("package"))); + componentLibrary.setVersion(component.getVersion()); + List componentLibraryList = componentLibraryMapper.queryComponentLibraryByCondition(componentLibrary); + Integer componentLibraryId = null; + if (!componentLibraryList.isEmpty()) { + componentLibraryId = componentLibraryList.get(0).getId(); + } + component.setLibraryId(componentLibraryId); if (queryComponent.isEmpty()) { + // 插入新记录 Integer result = createComponent(component); if (result == 1) { diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java index e28885f5..41e281d2 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java @@ -35,6 +35,9 @@ @Service @Slf4j public class MaterialHistoryServiceImpl implements MaterialHistoryService { + /** + * The material history mapper. + */ @Autowired private MaterialHistoryMapper materialHistoryMapper; @@ -57,7 +60,7 @@ public List findAllMaterialHistory() { @Override public Result findMaterialHistoryById(@Param("id") Integer id) { MaterialHistory materialHistory = materialHistoryMapper.queryMaterialHistoryById(id); - if(null == materialHistory.getId()){ + if (null == materialHistory.getId()) { return Result.failed(ExceptionEnum.CM009); } return Result.success(materialHistory); @@ -86,7 +89,7 @@ public List findMaterialHistoryByCondition(MaterialHistory mate public Result deleteMaterialHistoryById(@Param("id") Integer id) { Result result = this.findMaterialHistoryById(id); int deleteResult = materialHistoryMapper.deleteMaterialHistoryById(id); - if(deleteResult != 1){ + if (deleteResult != 1) { return Result.failed(ExceptionEnum.CM008); } return result; @@ -101,7 +104,7 @@ public Result deleteMaterialHistoryById(@Param("id") Integer id @Override public Result updateMaterialHistoryById(MaterialHistory materialHistory) { int updateResult = materialHistoryMapper.updateMaterialHistoryById(materialHistory); - if(updateResult != 1){ + if (updateResult != 1) { return Result.failed(ExceptionEnum.CM008); } Result result = this.findMaterialHistoryById(materialHistory.getId()); @@ -117,7 +120,7 @@ public Result updateMaterialHistoryById(MaterialHistory materia @Override public Result createMaterialHistory(MaterialHistory materialHistory) { int createResult = materialHistoryMapper.createMaterialHistory(materialHistory); - if(createResult != 1){ + if (createResult != 1) { return Result.failed(ExceptionEnum.CM008); } Result result = this.findMaterialHistoryById(materialHistory.getId()); diff --git a/base/src/main/resources/mappers/ComponentLibraryMapper.xml b/base/src/main/resources/mappers/ComponentLibraryMapper.xml index 6b65e50a..7b565887 100644 --- a/base/src/main/resources/mappers/ComponentLibraryMapper.xml +++ b/base/src/main/resources/mappers/ComponentLibraryMapper.xml @@ -7,7 +7,7 @@ id - , version, `name`, package, registry, framework, description, script, css, bundle, dependencies, `others`, thumbnail, `public`, is_started, is_official ,is_default, created_by, last_updated_by, created_time, last_updated_time, + , version, `name`, package, registry, framework, description, script, css, bundle, dependencies, `others`, thumbnail, `public`, is_started, is_official, is_default, created_by, last_updated_by, created_time, last_updated_time, tenant_id, renter_id, site_id @@ -17,7 +17,7 @@ AND version = #{version} - AND name = #{name} + AND `name` = #{name} AND package = #{packageName} @@ -84,74 +84,73 @@ - version = #{version} + version = #{version}, - name = #{name} + `name` = #{name}, - package = #{packageName} + `package` = #{packageName}, - registry = #{registry} + registry = #{registry}, - description = #{description} + description = #{description}, - framework = #{framework} + framework = #{framework}, - script = #{script} + script = #{script}, - css = #{css} + css = #{css}, - bundle = #{bundle} + bundle = #{bundle}, - `others` = #{others} + `others` = #{others}, - thumbnail = #{thumbnail} + thumbnail = #{thumbnail}, - `public` = #{publicStatus} + `public` = #{publicStatus}, - is_started = #{publicStatus} + is_started = #{isStarted}, - is_official = #{isOfficial} + is_official = #{isOfficial}, - is_default = #{isDefault} + is_default = #{isDefault}, - created_by = #{createdBy} + created_by = #{createdBy}, - last_updated_by = #{lastUpdatedBy} + last_updated_by = #{lastUpdatedBy}, - created_time = #{createdTime} + created_time = #{createdTime}, - last_updated_time = #{lastUpdatedTime} + last_updated_time = #{lastUpdatedTime}, - tenant_id = #{tenantId} + tenant_id = #{tenantId}, - renter_id = #{renterId} + renter_id = #{renterId}, - site_id = #{siteId} + site_id = #{siteId}, - @@ -177,23 +176,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -220,8 +365,7 @@ - WHERE - id=#{id} + WHERE id=#{id} diff --git a/base/src/main/resources/mappers/MaterialHistoryMapper.xml b/base/src/main/resources/mappers/MaterialHistoryMapper.xml index f91843aa..94720a4b 100644 --- a/base/src/main/resources/mappers/MaterialHistoryMapper.xml +++ b/base/src/main/resources/mappers/MaterialHistoryMapper.xml @@ -8,7 +8,7 @@ id , ref_id, version, content, name, npm_name, framework, assets_url, image_url, build_info, description, - material_size, tgz_url, unzip_tgz_root_path_url, unzip_tgz_files, is_started, created_by, last_updated_by, created_time, + material_size, tgz_url, unzip_tgz_root_path_url, unzip_tgz_files, created_by, last_updated_by, created_time, last_updated_time, tenant_id, renter_id, site_id @@ -56,9 +56,6 @@ AND unzip_tgz_files = #{unzipTgzFiles} - - AND is_started = #{isStarted} - AND created_by = #{createdBy} @@ -126,9 +123,6 @@ unzip_tgz_files = #{unzipTgzFiles}, - - is_started = #{isStarted}, - created_by = #{createdBy}, @@ -170,7 +164,6 @@ - @@ -231,7 +224,6 @@ , tgz_url , unzip_tgz_root_path_url , unzip_tgz_files - , is_started , created_by , last_updated_by , created_time @@ -253,7 +245,6 @@ , #{tgzUrl} , #{unzipTgzRootPathUrl} , #{unzipTgzFiles} - , #{isStarted} , #{createdBy} , #{lastUpdatedBy} , #{createdTime} diff --git a/base/src/test/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImplTest.java index 3351f0ba..cf4e50a9 100644 --- a/base/src/test/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImplTest.java @@ -23,6 +23,7 @@ import com.tinyengine.it.mapper.AppMapper; import com.tinyengine.it.mapper.BlockGroupMapper; import com.tinyengine.it.mapper.BlockHistoryMapper; +import com.tinyengine.it.mapper.ComponentLibraryMapper; import com.tinyengine.it.mapper.DatasourceMapper; import com.tinyengine.it.mapper.I18nEntryMapper; import com.tinyengine.it.mapper.MaterialHistoryMapper; @@ -39,6 +40,7 @@ import com.tinyengine.it.model.entity.AppExtension; import com.tinyengine.it.model.entity.BlockGroup; import com.tinyengine.it.model.entity.BlockHistory; +import com.tinyengine.it.model.entity.ComponentLibrary; import com.tinyengine.it.model.entity.Datasource; import com.tinyengine.it.model.entity.MaterialHistory; import com.tinyengine.it.model.entity.Page; @@ -53,6 +55,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.awt.*; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -94,7 +97,8 @@ class AppV1ServiceImplTest { @Mock private PlatformService platformService; - + @Mock + private ComponentLibraryMapper componentLibraryMapper; @InjectMocks private AppV1ServiceImpl appV1ServiceImpl; @@ -136,7 +140,8 @@ void testAppSchema() throws JsonProcessingException { platform.setMaterialHistoryId(3); when(platformService.queryPlatformById(any())).thenReturn(platform); - + List componentLibraryList = new ArrayList<>(); + when(componentLibraryMapper.queryAllComponentLibrary()).thenReturn(componentLibraryList); SchemaDto result = appV1ServiceImpl.appSchema(appId); Assertions.assertEquals("2", result.getMeta().getAppId()); } @@ -200,6 +205,8 @@ void testGetSchemaComponentsMap() { MaterialHistory materialHistory = new MaterialHistory(); materialHistory.setComponents(new ArrayList<>()); metaDto.setMaterialHistory(materialHistory); + List componentLibraryList = new ArrayList<>(); + when(componentLibraryMapper.queryAllComponentLibrary()).thenReturn(componentLibraryList); List> result = appV1ServiceImpl.getSchemaComponentsMap(metaDto); Assertions.assertEquals("v1", result.get(0).get("version")); } From 6a5269dcfe1636446c9d15366683d076dc1aedf6 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 6 Apr 2025 23:06:15 -0700 Subject: [PATCH 37/72] feat: component library api --- .../it/controller/ComponentController.java | 27 +++++++++++++-- .../service/app/impl/CanvasServiceImpl.java | 5 ++- .../material/ComponentLibraryService.java | 12 +++---- .../impl/ComponentLibraryServiceImpl.java | 22 ++++++------ .../material/impl/ComponentServiceImpl.java | 34 +++++++++++++------ .../handler/MyMetaObjectHandlerTest.java | 2 +- .../app/impl/CanvasServiceImplTest.java | 6 +++- .../impl/BlockGroupServiceImplTest.java | 6 ++++ .../impl/ComponentServiceImplTest.java | 11 +++++- .../impl/MaterialHistoryServiceImplTest.java | 4 +++ .../impl/MaterialServiceImplTest.java | 6 +++- 11 files changed, 100 insertions(+), 35 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java index 44172583..06f29307 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java @@ -15,6 +15,7 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.common.log.SystemControllerLog; +import com.tinyengine.it.model.dto.BundleResultDto; import com.tinyengine.it.model.dto.CustComponentDto; import com.tinyengine.it.model.dto.FileResult; import com.tinyengine.it.model.entity.Component; @@ -53,6 +54,27 @@ public class ComponentController { @Autowired private ComponentService componentService; + /** + * 上传bunled.json文件处理自定义组件 + * + * @param file the file + * @return result + */ + @Operation(summary = "上传bunled.json文件创建组件", description = "上传bunled.json文件创建组件", parameters = { + @Parameter(name = "file", description = "文件参数对象")}, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "上传bunled.json文件创建组件") + @PostMapping("/component/bundle/createComponent") + public Result bundleCreateComponent(@RequestParam MultipartFile file) { + if (file.isEmpty()) { + return Result.failed(ExceptionEnum.CM307); + } + // 返回插入和更新的条数 + return componentService.readFileAndBulkCreate(file); + } + /** * 上传bunled.json文件处理自定义组件 * @@ -66,12 +88,11 @@ public class ComponentController { @ApiResponse(responseCode = "400", description = "请求失败")}) @SystemControllerLog(description = "上传bunled.json文件处理自定义组件") @PostMapping("/component/bundle/split") - public Result bundleSplit(@RequestParam MultipartFile file) { + public Result bundleSplit(@RequestParam MultipartFile file) { if (file.isEmpty()) { return Result.failed(ExceptionEnum.CM307); } - // 返回插入和更新的条数 - return componentService.readFileAndBulkCreate(file); + return componentService.bundleSplit(file); } /** diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java index 206a16d4..344891db 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java @@ -13,6 +13,7 @@ package com.tinyengine.it.service.app.impl; import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.context.LoginUserContext; import com.tinyengine.it.mapper.BlockMapper; import com.tinyengine.it.mapper.PageMapper; import com.tinyengine.it.mapper.UserMapper; @@ -38,12 +39,14 @@ public class CanvasServiceImpl implements CanvasService { private BlockMapper blockMapper; @Autowired private UserMapper userMapper; + @Autowired + private LoginUserContext loginUserContext; @Override public Result lockCanvas(Integer id, String state, String type) { int occupier; // needTODO 先试用mock数据,后续添加登录及权限后从session获取, - User user = userMapper.queryUserById(1); + User user = userMapper.queryUserById(Integer.parseInt(loginUserContext.getLoginUserId())); CanvasDto canvasDto = new CanvasDto(); if ("page".equals(type)) { Page page = pageMapper.queryPageById(id); diff --git a/base/src/main/java/com/tinyengine/it/service/material/ComponentLibraryService.java b/base/src/main/java/com/tinyengine/it/service/material/ComponentLibraryService.java index e09d273c..71f44294 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/ComponentLibraryService.java +++ b/base/src/main/java/com/tinyengine/it/service/material/ComponentLibraryService.java @@ -43,10 +43,10 @@ public interface ComponentLibraryService { /** * 根据条件查询表t_component_library信息 * - * @param material the material + * @param componentLibrary the componentLibrary * @return the list */ - List queryComponentLibraryByCondition(ComponentLibrary material); + List queryComponentLibraryByCondition(ComponentLibrary componentLibrary); /** * 根据主键id删除t_component_library数据 @@ -59,16 +59,16 @@ public interface ComponentLibraryService { /** * 根据主键id更新表t_component_library信息 * - * @param material the material + * @param componentLibrary the componentLibrary * @return the integer */ - Result updateComponentLibraryById(ComponentLibrary material); + Result updateComponentLibraryById(ComponentLibrary componentLibrary); /** * 新增表t_component_library数据 * - * @param material the material + * @param componentLibrary the componentLibrary * @return the integer */ - Result createComponentLibrary(ComponentLibrary material); + Result createComponentLibrary(ComponentLibrary componentLibrary); } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java index c0e12fb8..62902029 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java @@ -65,12 +65,12 @@ public Result queryComponentLibraryById(@Param("id") Integer i /** * 根据条件查询表t_component_library数据 * - * @param material material + * @param componentLibrary componentLibrary * @return query result */ @Override - public List queryComponentLibraryByCondition(ComponentLibrary material) { - return componentLibraryMapper.queryComponentLibraryByCondition(material); + public List queryComponentLibraryByCondition(ComponentLibrary componentLibrary) { + return componentLibraryMapper.queryComponentLibraryByCondition(componentLibrary); } /** @@ -93,32 +93,32 @@ public Result deleteComponentLibraryById(@Param("id") Integer /** * 根据主键id更新表t_component_library数据 * - * @param material material + * @param componentLibrary componentLibrary * @return execute success data number */ @Override - public Result updateComponentLibraryById(ComponentLibrary material) { - int updateResult = componentLibraryMapper.updateComponentLibraryById(material); + public Result updateComponentLibraryById(ComponentLibrary componentLibrary) { + int updateResult = componentLibraryMapper.updateComponentLibraryById(componentLibrary); if(updateResult != 1){ return Result.failed(ExceptionEnum.CM008); } - Result result = this.queryComponentLibraryById(material.getId()); + Result result = this.queryComponentLibraryById(componentLibrary.getId()); return result; } /** * 新增表t_component_library数据 * - * @param material material + * @param componentLibrary componentLibrary * @return execute success data number */ @Override - public Result createComponentLibrary(ComponentLibrary material) { - int createResult = componentLibraryMapper.createComponentLibrary(material); + public Result createComponentLibrary(ComponentLibrary componentLibrary) { + int createResult = componentLibraryMapper.createComponentLibrary(componentLibrary); if(createResult != 1){ return Result.failed(ExceptionEnum.CM008); } - Result result = this.queryComponentLibraryById(material.getId()); + Result result = this.queryComponentLibraryById(componentLibrary.getId()); return result; } } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java index 295fa127..bf2d3602 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java @@ -142,6 +142,9 @@ public Integer createComponent(Component component) { public Result readFileAndBulkCreate(MultipartFile file) { List componentList = this.bundleSplit(file).getData().getComponentList(); List packageList = this.bundleSplit(file).getData().getPackageList(); + if (null == packageList || packageList.isEmpty()) { + return bulkCreate(componentList); + } for (ComponentLibrary componentLibrary : packageList) { componentLibrary.setIsDefault(true); componentLibrary.setIsStarted(true); @@ -233,6 +236,12 @@ public Result bundleSplit(MultipartFile file) { componentList.add(component); } List> packages = bundleDto.getMaterials().getPackages(); + + BundleResultDto bundleList = new BundleResultDto(); + bundleList.setComponentList(componentList); + if (null == packages || packages.isEmpty()) { + return Result.success(bundleList); + } List packageList = new ArrayList<>(); for (Map library : packages) { ComponentLibrary componentLibrary = BeanUtil.mapToBean(library, ComponentLibrary.class, true); @@ -240,8 +249,6 @@ public Result bundleSplit(MultipartFile file) { componentLibrary.setFramework("Vue"); packageList.add(componentLibrary); } - BundleResultDto bundleList = new BundleResultDto(); - bundleList.setComponentList(componentList); bundleList.setPackageList(packageList); return Result.success(bundleList); } @@ -298,15 +305,22 @@ public Result bulkCreate(List componentList) { componentParam.setVersion(component.getVersion()); List queryComponent = findComponentByCondition(componentParam); // 查询组件库id - ComponentLibrary componentLibrary = new ComponentLibrary(); - componentLibrary.setPackageName(String.valueOf(component.getNpm().get("package"))); - componentLibrary.setVersion(component.getVersion()); - List componentLibraryList = componentLibraryMapper.queryComponentLibraryByCondition(componentLibrary); - Integer componentLibraryId = null; - if (!componentLibraryList.isEmpty()) { - componentLibraryId = componentLibraryList.get(0).getId(); + String packageName = null; + if(null!= component.getNpm() && null != component.getNpm().get("package")){ + packageName = String.valueOf(component.getNpm().get("package")); } - component.setLibraryId(componentLibraryId); + if(null != packageName && !packageName.isEmpty()){ + ComponentLibrary componentLibrary = new ComponentLibrary(); + componentLibrary.setPackageName(String.valueOf(component.getNpm().get("package"))); + componentLibrary.setVersion(component.getVersion()); + List componentLibraryList = componentLibraryMapper.queryComponentLibraryByCondition(componentLibrary); + Integer componentLibraryId = null; + if (!componentLibraryList.isEmpty()) { + componentLibraryId = componentLibraryList.get(0).getId(); + } + component.setLibraryId(componentLibraryId); + } + if (queryComponent.isEmpty()) { // 插入新记录 diff --git a/base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java b/base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java index a713172c..d6b219e5 100644 --- a/base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java +++ b/base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java @@ -36,7 +36,7 @@ void testInsertFill() throws NoSuchFieldException, IllegalAccessException { when(param.hasSetter("tenantId")).thenReturn(true); TestUtil.setPrivateValue(myMetaObjectHandler, "loginUserContext", new MockUserContext()); myMetaObjectHandler.insertFill(param); - verify(param, times(6)).hasSetter(anyString()); + verify(param, times(8)).hasSetter(anyString()); } @Test diff --git a/base/src/test/java/com/tinyengine/it/service/app/impl/CanvasServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/app/impl/CanvasServiceImplTest.java index 59ece02d..c341592c 100644 --- a/base/src/test/java/com/tinyengine/it/service/app/impl/CanvasServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/app/impl/CanvasServiceImplTest.java @@ -19,6 +19,7 @@ import static org.mockito.Mockito.when; import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.context.LoginUserContext; import com.tinyengine.it.mapper.BlockMapper; import com.tinyengine.it.mapper.PageMapper; import com.tinyengine.it.mapper.UserMapper; @@ -46,6 +47,8 @@ class CanvasServiceImplTest { private BlockMapper blockMapper; @Mock private UserMapper userMapper; + @Mock + private LoginUserContext loginUserContext; @InjectMocks private CanvasServiceImpl canvasServiceImpl; @@ -67,7 +70,7 @@ void testLockCanvasTypePage() { User user = new User(); user.setId(userId); when(userMapper.queryUserById(1)).thenReturn(user); - + when(loginUserContext.getLoginUserId()).thenReturn("1"); Result result = canvasServiceImpl.lockCanvas(pageId, "occupy", "page"); verify(pageMapper, times(1)).updatePageById(any()); @@ -86,6 +89,7 @@ void testLockCanvasTypeIsNotPage() { User user = new User(); user.setId(userId); when(userMapper.queryUserById(1)).thenReturn(user); + when(loginUserContext.getLoginUserId()).thenReturn("1"); Result result = canvasServiceImpl.lockCanvas(pageId, "occupy", "other"); diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java index 00592696..c98cf1e8 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImplTest.java @@ -20,6 +20,7 @@ import com.tinyengine.it.mapper.BlockGroupBlockMapper; import com.tinyengine.it.mapper.BlockGroupMapper; import com.tinyengine.it.model.dto.BlockGroupDto; +import com.tinyengine.it.model.entity.Block; import com.tinyengine.it.model.entity.BlockGroup; import org.junit.jupiter.api.Assertions; @@ -107,8 +108,13 @@ void testUpdateBlockGroupById() { @Test void testCreateBlockGroup() { BlockGroup param = new BlockGroup(); + Block block = new Block(); + block.setId(1); + List blockList = new ArrayList<>(); + blockList.add(block); when(blockGroupMapper.createBlockGroup(param)).thenReturn(1); when(loginUserContext.getLoginUserId()).thenReturn("1"); + when(blockGroupMapper.queryBlockGroupAndBlockById(1, null, loginUserContext.getLoginUserId())).thenReturn(param); BlockGroup blockGroupParam = new BlockGroup(); blockGroupParam.setId(1); Result result = blockGroupServiceImpl.createBlockGroup(blockGroupParam); diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/ComponentServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/ComponentServiceImplTest.java index 3d2db841..1834486d 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/ComponentServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/ComponentServiceImplTest.java @@ -18,11 +18,13 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.common.utils.Utils; +import com.tinyengine.it.mapper.ComponentLibraryMapper; import com.tinyengine.it.mapper.ComponentMapper; import com.tinyengine.it.model.dto.BundleMaterial; import com.tinyengine.it.model.dto.FileResult; import com.tinyengine.it.model.dto.JsonFile; import com.tinyengine.it.model.entity.Component; +import com.tinyengine.it.model.entity.ComponentLibrary; import com.tinyengine.it.model.entity.MaterialComponent; import com.tinyengine.it.model.entity.MaterialHistoryComponent; @@ -50,6 +52,8 @@ class ComponentServiceImplTest { @Mock private ComponentMapper componentMapper; + @Mock + private ComponentLibraryMapper componentLibraryMapper; @InjectMocks private ComponentServiceImpl componentServiceImpl; @@ -124,7 +128,11 @@ void testReadFileAndBulkCreate() { when(componentMapper.createMaterialComponent(any(MaterialComponent.class))).thenReturn(Integer.valueOf(0)); when(componentMapper.createMaterialHistoryComponent(any(MaterialHistoryComponent.class))) .thenReturn(Integer.valueOf(0)); - + ComponentLibrary componentLibrary = new ComponentLibrary(); + componentLibrary.setId(1); + List componentLibraryList = new ArrayList<>(); + componentLibraryList.add(componentLibrary); + when(componentLibraryMapper.queryComponentLibraryByCondition(componentLibrary)).thenReturn(componentLibraryList); MultipartFile file = mock(MultipartFile.class); HashMap fileContent = new HashMap<>(); BundleMaterial bundleMaterial = new BundleMaterial(); @@ -134,6 +142,7 @@ void testReadFileAndBulkCreate() { components.add(componentdata); bundleMaterial.setComponents(components); bundleMaterial.setSnippets(new ArrayList<>()); + bundleMaterial.setPackages(new ArrayList<>()); HashMap material = new HashMap<>(); material.put("framework", "Vue"); material.put("materials", bundleMaterial); diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImplTest.java index 2b9503ad..442ff2e4 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImplTest.java @@ -55,6 +55,7 @@ void testFindAllMaterialHistory() { @Test void testFindMaterialHistoryById() { MaterialHistory mockData = new MaterialHistory(); + mockData.setId(1); when(materialHistoryMapper.queryMaterialHistoryById(1)).thenReturn(mockData); Result result = materialHistoryServiceImpl.findMaterialHistoryById(1); @@ -74,6 +75,7 @@ void testFindMaterialHistoryByCondition() { @Test void testDeleteMaterialHistoryById() { MaterialHistory param = new MaterialHistory(); + param.setId(1); when(materialHistoryMapper.deleteMaterialHistoryById(1)).thenReturn(1); when(materialHistoryMapper.queryMaterialHistoryById(1)).thenReturn(param); @@ -84,6 +86,7 @@ void testDeleteMaterialHistoryById() { @Test void testUpdateMaterialHistoryById() { MaterialHistory param = new MaterialHistory(); + param.setId(1); when(materialHistoryMapper.updateMaterialHistoryById(param)).thenReturn(1); when(materialHistoryMapper.queryMaterialHistoryById(1)).thenReturn(param); @@ -94,6 +97,7 @@ void testUpdateMaterialHistoryById() { @Test void testCreateMaterialHistory() { MaterialHistory param = new MaterialHistory(); + param.setId(1); when(materialHistoryMapper.createMaterialHistory(param)).thenReturn(1); when(materialHistoryMapper.queryMaterialHistoryById(1)).thenReturn(param); diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java index 99285deb..2790414e 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java @@ -56,6 +56,7 @@ void testQueryAllMaterial() { @Test void testQueryMaterialById() { Material mockData = new Material(); + mockData.setId(1); when(materialMapper.queryMaterialById(1)).thenReturn(mockData); Result result = materialServiceImpl.queryMaterialById(1); @@ -74,8 +75,9 @@ void testQueryMaterialByCondition() { @Test void testDeleteMaterialById() { - when(materialMapper.deleteMaterialById(1)).thenReturn(2); + when(materialMapper.deleteMaterialById(1)).thenReturn(1); Material mockData = new Material(); + mockData.setId(1); when(materialMapper.queryMaterialById(1)).thenReturn(mockData); Result result = materialServiceImpl.deleteMaterialById(1); @@ -85,6 +87,7 @@ void testDeleteMaterialById() { @Test void testUpdateMaterialById() { Material param = new Material(); + param.setId(1); when(materialMapper.updateMaterialById(param)).thenReturn(1); when(materialMapper.queryMaterialById(1)).thenReturn(param); @@ -95,6 +98,7 @@ void testUpdateMaterialById() { @Test void testCreateMaterial() { Material param = new Material(); + param.setId(1); when(materialMapper.createMaterial(param)).thenReturn(1); when(materialMapper.queryMaterialById(1)).thenReturn(param); From 2f31f888194a278c58b973a270706f701982cc2a Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 6 Apr 2025 23:12:05 -0700 Subject: [PATCH 38/72] feat: component library api --- .../com/tinyengine/it/service/app/impl/PageServiceImpl.java | 6 ------ .../it/service/material/impl/ComponentServiceImpl.java | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java index a094e362..d80963e9 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java @@ -574,10 +574,7 @@ public boolean protectDefaultPage(Page page) { /** * 查询父页面 -<<<<<<< HEAD -======= * ->>>>>>> 342bb06d8974b37e0637fb5d3512f713dccf595b * @param parentId the parentId * @return parentId the parentId */ @@ -592,10 +589,7 @@ private String getParentPage(String parentId) { /** * 查询默认子页面 -<<<<<<< HEAD -======= * ->>>>>>> 342bb06d8974b37e0637fb5d3512f713dccf595b * @param parentId the parentId * @return subPageId the subPageId */ diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java index bf2d3602..b7ec01db 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java @@ -313,7 +313,8 @@ public Result bulkCreate(List componentList) { ComponentLibrary componentLibrary = new ComponentLibrary(); componentLibrary.setPackageName(String.valueOf(component.getNpm().get("package"))); componentLibrary.setVersion(component.getVersion()); - List componentLibraryList = componentLibraryMapper.queryComponentLibraryByCondition(componentLibrary); + List componentLibraryList = componentLibraryMapper + .queryComponentLibraryByCondition(componentLibrary); Integer componentLibraryId = null; if (!componentLibraryList.isEmpty()) { componentLibraryId = componentLibraryList.get(0).getId(); From 9ee1ef1148f11797ec420b6640a4b0a8e7b7b60f Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 6 Apr 2025 23:20:13 -0700 Subject: [PATCH 39/72] feat: component library api --- .../java/com/tinyengine/it/controller/ComponentController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java index 06f29307..fda2a651 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java @@ -66,7 +66,7 @@ public class ComponentController { content = @Content(mediaType = "application/json", schema = @Schema())), @ApiResponse(responseCode = "400", description = "请求失败")}) @SystemControllerLog(description = "上传bunled.json文件创建组件") - @PostMapping("/component/bundle/createComponent") + @PostMapping("/component/bundle/create") public Result bundleCreateComponent(@RequestParam MultipartFile file) { if (file.isEmpty()) { return Result.failed(ExceptionEnum.CM307); From 59c6ddcb068922bceabb717bcc86ebddf34ff5a7 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 6 Apr 2025 23:34:51 -0700 Subject: [PATCH 40/72] feat: component library api --- .../com/tinyengine/it/controller/ComponentController.java | 4 +++- .../tinyengine/it/controller/ComponentLibraryController.java | 3 ++- .../it/service/material/impl/ComponentLibraryServiceImpl.java | 3 --- .../it/service/material/impl/MaterialHistoryServiceImpl.java | 3 --- .../it/service/material/impl/MaterialServiceImpl.java | 3 --- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java index fda2a651..1248f3b9 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java @@ -31,11 +31,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import javax.validation.Valid; import java.util.List; /** @@ -108,7 +110,7 @@ public Result bundleSplit(@RequestParam MultipartFile file) { @ApiResponse(responseCode = "400", description = "请求失败")}) @SystemControllerLog(description = "批量创建自定义组件") @PostMapping("/component/batch/create") - public Result createCustComponent(@RequestParam CustComponentDto custComponentDto) { + public Result createCustComponent(@Valid @RequestBody CustComponentDto custComponentDto) { // 返回插入和更新的条数 return componentService.custComponentBatchCreate(custComponentDto); } diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java index 64adb5c3..eabc5237 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java @@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -131,7 +132,7 @@ public Result updateComponentLibrary(@PathVariable Integer id, @ApiResponse(responseCode = "400", description = "请求失败")} ) @SystemControllerLog(description = "删除ComponentLibrary信息") - @GetMapping("/component-library/delete/{id}") + @DeleteMapping("/component-library/delete/{id}") public Result deleteComponentLibrary(@PathVariable Integer id) { return componentLibraryService.deleteComponentLibraryById(id); } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java index 62902029..3af1449e 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java @@ -56,9 +56,6 @@ public List queryAllComponentLibrary() { @Override public Result queryComponentLibraryById(@Param("id") Integer id) { ComponentLibrary material = componentLibraryMapper.queryComponentLibraryById(id); - if(null == material.getId()){ - return Result.failed(ExceptionEnum.CM009); - } return Result.success(material); } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java index 41e281d2..ee56dedb 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java @@ -60,9 +60,6 @@ public List findAllMaterialHistory() { @Override public Result findMaterialHistoryById(@Param("id") Integer id) { MaterialHistory materialHistory = materialHistoryMapper.queryMaterialHistoryById(id); - if (null == materialHistory.getId()) { - return Result.failed(ExceptionEnum.CM009); - } return Result.success(materialHistory); } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java index 2750e61a..ef8638f2 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java @@ -57,9 +57,6 @@ public List queryAllMaterial() { @Override public Result queryMaterialById(@Param("id") Integer id) { Material material = materialMapper.queryMaterialById(id); - if(null == material.getId()){ - return Result.failed(ExceptionEnum.CM009); - } return Result.success(material); } From 8373484a55cb47d9d52df753603b5784bf7448e9 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 6 Apr 2025 23:38:35 -0700 Subject: [PATCH 41/72] feat: component library api --- .../java/com/tinyengine/it/controller/MaterialController.java | 3 ++- .../it/service/material/impl/MaterialServiceImpl.java | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/MaterialController.java b/base/src/main/java/com/tinyengine/it/controller/MaterialController.java index 6c4f91bf..374c9e98 100644 --- a/base/src/main/java/com/tinyengine/it/controller/MaterialController.java +++ b/base/src/main/java/com/tinyengine/it/controller/MaterialController.java @@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -131,7 +132,7 @@ public Result updateMaterial(@PathVariable Integer id, @RequestBody Ma @ApiResponse(responseCode = "400", description = "请求失败")} ) @SystemControllerLog(description = "删除Material信息") - @GetMapping("/material/delete/{id}") + @DeleteMapping("/material/delete/{id}") public Result deleteMaterial(@PathVariable Integer id) { return materialService.deleteMaterialById(id); } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java index ef8638f2..4e3ab51c 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java @@ -16,7 +16,6 @@ import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.mapper.MaterialMapper; import com.tinyengine.it.model.entity.Material; -import com.tinyengine.it.model.entity.MaterialHistory; import com.tinyengine.it.service.material.MaterialService; import lombok.extern.slf4j.Slf4j; From fb123c693d7f5e1828e17f5c08f6fa4d71a40022 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 6 Apr 2025 23:47:55 -0700 Subject: [PATCH 42/72] feat: component library api --- .../com/tinyengine/it/controller/ComponentController.java | 2 +- .../service/material/impl/ComponentLibraryServiceImpl.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java index 1248f3b9..3b7a6feb 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java @@ -104,7 +104,7 @@ public Result bundleSplit(@RequestParam MultipartFile file) { * @return result */ @Operation(summary = "批量创建自定义组件", description = "批量创建自定义组件", parameters = { - @Parameter(name = "file", description = "文件参数对象")}, responses = { + @Parameter(name = "custComponentDto", description = "自定义组件对象")}, responses = { @ApiResponse(responseCode = "200", description = "返回信息", content = @Content(mediaType = "application/json", schema = @Schema())), @ApiResponse(responseCode = "400", description = "请求失败")}) diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java index 3af1449e..c63f967f 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java @@ -78,11 +78,14 @@ public List queryComponentLibraryByCondition(ComponentLibrary */ @Override public Result deleteComponentLibraryById(@Param("id") Integer id) { + Result result = this.queryComponentLibraryById(id); + if(result.getData() == null || result.getData().getId() == null){ + return Result.success(); + } int deleteResult = componentLibraryMapper.deleteComponentLibraryById(id); if(deleteResult != 1){ return Result.failed(ExceptionEnum.CM008); } - Result result = this.queryComponentLibraryById(id); return result; } From 0875559eaa0af38825c287b61849346ed65f4359 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 6 Apr 2025 23:50:54 -0700 Subject: [PATCH 43/72] feat: component library api --- base/src/main/resources/mappers/ComponentLibraryMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/resources/mappers/ComponentLibraryMapper.xml b/base/src/main/resources/mappers/ComponentLibraryMapper.xml index 7b565887..f6574ddf 100644 --- a/base/src/main/resources/mappers/ComponentLibraryMapper.xml +++ b/base/src/main/resources/mappers/ComponentLibraryMapper.xml @@ -50,7 +50,7 @@ AND `public` = #{publicStatus} - AND is_started = #{publicStatus} + AND is_started = #{isStarted} AND is_official = #{isOfficial} From 40826264894158106b548cefc2df398e4c9e9606 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Mon, 7 Apr 2025 00:05:22 -0700 Subject: [PATCH 44/72] fix: Mock data is changed to be obtained from loginUserContext --- .../com/tinyengine/it/controller/CanvasController.java | 3 +++ .../com/tinyengine/it/controller/UserController.java | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/CanvasController.java b/base/src/main/java/com/tinyengine/it/controller/CanvasController.java index 6ce786ec..1dcaed37 100644 --- a/base/src/main/java/com/tinyengine/it/controller/CanvasController.java +++ b/base/src/main/java/com/tinyengine/it/controller/CanvasController.java @@ -41,6 +41,9 @@ @RequestMapping("/app-center/api") @Tag(name = "区块") public class CanvasController { + /** + * The canvas service. + */ @Autowired private CanvasService canvasService; diff --git a/base/src/main/java/com/tinyengine/it/controller/UserController.java b/base/src/main/java/com/tinyengine/it/controller/UserController.java index 0ae2d941..9da9b8db 100644 --- a/base/src/main/java/com/tinyengine/it/controller/UserController.java +++ b/base/src/main/java/com/tinyengine/it/controller/UserController.java @@ -13,6 +13,7 @@ package com.tinyengine.it.controller; import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.context.LoginUserContext; import com.tinyengine.it.model.entity.User; import com.tinyengine.it.service.app.UserService; @@ -42,6 +43,12 @@ public class UserController { @Autowired private UserService userService; + /** + * The loginUserContext service. + */ + @Autowired + private LoginUserContext loginUserContext; + /** * Me result. * @@ -49,7 +56,7 @@ public class UserController { */ @GetMapping("/user/me") public Result me() { - User user = userService.queryUserById(1); + User user = userService.queryUserById(Integer.parseInt(loginUserContext.getLoginUserId())); return Result.success(user); } } From 72539c558e9c95617a7c0545454fb4f1373e51cc Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Wed, 9 Apr 2025 19:22:43 -0700 Subject: [PATCH 45/72] fix: Component library mapper --- base/src/main/resources/mappers/ComponentLibraryMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/resources/mappers/ComponentLibraryMapper.xml b/base/src/main/resources/mappers/ComponentLibraryMapper.xml index f6574ddf..a82ecacb 100644 --- a/base/src/main/resources/mappers/ComponentLibraryMapper.xml +++ b/base/src/main/resources/mappers/ComponentLibraryMapper.xml @@ -302,7 +302,7 @@ CL.last_updated_time, CL.tenant_id, CL.renter_id, - CL.site_id + CL.site_id, C.id AS componentId, C.version AS componentVersion, C.name AS componentName, From a98b5034a9ebd3b0eb675d2415c3083a5e4f2137 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 10 Apr 2025 20:30:34 -0700 Subject: [PATCH 46/72] fix:Update t_component index --- .../sql/h2/create_all_tables_ddl_v1.h2.sql | 34 ++++++++++++++++++- .../sql/mysql/update_all_tables_ddl.sql | 2 ++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 app/src/main/resources/sql/mysql/update_all_tables_ddl.sql diff --git a/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql b/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql index ee023852..dbd8f3aa 100644 --- a/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql +++ b/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql @@ -642,4 +642,36 @@ create table `r_block_group_block` `block_group_id` int not null comment '区块分组id', primary key (`id`) using btree, unique index `u_idx_block_group_block` (block_id, block_group_id) using btree -) engine = innodb comment = '区块分组和区块关系表'; \ No newline at end of file +) engine = innodb comment = '区块分组和区块关系表'; + +drop table if exists `t_component_library`; + +create table `t_component_library` +( + `id` int not null auto_increment comment '主键id', + `version` varchar(255) not null comment '版本', + `name` varchar(255) not null comment '名称', + `package` varchar(255) not null comment '包名', + `registry` varchar(255) comment '注册', + `framework` varchar(255) not null comment '技术栈', + `description` varchar(2000) comment '描述', + `script` varchar(255) comment '脚本地址', + `css` varchar(255) comment '样式地址', + `bundle` varchar(255) comment 'bundle.json地址', + `dependencies` longtext comment '依赖', + `others` longtext comment '其他', + `thumbnail` varchar(255) comment '略图', + `public` int comment '公开状态:0,1,2', + `is_started` tinyint(1) comment '是否启用', + `is_official` tinyint(1) comment '是否是官方', + `is_default` tinyint(1) comment '是否是默认', + `tenant_id` varchar(60) not null comment '租户id', + `renter_id` varchar(60) comment '业务租户id', + `site_id` varchar(60) comment '站点id,设计预留字段', + `created_by` varchar(60) not null comment '创建人', + `created_time` timestamp not null default current_timestamp comment '创建时间', + `last_updated_by` varchar(60) not null comment '最后修改人', + `last_updated_time` timestamp not null default current_timestamp comment '更新时间', + primary key (`id`) using btree, + unique index `u_idx_component_library` (`tenant_id`, `name`, `version`) using btree +) engine = innodb comment = '组件库表'; diff --git a/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql new file mode 100644 index 00000000..d6f9c5d1 --- /dev/null +++ b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql @@ -0,0 +1,2 @@ +ALTER TABLE t_component DROP INDEX u_idx_component; +ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); \ No newline at end of file From 800565695b49c918144693083310dde761abd2ca Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 10 Apr 2025 20:32:21 -0700 Subject: [PATCH 47/72] fix:Update t_component index --- app/src/main/resources/sql/h2/update_all_tables_ddl.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/src/main/resources/sql/h2/update_all_tables_ddl.sql diff --git a/app/src/main/resources/sql/h2/update_all_tables_ddl.sql b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql new file mode 100644 index 00000000..d6f9c5d1 --- /dev/null +++ b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql @@ -0,0 +1,2 @@ +ALTER TABLE t_component DROP INDEX u_idx_component; +ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); \ No newline at end of file From 3c66527ffd1de7efdd863efc75db970e0777610b Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 15 Apr 2025 20:20:25 -0700 Subject: [PATCH 48/72] fix: Component and component library mapper --- base/src/main/resources/mappers/ComponentLibraryMapper.xml | 1 + base/src/main/resources/mappers/ComponentMapper.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/base/src/main/resources/mappers/ComponentLibraryMapper.xml b/base/src/main/resources/mappers/ComponentLibraryMapper.xml index a82ecacb..843864cf 100644 --- a/base/src/main/resources/mappers/ComponentLibraryMapper.xml +++ b/base/src/main/resources/mappers/ComponentLibraryMapper.xml @@ -273,6 +273,7 @@ C.site_id AS componentSiteId FROM t_component_library CL LEFT JOIN t_component C ON CL.id = C.library_id + WHERE CL.is_default = false diff --git a/base/src/main/resources/mappers/ComponentMapper.xml b/base/src/main/resources/mappers/ComponentMapper.xml index 021caf7d..d4d59e96 100644 --- a/base/src/main/resources/mappers/ComponentMapper.xml +++ b/base/src/main/resources/mappers/ComponentMapper.xml @@ -267,7 +267,7 @@ From 267f667fc6241d0ccade4f51f3f7fd00a15fd7cb Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 15 Apr 2025 20:39:07 -0700 Subject: [PATCH 49/72] fix: App v1 service --- .../tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java | 6 +++++- .../it/service/material/impl/ComponentServiceImpl.java | 1 + base/src/main/resources/mappers/ComponentLibraryMapper.xml | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java index cf55c7c4..3b8a4a03 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java @@ -507,7 +507,11 @@ public List> getSchemaComponentsMap(MetaDto metaDto) { // 合并两个 List List> componentsMap = new ArrayList<>(componentsSchema); componentsMap.addAll(blocksSchema); - return componentsMap; + // 使用 Stream API 去重 + List> uniqueComponents = componentsMap.stream() + .distinct() + .collect(Collectors.toList()); + return uniqueComponents; } // 将区块组装成schema数据 diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java index b7ec01db..33b733dd 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java @@ -148,6 +148,7 @@ public Result readFileAndBulkCreate(MultipartFile file) { for (ComponentLibrary componentLibrary : packageList) { componentLibrary.setIsDefault(true); componentLibrary.setIsStarted(true); + componentLibrary.setIsOfficial(true); ComponentLibrary library = new ComponentLibrary(); library.setName(componentLibrary.getName()); library.setVersion(componentLibrary.getVersion()); diff --git a/base/src/main/resources/mappers/ComponentLibraryMapper.xml b/base/src/main/resources/mappers/ComponentLibraryMapper.xml index 843864cf..a82ecacb 100644 --- a/base/src/main/resources/mappers/ComponentLibraryMapper.xml +++ b/base/src/main/resources/mappers/ComponentLibraryMapper.xml @@ -273,7 +273,6 @@ C.site_id AS componentSiteId FROM t_component_library CL LEFT JOIN t_component C ON CL.id = C.library_id - WHERE CL.is_default = false From 75f0be1b41c7491b1c12413041156e490b3e7b85 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 15 Apr 2025 20:43:42 -0700 Subject: [PATCH 50/72] fix: App v1 service --- .../com/tinyengine/it/controller/UserControllerTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/base/src/test/java/com/tinyengine/it/controller/UserControllerTest.java b/base/src/test/java/com/tinyengine/it/controller/UserControllerTest.java index 224ca517..3f485b91 100644 --- a/base/src/test/java/com/tinyengine/it/controller/UserControllerTest.java +++ b/base/src/test/java/com/tinyengine/it/controller/UserControllerTest.java @@ -16,6 +16,7 @@ import static org.mockito.Mockito.when; import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.context.LoginUserContext; import com.tinyengine.it.model.entity.User; import com.tinyengine.it.service.app.UserService; @@ -34,6 +35,8 @@ class UserControllerTest { @Mock private UserService userService; + @Mock + private LoginUserContext loginUserContext; @InjectMocks private UserController userController; @@ -46,7 +49,7 @@ void setUp() { void testMe() { User mockData = new User(); when(userService.queryUserById(anyInt())).thenReturn(mockData); - + when(loginUserContext.getLoginUserId()).thenReturn("1"); Result result = userController.me(); Assertions.assertEquals(mockData, result.getData()); } From e7071e7c9521395785d4c441411ed7854378ccce Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 17 Apr 2025 00:04:50 -0700 Subject: [PATCH 51/72] fix: Modify code format --- .../tinyengine/it/config/filter/WebConfig.java | 9 ++++----- .../it/controller/ComponentController.java | 2 -- .../tinyengine/it/model/dto/PackagesDto.java | 2 +- .../com/tinyengine/it/model/entity/App.java | 2 -- .../service/app/impl/v1/AppV1ServiceImpl.java | 17 +++++++++-------- .../it/service/material/MaterialService.java | 1 - .../impl/ComponentLibraryServiceImpl.java | 16 ++++++++-------- .../material/impl/MaterialServiceImpl.java | 14 +++++++------- .../material/impl/MaterialServiceImplTest.java | 1 - 9 files changed, 29 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/tinyengine/it/config/filter/WebConfig.java b/app/src/main/java/com/tinyengine/it/config/filter/WebConfig.java index c03c5bb5..cacdf4d5 100644 --- a/app/src/main/java/com/tinyengine/it/config/filter/WebConfig.java +++ b/app/src/main/java/com/tinyengine/it/config/filter/WebConfig.java @@ -24,13 +24,12 @@ import java.util.List; @Configuration -public class WebConfig implements WebMvcConfigurer { +public class WebConfig implements WebMvcConfigurer { @Value("${cors.allowed-origins}") private String allowedOrigins; @Bean - public CorsFilter corsFilter() - { + public CorsFilter corsFilter() { // 跨域配置地址 List crosDomainList = Arrays.asList(allowedOrigins.split(",")); @@ -46,6 +45,6 @@ public CorsFilter corsFilter() UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/**", corsConfiguration); - return new CorsFilter(source); - } + return new CorsFilter(source); + } } diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java index 3b7a6feb..390d5be2 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java @@ -18,7 +18,6 @@ import com.tinyengine.it.model.dto.BundleResultDto; import com.tinyengine.it.model.dto.CustComponentDto; import com.tinyengine.it.model.dto.FileResult; -import com.tinyengine.it.model.entity.Component; import com.tinyengine.it.service.material.ComponentService; import io.swagger.v3.oas.annotations.Operation; @@ -38,7 +37,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; -import java.util.List; /** * 组件api diff --git a/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java b/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java index d511636f..0f8b6fec 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java @@ -32,5 +32,5 @@ public class PackagesDto { private String version; private String script; private String css; - private Map others; + private Map others; } diff --git a/base/src/main/java/com/tinyengine/it/model/entity/App.java b/base/src/main/java/com/tinyengine/it/model/entity/App.java index 70fe58cc..a972626a 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/App.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/App.java @@ -24,8 +24,6 @@ import lombok.Setter; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java index 3b8a4a03..2e62fa27 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java @@ -252,19 +252,20 @@ private SchemaMeta getSchemaMeta(MetaDto metaDto) { * * @return List the List */ - private List getPackages(){ + private List getPackages() { List componentLibraryList = componentLibraryMapper.queryAllComponentLibrary(); List packagesDtoList = new ArrayList<>(); - if(componentLibraryList.isEmpty()){ + if (componentLibraryList.isEmpty()) { return packagesDtoList; } - for (ComponentLibrary componentLibrary: componentLibraryList){ + for (ComponentLibrary componentLibrary : componentLibraryList) { PackagesDto pakagesDto = new PackagesDto(); BeanUtils.copyProperties(componentLibrary, pakagesDto); packagesDtoList.add(pakagesDto); } return packagesDtoList; } + /** * 获取应用信息 * @@ -497,11 +498,11 @@ public List> getSchemaComponentsMap(MetaDto metaDto) { // 转换组件数据为schema List components = materialHistory.getComponents(); List componentLibraryList = componentLibraryMapper.queryAllComponentLibrary(); - if(!componentLibraryList.isEmpty()){ - List componentList = componentLibraryList.stream() - .flatMap(componentLibrary -> componentLibrary.getComponents().stream()) // 扁平化每个 List - .collect(Collectors.toList()); // 收集到一个新的 List - components.addAll(componentList); + if (!componentLibraryList.isEmpty()) { + List componentList = componentLibraryList.stream() + .flatMap(componentLibrary -> componentLibrary.getComponents().stream()) // 扁平化每个 List + .collect(Collectors.toList()); // 收集到一个新的 List + components.addAll(componentList); } List> componentsSchema = getComponentSchema(components); // 合并两个 List diff --git a/base/src/main/java/com/tinyengine/it/service/material/MaterialService.java b/base/src/main/java/com/tinyengine/it/service/material/MaterialService.java index 14b53a1f..7adf7792 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/MaterialService.java +++ b/base/src/main/java/com/tinyengine/it/service/material/MaterialService.java @@ -15,7 +15,6 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.model.entity.Material; -import com.tinyengine.it.model.entity.MaterialHistory; import org.apache.ibatis.annotations.Param; import java.util.List; diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java index c63f967f..34aca33c 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java @@ -77,13 +77,13 @@ public List queryComponentLibraryByCondition(ComponentLibrary * @return execute success data number */ @Override - public Result deleteComponentLibraryById(@Param("id") Integer id) { + public Result deleteComponentLibraryById(@Param("id") Integer id) { Result result = this.queryComponentLibraryById(id); - if(result.getData() == null || result.getData().getId() == null){ + if (result.getData() == null || result.getData().getId() == null) { return Result.success(); } - int deleteResult = componentLibraryMapper.deleteComponentLibraryById(id); - if(deleteResult != 1){ + int deleteResult = componentLibraryMapper.deleteComponentLibraryById(id); + if (deleteResult != 1) { return Result.failed(ExceptionEnum.CM008); } return result; @@ -97,9 +97,9 @@ public Result deleteComponentLibraryById(@Param("id") Integer * @return execute success data number */ @Override - public Result updateComponentLibraryById(ComponentLibrary componentLibrary) { + public Result updateComponentLibraryById(ComponentLibrary componentLibrary) { int updateResult = componentLibraryMapper.updateComponentLibraryById(componentLibrary); - if(updateResult != 1){ + if (updateResult != 1) { return Result.failed(ExceptionEnum.CM008); } Result result = this.queryComponentLibraryById(componentLibrary.getId()); @@ -113,9 +113,9 @@ public Result updateComponentLibraryById(ComponentLibrary com * @return execute success data number */ @Override - public Result createComponentLibrary(ComponentLibrary componentLibrary) { + public Result createComponentLibrary(ComponentLibrary componentLibrary) { int createResult = componentLibraryMapper.createComponentLibrary(componentLibrary); - if(createResult != 1){ + if (createResult != 1) { return Result.failed(ExceptionEnum.CM008); } Result result = this.queryComponentLibraryById(componentLibrary.getId()); diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java index 4e3ab51c..8ff669ca 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java @@ -77,9 +77,9 @@ public List queryMaterialByCondition(Material material) { * @return execute success data number */ @Override - public Result deleteMaterialById(@Param("id") Integer id) { - int deleteResult = materialMapper.deleteMaterialById(id); - if(deleteResult != 1){ + public Result deleteMaterialById(@Param("id") Integer id) { + int deleteResult = materialMapper.deleteMaterialById(id); + if (deleteResult != 1) { return Result.failed(ExceptionEnum.CM008); } Result result = this.queryMaterialById(id); @@ -94,9 +94,9 @@ public Result deleteMaterialById(@Param("id") Integer id) { * @return execute success data number */ @Override - public Result updateMaterialById(Material material) { + public Result updateMaterialById(Material material) { int updateResult = materialMapper.updateMaterialById(material); - if(updateResult != 1){ + if (updateResult != 1) { return Result.failed(ExceptionEnum.CM008); } Result result = this.queryMaterialById(material.getId()); @@ -110,9 +110,9 @@ public Result updateMaterialById(Material material) { * @return execute success data number */ @Override - public Result createMaterial(Material material) { + public Result createMaterial(Material material) { int createResult = materialMapper.createMaterial(material); - if(createResult != 1){ + if (createResult != 1) { return Result.failed(ExceptionEnum.CM008); } Result result = this.queryMaterialById(material.getId()); diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java index 2790414e..8abc1728 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/MaterialServiceImplTest.java @@ -17,7 +17,6 @@ import com.tinyengine.it.mapper.MaterialMapper; import com.tinyengine.it.model.entity.Material; -import com.tinyengine.it.model.entity.MaterialHistory; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; From 7d88f1cea8a2ede10abe0eae04297d6f5c842f2b Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Mon, 21 Apr 2025 03:01:54 -0700 Subject: [PATCH 52/72] fix: Modify mapper --- base/src/main/resources/mappers/AppMapper.xml | 12 ++++++------ .../resources/mappers/BlockHistoryMapper.xml | 12 ++++++------ base/src/main/resources/mappers/BlockMapper.xml | 12 ++++++------ .../resources/mappers/ComponentLibraryMapper.xml | 12 ++++++------ .../main/resources/mappers/ComponentMapper.xml | 6 +++--- .../main/resources/mappers/MaterialMapper.xml | 16 ++++++++-------- .../main/resources/mappers/PageHistoryMapper.xml | 12 ++++++------ base/src/main/resources/mappers/PageMapper.xml | 12 ++++++------ .../resources/mappers/PageTemplateMapper.xml | 12 ++++++------ .../main/resources/mappers/PlatformMapper.xml | 8 ++++---- base/src/main/resources/mappers/UserMapper.xml | 12 ++++++------ 11 files changed, 63 insertions(+), 63 deletions(-) diff --git a/base/src/main/resources/mappers/AppMapper.xml b/base/src/main/resources/mappers/AppMapper.xml index 0b7fffbb..3aa12b4c 100644 --- a/base/src/main/resources/mappers/AppMapper.xml +++ b/base/src/main/resources/mappers/AppMapper.xml @@ -82,7 +82,7 @@ AND is_demo = #{isDemo} - + AND is_default = #{isDefault} @@ -112,7 +112,7 @@ AND data_hash = #{dataHash} - + AND can_associate = #{canAssociate} @@ -173,7 +173,7 @@ state = #{state}, - + published = #{isPublish}, @@ -206,10 +206,10 @@ branch = #{branch}, - + is_demo = #{isDemo}, - + is_default = #{isDefault}, @@ -239,7 +239,7 @@ data_hash = #{dataHash}, - + can_associate = #{canAssociate}, diff --git a/base/src/main/resources/mappers/BlockHistoryMapper.xml b/base/src/main/resources/mappers/BlockHistoryMapper.xml index 9a8c4afc..1d31c777 100644 --- a/base/src/main/resources/mappers/BlockHistoryMapper.xml +++ b/base/src/main/resources/mappers/BlockHistoryMapper.xml @@ -53,16 +53,16 @@ AND tags = #{tags} - + AND is_official = #{isOfficial} AND public = #{isPublic} - + AND is_default = #{isDefault} - + AND tiny_reserved = #{isTinyReserved} @@ -147,16 +147,16 @@ tags = #{tags}, - + is_official = #{isOfficial}, public = #{isPublic}, - + is_default = #{isDefault}, - + tiny_reserved = #{isTinyReserved}, diff --git a/base/src/main/resources/mappers/BlockMapper.xml b/base/src/main/resources/mappers/BlockMapper.xml index c6a8a47b..fb83e5c6 100644 --- a/base/src/main/resources/mappers/BlockMapper.xml +++ b/base/src/main/resources/mappers/BlockMapper.xml @@ -54,16 +54,16 @@ AND occupier_by = #{occupierBy} - + AND is_official = #{isOfficial} AND `public` = #{publicStatus} - + AND is_default = #{isDefault} - + AND tiny_reserved = #{isTinyReserved} @@ -145,16 +145,16 @@ occupier_by = #{occupierBy}, - + is_official = #{isOfficial}, `public` = #{publicStatus}, - + is_default = #{isDefault}, - + tiny_reserved = #{isTinyReserved}, diff --git a/base/src/main/resources/mappers/ComponentLibraryMapper.xml b/base/src/main/resources/mappers/ComponentLibraryMapper.xml index a82ecacb..5cec078e 100644 --- a/base/src/main/resources/mappers/ComponentLibraryMapper.xml +++ b/base/src/main/resources/mappers/ComponentLibraryMapper.xml @@ -49,13 +49,13 @@ AND `public` = #{publicStatus} - + AND is_started = #{isStarted} - + AND is_official = #{isOfficial} - + AND is_default = #{isDefault} @@ -119,13 +119,13 @@ `public` = #{publicStatus}, - + is_started = #{isStarted}, - + is_official = #{isOfficial}, - + is_default = #{isDefault}, diff --git a/base/src/main/resources/mappers/ComponentMapper.xml b/base/src/main/resources/mappers/ComponentMapper.xml index d4d59e96..3fc382c1 100644 --- a/base/src/main/resources/mappers/ComponentMapper.xml +++ b/base/src/main/resources/mappers/ComponentMapper.xml @@ -169,13 +169,13 @@ framework = #{framework}, - + is_official = #{isOfficial}, - + is_default = #{isDefault}, - + tiny_reserved = #{isTinyReserved}, diff --git a/base/src/main/resources/mappers/MaterialMapper.xml b/base/src/main/resources/mappers/MaterialMapper.xml index 655e433b..5a0a35b1 100644 --- a/base/src/main/resources/mappers/MaterialMapper.xml +++ b/base/src/main/resources/mappers/MaterialMapper.xml @@ -30,7 +30,7 @@ AND image_url = #{imageUrl} - + AND published = #{isPublish} @@ -48,13 +48,13 @@ AND description = #{description} - + AND is_official = #{isOfficial} - + AND is_default = #{isDefault} - + AND tiny_reserved = #{isTinyReserved} @@ -115,7 +115,7 @@ image_url = #{imageUrl}, - + published = #{isPublish}, @@ -133,13 +133,13 @@ description = #{description}, - + is_official = #{isOfficial}, - + is_default = #{isDefault}, - + tiny_reserved = #{isTinyReserved}, diff --git a/base/src/main/resources/mappers/PageHistoryMapper.xml b/base/src/main/resources/mappers/PageHistoryMapper.xml index 218844c0..1774d5a7 100644 --- a/base/src/main/resources/mappers/PageHistoryMapper.xml +++ b/base/src/main/resources/mappers/PageHistoryMapper.xml @@ -31,7 +31,7 @@ AND page_content = #{pageContent} - + AND is_body = #{isBody} @@ -43,10 +43,10 @@ AND `depth` = #{depth} - + AND is_page = #{isPage} - + AND is_default = #{isDefault} @@ -104,7 +104,7 @@ page_content = #{pageContent}, - + is_body = #{isBody}, @@ -116,10 +116,10 @@ `depth` = #{depth}, - + is_page = #{isPage}, - + is_default = #{isDefault}, diff --git a/base/src/main/resources/mappers/PageMapper.xml b/base/src/main/resources/mappers/PageMapper.xml index b79a7a29..8786ddbf 100644 --- a/base/src/main/resources/mappers/PageMapper.xml +++ b/base/src/main/resources/mappers/PageMapper.xml @@ -26,7 +26,7 @@ AND page_content = #{pageContent} - + AND is_body = #{isBody} @@ -38,13 +38,13 @@ AND `depth` = #{depth} - + AND is_page = #{isPage} AND occupier_by = #{occupierBy} - + AND is_default = #{isDefault} @@ -93,7 +93,7 @@ page_content = #{pageContent}, - + is_body = #{isBody}, @@ -105,13 +105,13 @@ `depth` = #{depth}, - + is_page = #{isPage}, occupier_by = #{occupierBy}, - + is_default = #{isDefault}, diff --git a/base/src/main/resources/mappers/PageTemplateMapper.xml b/base/src/main/resources/mappers/PageTemplateMapper.xml index 27ca7d14..949fd328 100644 --- a/base/src/main/resources/mappers/PageTemplateMapper.xml +++ b/base/src/main/resources/mappers/PageTemplateMapper.xml @@ -22,10 +22,10 @@ AND framework = #{framework} - + AND published = #{published} - + AND `public` = #{publicStatus} @@ -34,7 +34,7 @@ AND status = #{status} - + AND is_preset = #{isPreset} @@ -80,10 +80,10 @@ framework = #{framework}, - + published = #{published}, - + `public` = #{publicStatus}, @@ -92,7 +92,7 @@ status = #{status}, - + is_preset = #{isPreset}, diff --git a/base/src/main/resources/mappers/PlatformMapper.xml b/base/src/main/resources/mappers/PlatformMapper.xml index ef8a8e1d..052dd768 100644 --- a/base/src/main/resources/mappers/PlatformMapper.xml +++ b/base/src/main/resources/mappers/PlatformMapper.xml @@ -18,7 +18,7 @@ AND name = #{name} - + AND published = #{isPublish} @@ -45,7 +45,7 @@ AND sort_toolbar = #{sortToolbar} - + AND is_default = #{isDefault} @@ -100,7 +100,7 @@ name = #{name}, - + published = #{isPublish}, @@ -127,7 +127,7 @@ sort_toolbar = #{sortToolbar}, - + is_default = #{isDefault}, diff --git a/base/src/main/resources/mappers/UserMapper.xml b/base/src/main/resources/mappers/UserMapper.xml index 69f533c4..add419f9 100644 --- a/base/src/main/resources/mappers/UserMapper.xml +++ b/base/src/main/resources/mappers/UserMapper.xml @@ -19,7 +19,7 @@ AND email = #{email} - + AND enable = #{isEnable} @@ -43,10 +43,10 @@ AND site_id = #{siteId} - + AND is_admin = #{isAdmin} - + AND is_public = #{isPublic} @@ -59,7 +59,7 @@ email = #{email}, - + enable = #{isEnable}, @@ -84,10 +84,10 @@ site_id = #{siteId}, - + is_admin = #{isAdmin}, - + is_public = #{isPublic}, From cabc1290b15d9c0abc0ee60d7dd8188dc6c34442 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 22 Apr 2025 18:23:55 -0700 Subject: [PATCH 53/72] fix: Modify bundle split --- .../com/tinyengine/it/model/entity/User.java | 2 ++ .../it/service/material/ComponentService.java | 17 +++++++++++++++++ .../material/impl/ComponentServiceImpl.java | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/base/src/main/java/com/tinyengine/it/model/entity/User.java b/base/src/main/java/com/tinyengine/it/model/entity/User.java index f8238a94..7c26cade 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/User.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/User.java @@ -12,6 +12,7 @@ package com.tinyengine.it.model.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.tinyengine.it.common.base.BaseEntity; @@ -38,6 +39,7 @@ public class User extends BaseEntity { @Schema(name = "email", description = "邮箱") private String email; + @TableField("enable") @Schema(name = "enable", description = "账号是否可用") private Boolean isEnable; diff --git a/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java b/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java index 4033bb1c..39a8f60f 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java +++ b/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java @@ -13,6 +13,7 @@ package com.tinyengine.it.service.material; import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.model.dto.BundleDto; import com.tinyengine.it.model.dto.BundleResultDto; import com.tinyengine.it.model.dto.CustComponentDto; import com.tinyengine.it.model.dto.FileResult; @@ -92,6 +93,22 @@ public interface ComponentService { */ Result bundleSplit(MultipartFile file); + /** + * 解析bundleDto为component集合 + * + * @param bundleDto bundleDto + * @return BundleResultDto BundleResultDto + */ + Result parseBundle(BundleDto bundleDto); + + /** + * 批量创建/更新组件 + * + * @param componentList componentList + * @return FileResult FileResult + */ + Result bulkCreate(List componentList); + /** * 批量创建component * diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java index 33b733dd..4e6680f1 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java @@ -195,7 +195,17 @@ public Result bundleSplit(MultipartFile file) { data = (Map) dataObj; } BundleDto bundleDto = BeanUtil.mapToBean(data, BundleDto.class, true); + return this.parseBundle(bundleDto); + } + /** + * 解析bundleDto为component集合 + * + * @param bundleDto bundleDto + * @return BundleResultDto BundleResultDto + */ + @Override + public Result parseBundle(BundleDto bundleDto) { List> components = bundleDto.getMaterials().getComponents(); List snippets = bundleDto.getMaterials().getSnippets(); From 2c60fa11635cd1597a150e875619edf44371658c Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Sun, 27 Apr 2025 00:49:57 -0700 Subject: [PATCH 54/72] fix: format code and fix style issue --- .../java/com/tinyengine/it/config/AiChatConfig.java | 6 +++--- .../com/tinyengine/it/gateway/ai/AiChatClient.java | 4 ++-- .../it/service/material/impl/BlockServiceImpl.java | 12 ++++-------- .../tinyengine/it/gateway/ai/AiChatClientTest.java | 5 ++--- .../it/service/app/impl/AiChatServiceImplTest.java | 2 +- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java b/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java index 14ee6573..e69c16b5 100644 --- a/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java +++ b/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java @@ -23,8 +23,8 @@ * @since 2024-10-20 */ public class AiChatConfig { - private static final String OPENAI_API_URL = "https://api.openai.com"; - private static final String LOCAL_GPT_API_URL = "https://dashscope.aliyuncs.com/compatible-mode"; + private static final String OPENAI_API_URL = "https://api.openai.com"; + private static final String LOCAL_GPT_API_URL = "https://dashscope.aliyuncs.com/compatible-mode"; /** @@ -32,7 +32,7 @@ public class AiChatConfig { * * @return the AI chat config */ - public static Map getAiChatConfig(String model,String token) { + public static Map getAiChatConfig(String model, String token) { Map config = new HashMap<>(); Map openaiHeaders = new HashMap<>(); diff --git a/base/src/main/java/com/tinyengine/it/gateway/ai/AiChatClient.java b/base/src/main/java/com/tinyengine/it/gateway/ai/AiChatClient.java index 9d34320c..017583ce 100644 --- a/base/src/main/java/com/tinyengine/it/gateway/ai/AiChatClient.java +++ b/base/src/main/java/com/tinyengine/it/gateway/ai/AiChatClient.java @@ -43,8 +43,8 @@ public class AiChatClient { /** * Instantiates a new Ai chat client. */ - public AiChatClient(String model,String token) { - this.config = AiChatConfig.getAiChatConfig(model,token); + public AiChatClient(String model, String token) { + this.config = AiChatConfig.getAiChatConfig(model, token); // Optional: Default base URL this.webClient = WebClient.builder().baseUrl("https://default.api.url").build(); } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java index d932106e..377a8810 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java @@ -93,7 +93,6 @@ public class BlockServiceImpl implements BlockService { private BlockGroupMapper blockGroupMapper; @Autowired private BlockGroupBlockMapper blockGroupBlockMapper; - @Autowired private LoginUserContext loginUserContext; @@ -190,7 +189,7 @@ public Result updateBlockById(BlockParam blockParam, Integer appId) { // 根据区块id获取区块所在分组 List blockGroups = blockGroupMapper.findBlockGroupByBlockId(blocks.getId(), loginUserContext.getLoginUserId()); // 删除区块与分组关系 - if(blockGroups != null && !blockGroups.isEmpty()){ + if (blockGroups != null && !blockGroups.isEmpty()) { List blockGroupIds = blockGroups.stream().map(BlockGroup::getId).collect(Collectors.toList()); for (Integer id : blockGroupIds) { blockGroupBlockMapper.deleteByGroupIdAndBlockId(id, blocks.getId()); @@ -287,21 +286,18 @@ public Map> getBlockAssets(Map pageContent, mergedAssets.put("styles", new ArrayList<>()); // Merge the assets using streams - return blocksList.stream().map(Block::getAssets).map(assetsMap -> - { + return blocksList.stream().map(Block::getAssets).map(assetsMap -> { Map> tempMap = new HashMap<>(); tempMap.put("material", (List) assetsMap.getOrDefault("material", new ArrayList<>())); tempMap.put("scripts", (List) assetsMap.getOrDefault("scripts", new ArrayList<>())); tempMap.put("styles", (List) assetsMap.getOrDefault("styles", new ArrayList<>())); return tempMap; - }).reduce(mergedAssets, (acc, curr) -> - { + }).reduce(mergedAssets, (acc, curr) -> { acc.get("material").addAll(curr.get("material")); acc.get("scripts").addAll(curr.get("scripts")); acc.get("styles").addAll(curr.get("styles")); return acc; - }, (map1, map2) -> - { + }, (map1, map2) -> { map1.get("material").addAll(map2.get("material")); map1.get("scripts").addAll(map2.get("scripts")); map1.get("styles").addAll(map2.get("styles")); diff --git a/base/src/test/java/com/tinyengine/it/gateway/ai/AiChatClientTest.java b/base/src/test/java/com/tinyengine/it/gateway/ai/AiChatClientTest.java index a59e7d12..1547ef62 100644 --- a/base/src/test/java/com/tinyengine/it/gateway/ai/AiChatClientTest.java +++ b/base/src/test/java/com/tinyengine/it/gateway/ai/AiChatClientTest.java @@ -87,16 +87,15 @@ void testExecuteChatRequest() { when(bodyUriSpec.uri(anyString())).thenReturn(bodyUriSpec); HashMap foundationModel = new HashMap<>(); foundationModel.put("model", "ERNIE-4.0-8K"); - foundationModel.put("token","asdf"); + foundationModel.put("token", "asdf"); ArrayList messages = new ArrayList<>(); AiMessages aiMessages = new AiMessages(); aiMessages.setContent("dddd编码时遵从以下几条要求aaa"); aiMessages.setName("John"); aiMessages.setRole("user"); messages.add(aiMessages); - AiParam param = new AiParam(foundationModel,Arrays.asList(aiMessages)); + AiParam param = new AiParam(foundationModel, Arrays.asList(aiMessages)); Map returnData = aiChatClient.executeChatRequest(param); Assertions.assertNull(returnData.get("data")); } } - diff --git a/base/src/test/java/com/tinyengine/it/service/app/impl/AiChatServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/app/impl/AiChatServiceImplTest.java index 43ea47cd..0905c253 100644 --- a/base/src/test/java/com/tinyengine/it/service/app/impl/AiChatServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/app/impl/AiChatServiceImplTest.java @@ -68,7 +68,7 @@ void testGetAnswerFromAi() { aiParam.setMessages(messages); HashMap foundationModel = new HashMap<>(); foundationModel.put("model", "ERNIE-4.0-8K"); - foundationModel.put("token","asdf"); + foundationModel.put("token", "asdf"); aiParam.setFoundationModel(foundationModel); Map dataMap = new HashMap<>(); From 1a380b62c333428983dec89a905f771b22748c96 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Wed, 30 Apr 2025 01:31:22 -0700 Subject: [PATCH 55/72] fix: fix getSchemaComponentsTree function bug --- base/src/main/java/com/tinyengine/it/config/AiChatConfig.java | 2 ++ .../tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java b/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java index e69c16b5..6537b0f4 100644 --- a/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java +++ b/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java @@ -26,6 +26,8 @@ public class AiChatConfig { private static final String OPENAI_API_URL = "https://api.openai.com"; private static final String LOCAL_GPT_API_URL = "https://dashscope.aliyuncs.com/compatible-mode"; + private static final String DEEPSEEK_V3_URL = "https://api.deepseek.com"; + /** * Gets AI chat config. diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java index 2e62fa27..d55fa0b0 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java @@ -467,7 +467,9 @@ public List getSchemaComponentsTree(MetaDto metaDto) { Map data = Utils.convert(pageInfo); boolean isToLine = false; Map page = formatDataFields(data, resKeys, isToLine); - page.put("isHome", String.valueOf(page.get("id")).equals(app.getHomePage().toString())); + if (null != app.getHomePage()) { + page.put("isHome", String.valueOf(page.get("id")).equals(app.getHomePage().toString())); + } Map schema; Schema schemaUtil = new Schema(); if (!pageInfo.getIsPage()) { From 15c6e8f381fa88aff66f14e3bb922030b263f0b7 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 6 May 2025 23:40:29 -0700 Subject: [PATCH 56/72] fix: Fix folder hierarchy restrictions and add AI models --- .../main/java/com/tinyengine/it/common/enums/Enums.java | 7 ++++++- .../main/java/com/tinyengine/it/config/AiChatConfig.java | 9 ++++++++- .../main/java/com/tinyengine/it/model/dto/AiParam.java | 2 ++ .../tinyengine/it/service/app/impl/PageServiceImpl.java | 5 +---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/common/enums/Enums.java b/base/src/main/java/com/tinyengine/it/common/enums/Enums.java index 2489eb00..e9b7f2ad 100644 --- a/base/src/main/java/com/tinyengine/it/common/enums/Enums.java +++ b/base/src/main/java/com/tinyengine/it/common/enums/Enums.java @@ -793,7 +793,12 @@ public enum FoundationModel { * Moonshot v1 8k e foundation model. */ // kimi - MOONSHOT_V1_8K("moonshot-v1-8k"); + MOONSHOT_V1_8K("moonshot-v1-8k"), + /** + * Moonshot v3 e foundation model. + */ + // deepseek + DEEPSEEK_V3("deepseek-chat"); private final String value; FoundationModel(String value) { diff --git a/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java b/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java index 6537b0f4..aac487be 100644 --- a/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java +++ b/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java @@ -25,7 +25,6 @@ public class AiChatConfig { private static final String OPENAI_API_URL = "https://api.openai.com"; private static final String LOCAL_GPT_API_URL = "https://dashscope.aliyuncs.com/compatible-mode"; - private static final String DEEPSEEK_V3_URL = "https://api.deepseek.com"; @@ -46,14 +45,22 @@ public static Map getAiChatConfig(String model, String String localGptApiKey = Enums.FoundationModel.LOCAL_GPT.getValue().equals(model) ? token : null; localGptHeaders.put("Authorization", "Bearer " + localGptApiKey); + Map deepSeekHeaders = new HashMap<>(); + String deepSeekApiKey = Enums.FoundationModel.DEEPSEEK_V3.getValue().equals(model) ? token : null; + deepSeekHeaders.put("Authorization", "Bearer " + deepSeekApiKey); + Map ernieBotHeaders = new HashMap<>(); + config.put(Enums.FoundationModel.GPT_35_TURBO.getValue(), new AiChatConfigData( OPENAI_API_URL + "/v1/chat/completions", createCommonRequestOption(), openaiHeaders, "openai")); config.put(Enums.FoundationModel.LOCAL_GPT.getValue(), new AiChatConfigData( LOCAL_GPT_API_URL + "/v1/chat/completions", createCommonRequestOption(), localGptHeaders, "!openai")); + config.put(Enums.FoundationModel.DEEPSEEK_V3.getValue(), new AiChatConfigData( + DEEPSEEK_V3_URL + "/chat/completions", createCommonRequestOption(), deepSeekHeaders, "DeepSeek")); + String ernieBotAccessToken = Enums.FoundationModel.ERNIBOT_TURBO.getValue().equals(model) ? token : null; config.put(Enums.FoundationModel.ERNIBOT_TURBO.getValue(), new AiChatConfigData( diff --git a/base/src/main/java/com/tinyengine/it/model/dto/AiParam.java b/base/src/main/java/com/tinyengine/it/model/dto/AiParam.java index 01168485..85242481 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/AiParam.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/AiParam.java @@ -26,10 +26,12 @@ public class AiParam { private Map foundationModel; private List messages; + private String model; public AiParam(Map foundationModel, List messages) { this.foundationModel = foundationModel; this.messages = messages; + this.model = foundationModel.get("model"); } public AiParam() { diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java index d80963e9..681ce799 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java @@ -445,10 +445,7 @@ public Result getDepth(String parentId) { // getFolder 获取父类信息 Page parentInfo = pageMapper.queryPageById(parent); int depth = parentInfo.getDepth(); - if (depth < 5) { - return Result.success(depth); - } - return Result.failed("Exceeded depth"); + return Result.success(depth); } /** From 243d8f93654ee1ef7fc585dd410f5015688e5c64 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Wed, 7 May 2025 23:21:01 -0700 Subject: [PATCH 57/72] fix: block lock issue --- .../tinyengine/it/service/material/impl/BlockServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java index 377a8810..842fa819 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java @@ -228,6 +228,7 @@ public Result createBlock(BlockParam blockParam) { } // 对接收到的参数occupier为对应的一个对象,进行特殊处理并重新赋值 Block blocks = new Block(); + blocks.setOccupierBy(loginUserContext.getLoginUserId()); if (blockParam.getOccupier() != null) { blocks.setOccupierBy(String.valueOf(blockParam.getOccupier().getId())); } From b98e1933542f64ea98ce723b251836ec5d1bfacb Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Fri, 9 May 2025 02:55:09 -0700 Subject: [PATCH 58/72] fead: platform API --- .../sql/h2/create_all_tables_ddl_v1.h2.sql | 4 +- .../sql/h2/update_all_tables_ddl.sql | 7 +- .../mysql/create_all_tables_ddl_v1.mysql.sql | 6 +- .../sql/mysql/update_all_tables_ddl.sql | 7 +- .../it/controller/PlatformController.java | 162 ++++++++++++ .../controller/PlatformHistoryController.java | 162 ++++++++++++ .../it/mapper/PlatformHistoryMapper.java | 75 ++++++ .../tinyengine/it/model/entity/Platform.java | 2 + .../it/model/entity/PlatformHistory.java | 64 +++++ .../platform/PlatformHistoryService.java | 73 ++++++ .../it/service/platform/PlatformService.java | 13 +- .../impl/PlatformHistorySrviceImpl.java | 118 +++++++++ .../platform/impl/PlatformServiceImpl.java | 37 ++- .../mappers/PlatformHistoryMapper.xml | 239 ++++++++++++++++++ .../impl/PlatformServiceImplTest.java | 18 +- 15 files changed, 958 insertions(+), 29 deletions(-) create mode 100644 base/src/main/java/com/tinyengine/it/controller/PlatformController.java create mode 100644 base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java create mode 100644 base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java create mode 100644 base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java create mode 100644 base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java create mode 100644 base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java create mode 100644 base/src/main/resources/mappers/PlatformHistoryMapper.xml diff --git a/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql b/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql index dbd8f3aa..07ce9bd1 100644 --- a/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql +++ b/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql @@ -41,11 +41,11 @@ create table `t_platform_history` `ref_id` int not null comment '关联主表id', `version` varchar(255) not null comment '版本', `name` varchar(255) not null comment '名称', - `publish_url` varchar(255) not null comment '设计器静态资源托管地址', + `publish_url` varchar(255) comment '设计器静态资源托管地址', `description` varchar(2000) comment '描述', `vscode_url` varchar(255) comment '设计预留字段', `material_history_id` int not null comment '关联物料包历史id', - `sub_count` int not null comment '设计预留字段', + `sub_count` int comment '设计预留字段', `material_pkg_name` varchar(255) comment '物料包名称', `material_version` varchar(255) comment '物料包版本', `image_url` varchar(255) comment '封面图地址', diff --git a/app/src/main/resources/sql/h2/update_all_tables_ddl.sql b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql index d6f9c5d1..4c5c7a09 100644 --- a/app/src/main/resources/sql/h2/update_all_tables_ddl.sql +++ b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql @@ -1,2 +1,7 @@ ALTER TABLE t_component DROP INDEX u_idx_component; -ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); \ No newline at end of file +ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); + +ALTER TABLE t_datasource DROP INDEX u_idx_datasource; +ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`); + +ALTER TABLE t_platform_history MODIFY sub_count int NULL; \ No newline at end of file diff --git a/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql b/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql index a4cfa649..bccbab33 100644 --- a/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql +++ b/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql @@ -41,11 +41,11 @@ create table `t_platform_history` `ref_id` int not null comment '关联主表id', `version` varchar(255) not null comment '版本', `name` varchar(255) not null comment '名称', - `publish_url` varchar(255) not null comment '设计器静态资源托管地址', + `publish_url` varchar(255) comment '设计器静态资源托管地址', `description` varchar(2000) comment '描述', - `vscode_url` varchar(255) comment '设计预留字段', + `vscode_url` varchar(255) comment '设计预留字段', `material_history_id` int not null comment '关联物料包历史id', - `sub_count` int not null comment '设计预留字段', + `sub_count` int comment '设计预留字段', `material_pkg_name` varchar(255) comment '物料包名称', `material_version` varchar(255) comment '物料包版本', `image_url` varchar(255) comment '封面图地址', diff --git a/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql index d6f9c5d1..4c5c7a09 100644 --- a/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql +++ b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql @@ -1,2 +1,7 @@ ALTER TABLE t_component DROP INDEX u_idx_component; -ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); \ No newline at end of file +ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); + +ALTER TABLE t_datasource DROP INDEX u_idx_datasource; +ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`); + +ALTER TABLE t_platform_history MODIFY sub_count int NULL; \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/controller/PlatformController.java b/base/src/main/java/com/tinyengine/it/controller/PlatformController.java new file mode 100644 index 00000000..6f9b1185 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/controller/PlatformController.java @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.controller; + +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.log.SystemControllerLog; +import com.tinyengine.it.model.entity.Platform; +import com.tinyengine.it.service.platform.PlatformService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * 设计器api + * + * @since 2024-10-20 + */ +@Validated +@RestController +@RequestMapping("/platform-center/api") +@Tag(name = "设计器") +public class PlatformController { + /** + * The Platform service. + */ + @Autowired + private PlatformService platformService; + + /** + * 查询表Platform信息 + * + * @return Platform信息 all app + */ + @Operation(summary = "查询表Platform信息", + description = "查询表Platform信息", + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "查询表Platform信息") + @GetMapping("/platform/list") + public Result> getAllPlatform() { + List appList = platformService.queryAllPlatform(); + return Result.success(appList); + } + + /** + * 根据id查询表Platform信息 + * + * @param id the id + * @return Platform信息 app by id + */ + @Operation(summary = "根据id查询表Platform信息", + description = "根据id查询表Platform信息", + parameters = { + @Parameter(name = "id", description = "Platform主键id") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "根据id查询表Platform信息") + @GetMapping("/platform/{id}") + public Result getPlatformById(@PathVariable Integer id) { + Platform platform = platformService.queryPlatformById(id); + return Result.success(platform); + } + + /** + * 创建Platform + * + * @param platform the platform + * @return Platform信息 result + */ + @Operation(summary = "创建platform", + description = "创建platform", + parameters = { + @Parameter(name = "platform", description = "Platform入参对象") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "创建platform") + @PostMapping("/platform/create") + public Result createPlatform(@Valid @RequestBody Platform platform) { + return platformService.createPlatform(platform); + } + + /** + * 修改Platform信息 + * + * @param id the id + * @param platform the platform + * @return Platform信息 result + */ + @Operation(summary = "修改单个Platform信息", description = "修改单个Platform信息", parameters = { + @Parameter(name = "id", description = "appId"), + @Parameter(name = "Platform", description = "入参对象")}, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "修改单个Platform信息") + @PostMapping("/platform/update/{id}") + public Result updatePlatform(@PathVariable Integer id, @RequestBody Platform platform) { + platform.setId(id); + return platformService.updatePlatformById(platform); + } + + /** + * 删除Platform信息 + * + * @param id the id + * @return platform信息 result + */ + @Operation(summary = "删除platform信息", + description = "删除platform信息", + parameters = { + @Parameter(name = "id", description = "Platform主键id") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "删除platform信息") + @GetMapping("/platform/delete/{id}") + public Result deletePlatform(@PathVariable Integer id) { + return platformService.deletePlatformById(id); + } +} diff --git a/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java new file mode 100644 index 00000000..7f8f7ff4 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.controller; + +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.log.SystemControllerLog; +import com.tinyengine.it.model.entity.PlatformHistory; +import com.tinyengine.it.service.platform.PlatformHistoryService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * 设计器api + * + * @since 2024-10-20 + */ +@Validated +@RestController +@RequestMapping("/platform-center/api") +@Tag(name = "设计器历史") +public class PlatformHistoryController { + /** + * The PlatformHistory service. + */ + @Autowired + private PlatformHistoryService platformHistoryService; + + /** + * 查询表PlatformHistory信息 + * + * @return PlatformHistory信息 all app + */ + @Operation(summary = "查询表PlatformHistory信息", + description = "查询表PlatformHistory信息", + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "查询表PlatformHistory信息") + @GetMapping("/platform-history/list") + public Result> getAllPlatformHistory() { + List appList = platformHistoryService.queryAllPlatformHistory(); + return Result.success(appList); + } + + /** + * 根据id查询表PlatformHistory信息 + * + * @param id the id + * @return PlatformHistory信息 app by id + */ + @Operation(summary = "根据id查询表PlatformHistory信息", + description = "根据id查询表PlatformHistory信息", + parameters = { + @Parameter(name = "id", description = "PlatformHistory主键id") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "根据id查询表PlatformHistory信息") + @GetMapping("/platform-history/{id}") + public Result getPlatformHistoryById(@PathVariable Integer id) { + PlatformHistory platformHistory = platformHistoryService.queryPlatformHistoryById(id); + return Result.success(platformHistory); + } + + /** + * 创建PlatformHistory + * + * @param platformHistory the platformHistory + * @return PlatformHistory信息 result + */ + @Operation(summary = "创建platformHistory", + description = "创建platformHistory", + parameters = { + @Parameter(name = "platformHistory", description = "PlatformHistory入参对象") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "创建platformHistory") + @PostMapping("/platform-history/create") + public Result createPlatformHistory(@Valid @RequestBody PlatformHistory platformHistory) { + return platformHistoryService.createPlatformHistory(platformHistory); + } + + /** + * 修改PlatformHistory信息 + * + * @param id the id + * @param platformHistory the platformHistory + * @return PlatformHistory信息 result + */ + @Operation(summary = "修改单个PlatformHistory信息", description = "修改单个PlatformHistory信息", parameters = { + @Parameter(name = "id", description = "appId"), + @Parameter(name = "PlatformHistory", description = "入参对象")}, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "修改单个PlatformHistory信息") + @PostMapping("/platform-history/update/{id}") + public Result updatePlatformHistory(@PathVariable Integer id, @RequestBody PlatformHistory platformHistory) { + platformHistory.setId(id); + return platformHistoryService.updatePlatformHistoryById(platformHistory); + } + + /** + * 删除PlatformHistory信息 + * + * @param id the id + * @return platformHistory信息 result + */ + @Operation(summary = "删除platformHistory信息", + description = "删除platformHistory信息", + parameters = { + @Parameter(name = "id", description = "PlatformHistory主键id") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "删除platformHistory信息") + @GetMapping("/platform-history/delete/{id}") + public Result deletePlatformHistory(@PathVariable Integer id) { + return platformHistoryService.deletePlatformHistoryById(id); + } +} diff --git a/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java b/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java new file mode 100644 index 00000000..837d95e7 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.tinyengine.it.model.entity.Platform; + +import com.tinyengine.it.model.entity.PlatformHistory; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * The interface Platform history mapper. + * + * @since 2025-05-09 + */ +public interface PlatformHistoryMapper extends BaseMapper { + /** + * 查询表t_platform_history所有信息 + * + * @return the list + */ + List queryAllPlatformHistory(); + + /** + * 根据主键id查询表t_platform_history数据 + * + * @param id the id + * @return the platform + */ + PlatformHistory queryPlatformHistoryById(Integer id); + + /** + * 根据条件查询表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the list + */ + List queryPlatformHistoryByCondition(PlatformHistory platformHistory); + + /** + * 根据主键id删除表t_platform_history数据 + * + * @param id the id + * @return the integer + */ + Integer deletePlatformHistoryById(@Param("id") Integer id); + + /** + * 根据主键id更新表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the integer + */ + Integer updatePlatformHistoryById(PlatformHistory platformHistory); + + /** + * 新增表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the integer + */ + Integer createPlatformHistory(PlatformHistory platformHistory); +} diff --git a/base/src/main/java/com/tinyengine/it/model/entity/Platform.java b/base/src/main/java/com/tinyengine/it/model/entity/Platform.java index 39444d0d..acae4205 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/Platform.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/Platform.java @@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonProperty; import com.tinyengine.it.common.base.BaseEntity; import com.tinyengine.it.common.handler.ListTypeHandler; import com.tinyengine.it.common.handler.MapTypeHandler; @@ -42,6 +43,7 @@ public class Platform extends BaseEntity { private String name; @Schema(name = "published", description = "是否发布:1是,0否") + @JsonProperty("published") private Boolean isPublish; @Schema(name = "lastBuildInfo", description = "最后构建信息") diff --git a/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java b/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java new file mode 100644 index 00000000..1bfeab23 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.model.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.tinyengine.it.common.base.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; + +/** + * + * 设计器历史表 + * + * @since 2025-05-09 + */ +@Getter +@Setter +@TableName("t_platform_history") +@Schema(name = "PlatformHistory", description = "设计器历史表") +public class PlatformHistory extends BaseEntity { + @Schema(name = "refId", description = "设计器id") + private Integer refId; + + @Schema(name = "name", description = "名称") + private String name; + + @Schema(name = "publishUrl", description = "设计器静态资源托管地址") + private String publishUrl; + + @Schema(name = "description", description = "描述") + private String description; + + @Schema(name = "version", description = "当前历史记录表版本") + private String version; + + @Schema(name = "subCount", description = "设计预留字段") + private Integer subCount; + + @Schema(name = "materialHistoryId", description = "关联物料包历史ID") + private Integer materialHistoryId; + + @Schema(name = "imageUrl", description = "设计器截图地址") + private String imageUrl; + + @Schema(name = "materialPkgName", description = "物料包名称") + private String materialPkgName; + + @Schema(name = "materialVersion", description = "物料包版本") + private String materialVersion; + + @Schema(name = "vscodeUrl", description = "*设计预留字段*") + private String vscodeUrl; +} diff --git a/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java b/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java new file mode 100644 index 00000000..de5cc061 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.service.platform; + +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.model.entity.PlatformHistory; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * The interface platform history service. + * + * @since 2025-05-09 + */ +public interface PlatformHistoryService { + /** + * 查询表t_platform_history所有信息 + * + * @return the list + */ + List queryAllPlatformHistory(); + + /** + * 根据主键id查询表t_platform_history信息 + * + * @param id the id + * @return the platformHistory + */ + PlatformHistory queryPlatformHistoryById(@Param("id") Integer id); + + /** + * 根据条件查询表t_platform_history信息 + * + * @param platformHistory the platformHistory + * @return the list + */ + List queryPlatformHistoryByCondition(PlatformHistory platformHistory); + + /** + * 根据主键id删除t_platform_history数据 + * + * @param id the id + * @return the Result + */ + Result deletePlatformHistoryById(@Param("id") Integer id); + + /** + * 根据主键id更新表t_platform_history信息 + * + * @param platformHistory the platformHistory + * @return the Result + */ + Result updatePlatformHistoryById(PlatformHistory platformHistory); + + /** + * 新增表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the Result + */ + Result createPlatformHistory(PlatformHistory platformHistory); +} diff --git a/base/src/main/java/com/tinyengine/it/service/platform/PlatformService.java b/base/src/main/java/com/tinyengine/it/service/platform/PlatformService.java index 8163d7ff..552b9e7a 100644 --- a/base/src/main/java/com/tinyengine/it/service/platform/PlatformService.java +++ b/base/src/main/java/com/tinyengine/it/service/platform/PlatformService.java @@ -12,6 +12,7 @@ package com.tinyengine.it.service.platform; +import com.tinyengine.it.common.base.Result; import com.tinyengine.it.model.entity.Platform; import org.apache.ibatis.annotations.Param; @@ -51,23 +52,23 @@ public interface PlatformService { * 根据主键id删除t_platform数据 * * @param id the id - * @return the integer + * @return the Result */ - Integer deletePlatformById(@Param("id") Integer id); + Result deletePlatformById(@Param("id") Integer id); /** * 根据主键id更新表t_platform信息 * * @param platform the platform - * @return the integer + * @return the Result */ - Integer updatePlatformById(Platform platform); + Result updatePlatformById(Platform platform); /** * 新增表t_platform数据 * * @param platform the platform - * @return the integer + * @return the Result */ - Integer createPlatform(Platform platform); + Result createPlatform(Platform platform); } diff --git a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java new file mode 100644 index 00000000..3f869523 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.service.platform.impl; + +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.exception.ExceptionEnum; +import com.tinyengine.it.mapper.PlatformHistoryMapper; +import com.tinyengine.it.model.entity.PlatformHistory; +import com.tinyengine.it.service.platform.PlatformHistoryService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * The interface platform history service. + * + * @since 2025-05-09 + */ +@Service +@Slf4j +public class PlatformHistorySrviceImpl implements PlatformHistoryService { + @Autowired + private PlatformHistoryMapper platformHistoryMapper; + + /** + * 查询表t_platform_history所有信息 + * + * @return the list + */ + @Override + public List queryAllPlatformHistory() { + return platformHistoryMapper.queryAllPlatformHistory(); + } + + /** + * 根据主键id查询表t_platform_history信息 + * + * @param id the id + * @return the platformHistory + */ + @Override + public PlatformHistory queryPlatformHistoryById(Integer id) { + return platformHistoryMapper.queryPlatformHistoryById(id); + } + + /** + * 根据条件查询表t_platform_history信息 + * + * @param platformHistory the platformHistory + * @return the list + */ + @Override + public List queryPlatformHistoryByCondition(PlatformHistory platformHistory) { + return platformHistoryMapper.queryPlatformHistoryByCondition(platformHistory); + } + + /** + * 根据主键id删除t_platform_history数据 + * + * @param id the id + * @return the Result + */ + @Override + public Result deletePlatformHistoryById(Integer id) { + PlatformHistory platformHistory = this.queryPlatformHistoryById(id); + if (platformHistory == null || platformHistory.getId() == null) { + return Result.success(); + } + int deleteResult = platformHistoryMapper.deletePlatformHistoryById(id); + if (deleteResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + return Result.success(platformHistory); + } + + /** + * 根据主键id更新表t_platform_history信息 + * + * @param platformHistory the platformHistory + * @return the Result + */ + @Override + public Result updatePlatformHistoryById(PlatformHistory platformHistory) { + int updateResult = platformHistoryMapper.updatePlatformHistoryById(platformHistory); + if (updateResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + PlatformHistory platformHistoryResult = this.queryPlatformHistoryById(platformHistory.getId()); + return Result.success(platformHistoryResult); + } + + /** + * 新增表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the Result + */ + @Override + public Result createPlatformHistory(PlatformHistory platformHistory) { + int createResult = platformHistoryMapper.createPlatformHistory(platformHistory); + if (createResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + return Result.success(platformHistory); + } +} diff --git a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java index ee4d37d4..b9d06600 100644 --- a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java @@ -12,6 +12,8 @@ package com.tinyengine.it.service.platform.impl; +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.mapper.PlatformMapper; import com.tinyengine.it.model.entity.Platform; import com.tinyengine.it.service.platform.PlatformService; @@ -71,32 +73,49 @@ public List queryPlatformByCondition(Platform platform) { * 根据主键id删除表t_platform数据 * * @param id id - * @return execute success data number + * @return Result */ @Override - public Integer deletePlatformById(@Param("id") Integer id) { - return platformMapper.deletePlatformById(id); + public Result deletePlatformById(@Param("id") Integer id) { + Platform platform = this.queryPlatformById(id); + if (platform == null || platform.getId() == null) { + return Result.success(); + } + int deleteResult = platformMapper.deletePlatformById(id); + if (deleteResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + return Result.success(platform); } /** * 根据主键id更新表t_platform数据 * * @param platform platform - * @return execute success data number + * @return Result */ @Override - public Integer updatePlatformById(Platform platform) { - return platformMapper.updatePlatformById(platform); + public Result updatePlatformById(Platform platform) { + int updateResult = platformMapper.updatePlatformById(platform); + if (updateResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + Platform platformResult = platformMapper.queryPlatformById(platform.getId()); + return Result.success(platformResult); } /** * 新增表t_platform数据 * * @param platform platform - * @return execute success data number + * @return Result */ @Override - public Integer createPlatform(Platform platform) { - return platformMapper.createPlatform(platform); + public Result createPlatform(Platform platform) { + int createResult = platformMapper.createPlatform(platform); + if (createResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + return Result.success(platform); } } diff --git a/base/src/main/resources/mappers/PlatformHistoryMapper.xml b/base/src/main/resources/mappers/PlatformHistoryMapper.xml new file mode 100644 index 00000000..52c7871f --- /dev/null +++ b/base/src/main/resources/mappers/PlatformHistoryMapper.xml @@ -0,0 +1,239 @@ + + + + + + + + + id, ref_id, name, version, publish_url, vscode_url, description, material_history_id, sub_count, material_pkg_name, + material_version, image_url, tenant_id, renter_id, site_id, created_by, last_updated_by, + created_time, last_updated_time + + + + + + AND ref_id = #{refId} + + + AND name = #{name} + + + AND publish_url = #{publishUrl} + + + AND version = #{version} + + + AND description = #{description} + + + AND vscode_url = #{vscodeUrl} + + + AND material_history_id = #{materialHistoryId} + + + AND image_url = #{imageUrl} + + + AND sub_count = #{subCount} + + + AND material_pkg_name = #{materialPkgName} + + + AND material_version = #{materialVersion} + + + AND tenant_id = #{tenantId} + + + AND renter_id = #{renterId} + + + AND site_id = #{siteId} + + + AND created_by = #{createdBy} + + + AND last_updated_by = #{lastUpdatedBy} + + + AND created_time = #{createdTime} + + + AND last_updated_time = #{lastUpdatedTime} + + + + + + + ref_id = #{refId}, + + + name = #{name}, + + + publish_url = #{publishUrl}, + + + version = #{version}, + + + description = #{description}, + + + vscode_url = #{vscodeUrl}, + + + material_history_id = #{materialHistoryId}, + + + image_url = #{imageUrl}, + + + sub_count = #{subCount}, + + + material_pkg_name = #{materialPkgName}, + + + material_version = #{materialVersion}, + + + tenant_id = #{tenantId}, + + + renter_id = #{renterId}, + + + site_id = #{siteId}, + + + created_by = #{createdBy}, + + + last_updated_by = #{lastUpdatedBy}, + + + created_time = #{createdTime}, + + + last_updated_time = #{lastUpdatedTime}, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE + FROM t_platform_history + WHERE id = #{id} + + + + + UPDATE t_platform_history + + + + WHERE + id=#{id} + + + + + INSERT INTO t_platform_history ( id + , ref_id + , name + , version + , publish_url + , description + , sub_count + , material_history_id + , image_url + , material_pkg_name + , material_version + , vscode_url + , tenant_id + , renter_id + , site_id + , created_by + , last_updated_by + , created_time + , last_updated_time) + VALUES ( #{id} + , #{refId} + , #{name} + , #{version} + , #{publishUrl} + , #{description} + , #{subCount} + , #{materialHistoryId} + , #{imageUrl} + , #{materialPkgName} + , #{materialVersion} + , #{vscodeUrl} + , #{tenantId} + , #{renterId} + , #{siteId} + , #{createdBy} + , #{lastUpdatedBy} + , #{createdTime} + , #{lastUpdatedTime}) + + diff --git a/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java index 86990dee..cfbc00e2 100644 --- a/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java @@ -14,6 +14,7 @@ import static org.mockito.Mockito.when; +import com.tinyengine.it.common.base.Result; import com.tinyengine.it.mapper.PlatformMapper; import com.tinyengine.it.model.entity.Platform; @@ -73,19 +74,22 @@ void testQueryPlatformByCondition() { @Test void testDeletePlatformById() { + Platform mockData = new Platform(); + when(platformMapper.queryPlatformById(1)).thenReturn(mockData); when(platformMapper.deletePlatformById(1)).thenReturn(2); - Integer result = platformServiceImpl.deletePlatformById(1); - Assertions.assertEquals(2, result); + Result result = platformServiceImpl.deletePlatformById(1); + Assertions.assertEquals(mockData, result.getData()); } @Test void testUpdatePlatformById() { Platform param = new Platform(); when(platformMapper.updatePlatformById(param)).thenReturn(1); - - Integer result = platformServiceImpl.updatePlatformById(param); - Assertions.assertEquals(1, result); + Platform mockData = new Platform(); + when(platformMapper.queryPlatformById(1)).thenReturn(mockData); + Result result = platformServiceImpl.updatePlatformById(param); + Assertions.assertEquals(mockData, result.getData()); } @Test @@ -93,7 +97,7 @@ void testCreatePlatform() { Platform param = new Platform(); when(platformMapper.createPlatform(param)).thenReturn(1); - Integer result = platformServiceImpl.createPlatform(param); - Assertions.assertEquals(1, result); + Result result = platformServiceImpl.createPlatform(param); + Assertions.assertEquals(param, result.getData()); } } \ No newline at end of file From 4ac65e233b3ad123b38a363e3f7c552417a74aff Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Fri, 9 May 2025 02:55:09 -0700 Subject: [PATCH 59/72] feat: platform API --- .../sql/h2/create_all_tables_ddl_v1.h2.sql | 4 +- .../sql/h2/update_all_tables_ddl.sql | 7 +- .../mysql/create_all_tables_ddl_v1.mysql.sql | 6 +- .../sql/mysql/update_all_tables_ddl.sql | 7 +- .../it/controller/PlatformController.java | 162 ++++++++++++ .../controller/PlatformHistoryController.java | 162 ++++++++++++ .../it/mapper/PlatformHistoryMapper.java | 75 ++++++ .../tinyengine/it/model/entity/Platform.java | 2 + .../it/model/entity/PlatformHistory.java | 64 +++++ .../platform/PlatformHistoryService.java | 73 ++++++ .../it/service/platform/PlatformService.java | 13 +- .../impl/PlatformHistorySrviceImpl.java | 118 +++++++++ .../platform/impl/PlatformServiceImpl.java | 37 ++- .../mappers/PlatformHistoryMapper.xml | 239 ++++++++++++++++++ .../impl/PlatformServiceImplTest.java | 18 +- 15 files changed, 958 insertions(+), 29 deletions(-) create mode 100644 base/src/main/java/com/tinyengine/it/controller/PlatformController.java create mode 100644 base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java create mode 100644 base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java create mode 100644 base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java create mode 100644 base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java create mode 100644 base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java create mode 100644 base/src/main/resources/mappers/PlatformHistoryMapper.xml diff --git a/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql b/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql index dbd8f3aa..07ce9bd1 100644 --- a/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql +++ b/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql @@ -41,11 +41,11 @@ create table `t_platform_history` `ref_id` int not null comment '关联主表id', `version` varchar(255) not null comment '版本', `name` varchar(255) not null comment '名称', - `publish_url` varchar(255) not null comment '设计器静态资源托管地址', + `publish_url` varchar(255) comment '设计器静态资源托管地址', `description` varchar(2000) comment '描述', `vscode_url` varchar(255) comment '设计预留字段', `material_history_id` int not null comment '关联物料包历史id', - `sub_count` int not null comment '设计预留字段', + `sub_count` int comment '设计预留字段', `material_pkg_name` varchar(255) comment '物料包名称', `material_version` varchar(255) comment '物料包版本', `image_url` varchar(255) comment '封面图地址', diff --git a/app/src/main/resources/sql/h2/update_all_tables_ddl.sql b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql index d6f9c5d1..4c5c7a09 100644 --- a/app/src/main/resources/sql/h2/update_all_tables_ddl.sql +++ b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql @@ -1,2 +1,7 @@ ALTER TABLE t_component DROP INDEX u_idx_component; -ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); \ No newline at end of file +ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); + +ALTER TABLE t_datasource DROP INDEX u_idx_datasource; +ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`); + +ALTER TABLE t_platform_history MODIFY sub_count int NULL; \ No newline at end of file diff --git a/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql b/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql index a4cfa649..bccbab33 100644 --- a/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql +++ b/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql @@ -41,11 +41,11 @@ create table `t_platform_history` `ref_id` int not null comment '关联主表id', `version` varchar(255) not null comment '版本', `name` varchar(255) not null comment '名称', - `publish_url` varchar(255) not null comment '设计器静态资源托管地址', + `publish_url` varchar(255) comment '设计器静态资源托管地址', `description` varchar(2000) comment '描述', - `vscode_url` varchar(255) comment '设计预留字段', + `vscode_url` varchar(255) comment '设计预留字段', `material_history_id` int not null comment '关联物料包历史id', - `sub_count` int not null comment '设计预留字段', + `sub_count` int comment '设计预留字段', `material_pkg_name` varchar(255) comment '物料包名称', `material_version` varchar(255) comment '物料包版本', `image_url` varchar(255) comment '封面图地址', diff --git a/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql index d6f9c5d1..4c5c7a09 100644 --- a/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql +++ b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql @@ -1,2 +1,7 @@ ALTER TABLE t_component DROP INDEX u_idx_component; -ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); \ No newline at end of file +ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, library_id); + +ALTER TABLE t_datasource DROP INDEX u_idx_datasource; +ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`); + +ALTER TABLE t_platform_history MODIFY sub_count int NULL; \ No newline at end of file diff --git a/base/src/main/java/com/tinyengine/it/controller/PlatformController.java b/base/src/main/java/com/tinyengine/it/controller/PlatformController.java new file mode 100644 index 00000000..6f9b1185 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/controller/PlatformController.java @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.controller; + +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.log.SystemControllerLog; +import com.tinyengine.it.model.entity.Platform; +import com.tinyengine.it.service.platform.PlatformService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * 设计器api + * + * @since 2024-10-20 + */ +@Validated +@RestController +@RequestMapping("/platform-center/api") +@Tag(name = "设计器") +public class PlatformController { + /** + * The Platform service. + */ + @Autowired + private PlatformService platformService; + + /** + * 查询表Platform信息 + * + * @return Platform信息 all app + */ + @Operation(summary = "查询表Platform信息", + description = "查询表Platform信息", + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "查询表Platform信息") + @GetMapping("/platform/list") + public Result> getAllPlatform() { + List appList = platformService.queryAllPlatform(); + return Result.success(appList); + } + + /** + * 根据id查询表Platform信息 + * + * @param id the id + * @return Platform信息 app by id + */ + @Operation(summary = "根据id查询表Platform信息", + description = "根据id查询表Platform信息", + parameters = { + @Parameter(name = "id", description = "Platform主键id") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "根据id查询表Platform信息") + @GetMapping("/platform/{id}") + public Result getPlatformById(@PathVariable Integer id) { + Platform platform = platformService.queryPlatformById(id); + return Result.success(platform); + } + + /** + * 创建Platform + * + * @param platform the platform + * @return Platform信息 result + */ + @Operation(summary = "创建platform", + description = "创建platform", + parameters = { + @Parameter(name = "platform", description = "Platform入参对象") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "创建platform") + @PostMapping("/platform/create") + public Result createPlatform(@Valid @RequestBody Platform platform) { + return platformService.createPlatform(platform); + } + + /** + * 修改Platform信息 + * + * @param id the id + * @param platform the platform + * @return Platform信息 result + */ + @Operation(summary = "修改单个Platform信息", description = "修改单个Platform信息", parameters = { + @Parameter(name = "id", description = "appId"), + @Parameter(name = "Platform", description = "入参对象")}, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "修改单个Platform信息") + @PostMapping("/platform/update/{id}") + public Result updatePlatform(@PathVariable Integer id, @RequestBody Platform platform) { + platform.setId(id); + return platformService.updatePlatformById(platform); + } + + /** + * 删除Platform信息 + * + * @param id the id + * @return platform信息 result + */ + @Operation(summary = "删除platform信息", + description = "删除platform信息", + parameters = { + @Parameter(name = "id", description = "Platform主键id") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "删除platform信息") + @GetMapping("/platform/delete/{id}") + public Result deletePlatform(@PathVariable Integer id) { + return platformService.deletePlatformById(id); + } +} diff --git a/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java new file mode 100644 index 00000000..7f8f7ff4 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.controller; + +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.log.SystemControllerLog; +import com.tinyengine.it.model.entity.PlatformHistory; +import com.tinyengine.it.service.platform.PlatformHistoryService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * 设计器api + * + * @since 2024-10-20 + */ +@Validated +@RestController +@RequestMapping("/platform-center/api") +@Tag(name = "设计器历史") +public class PlatformHistoryController { + /** + * The PlatformHistory service. + */ + @Autowired + private PlatformHistoryService platformHistoryService; + + /** + * 查询表PlatformHistory信息 + * + * @return PlatformHistory信息 all app + */ + @Operation(summary = "查询表PlatformHistory信息", + description = "查询表PlatformHistory信息", + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "查询表PlatformHistory信息") + @GetMapping("/platform-history/list") + public Result> getAllPlatformHistory() { + List appList = platformHistoryService.queryAllPlatformHistory(); + return Result.success(appList); + } + + /** + * 根据id查询表PlatformHistory信息 + * + * @param id the id + * @return PlatformHistory信息 app by id + */ + @Operation(summary = "根据id查询表PlatformHistory信息", + description = "根据id查询表PlatformHistory信息", + parameters = { + @Parameter(name = "id", description = "PlatformHistory主键id") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "根据id查询表PlatformHistory信息") + @GetMapping("/platform-history/{id}") + public Result getPlatformHistoryById(@PathVariable Integer id) { + PlatformHistory platformHistory = platformHistoryService.queryPlatformHistoryById(id); + return Result.success(platformHistory); + } + + /** + * 创建PlatformHistory + * + * @param platformHistory the platformHistory + * @return PlatformHistory信息 result + */ + @Operation(summary = "创建platformHistory", + description = "创建platformHistory", + parameters = { + @Parameter(name = "platformHistory", description = "PlatformHistory入参对象") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "创建platformHistory") + @PostMapping("/platform-history/create") + public Result createPlatformHistory(@Valid @RequestBody PlatformHistory platformHistory) { + return platformHistoryService.createPlatformHistory(platformHistory); + } + + /** + * 修改PlatformHistory信息 + * + * @param id the id + * @param platformHistory the platformHistory + * @return PlatformHistory信息 result + */ + @Operation(summary = "修改单个PlatformHistory信息", description = "修改单个PlatformHistory信息", parameters = { + @Parameter(name = "id", description = "appId"), + @Parameter(name = "PlatformHistory", description = "入参对象")}, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")}) + @SystemControllerLog(description = "修改单个PlatformHistory信息") + @PostMapping("/platform-history/update/{id}") + public Result updatePlatformHistory(@PathVariable Integer id, @RequestBody PlatformHistory platformHistory) { + platformHistory.setId(id); + return platformHistoryService.updatePlatformHistoryById(platformHistory); + } + + /** + * 删除PlatformHistory信息 + * + * @param id the id + * @return platformHistory信息 result + */ + @Operation(summary = "删除platformHistory信息", + description = "删除platformHistory信息", + parameters = { + @Parameter(name = "id", description = "PlatformHistory主键id") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "删除platformHistory信息") + @GetMapping("/platform-history/delete/{id}") + public Result deletePlatformHistory(@PathVariable Integer id) { + return platformHistoryService.deletePlatformHistoryById(id); + } +} diff --git a/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java b/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java new file mode 100644 index 00000000..837d95e7 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.tinyengine.it.model.entity.Platform; + +import com.tinyengine.it.model.entity.PlatformHistory; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * The interface Platform history mapper. + * + * @since 2025-05-09 + */ +public interface PlatformHistoryMapper extends BaseMapper { + /** + * 查询表t_platform_history所有信息 + * + * @return the list + */ + List queryAllPlatformHistory(); + + /** + * 根据主键id查询表t_platform_history数据 + * + * @param id the id + * @return the platform + */ + PlatformHistory queryPlatformHistoryById(Integer id); + + /** + * 根据条件查询表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the list + */ + List queryPlatformHistoryByCondition(PlatformHistory platformHistory); + + /** + * 根据主键id删除表t_platform_history数据 + * + * @param id the id + * @return the integer + */ + Integer deletePlatformHistoryById(@Param("id") Integer id); + + /** + * 根据主键id更新表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the integer + */ + Integer updatePlatformHistoryById(PlatformHistory platformHistory); + + /** + * 新增表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the integer + */ + Integer createPlatformHistory(PlatformHistory platformHistory); +} diff --git a/base/src/main/java/com/tinyengine/it/model/entity/Platform.java b/base/src/main/java/com/tinyengine/it/model/entity/Platform.java index 39444d0d..acae4205 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/Platform.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/Platform.java @@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonProperty; import com.tinyengine.it.common.base.BaseEntity; import com.tinyengine.it.common.handler.ListTypeHandler; import com.tinyengine.it.common.handler.MapTypeHandler; @@ -42,6 +43,7 @@ public class Platform extends BaseEntity { private String name; @Schema(name = "published", description = "是否发布:1是,0否") + @JsonProperty("published") private Boolean isPublish; @Schema(name = "lastBuildInfo", description = "最后构建信息") diff --git a/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java b/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java new file mode 100644 index 00000000..1bfeab23 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.model.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.tinyengine.it.common.base.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; + +/** + * + * 设计器历史表 + * + * @since 2025-05-09 + */ +@Getter +@Setter +@TableName("t_platform_history") +@Schema(name = "PlatformHistory", description = "设计器历史表") +public class PlatformHistory extends BaseEntity { + @Schema(name = "refId", description = "设计器id") + private Integer refId; + + @Schema(name = "name", description = "名称") + private String name; + + @Schema(name = "publishUrl", description = "设计器静态资源托管地址") + private String publishUrl; + + @Schema(name = "description", description = "描述") + private String description; + + @Schema(name = "version", description = "当前历史记录表版本") + private String version; + + @Schema(name = "subCount", description = "设计预留字段") + private Integer subCount; + + @Schema(name = "materialHistoryId", description = "关联物料包历史ID") + private Integer materialHistoryId; + + @Schema(name = "imageUrl", description = "设计器截图地址") + private String imageUrl; + + @Schema(name = "materialPkgName", description = "物料包名称") + private String materialPkgName; + + @Schema(name = "materialVersion", description = "物料包版本") + private String materialVersion; + + @Schema(name = "vscodeUrl", description = "*设计预留字段*") + private String vscodeUrl; +} diff --git a/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java b/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java new file mode 100644 index 00000000..de5cc061 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.service.platform; + +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.model.entity.PlatformHistory; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * The interface platform history service. + * + * @since 2025-05-09 + */ +public interface PlatformHistoryService { + /** + * 查询表t_platform_history所有信息 + * + * @return the list + */ + List queryAllPlatformHistory(); + + /** + * 根据主键id查询表t_platform_history信息 + * + * @param id the id + * @return the platformHistory + */ + PlatformHistory queryPlatformHistoryById(@Param("id") Integer id); + + /** + * 根据条件查询表t_platform_history信息 + * + * @param platformHistory the platformHistory + * @return the list + */ + List queryPlatformHistoryByCondition(PlatformHistory platformHistory); + + /** + * 根据主键id删除t_platform_history数据 + * + * @param id the id + * @return the Result + */ + Result deletePlatformHistoryById(@Param("id") Integer id); + + /** + * 根据主键id更新表t_platform_history信息 + * + * @param platformHistory the platformHistory + * @return the Result + */ + Result updatePlatformHistoryById(PlatformHistory platformHistory); + + /** + * 新增表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the Result + */ + Result createPlatformHistory(PlatformHistory platformHistory); +} diff --git a/base/src/main/java/com/tinyengine/it/service/platform/PlatformService.java b/base/src/main/java/com/tinyengine/it/service/platform/PlatformService.java index 8163d7ff..552b9e7a 100644 --- a/base/src/main/java/com/tinyengine/it/service/platform/PlatformService.java +++ b/base/src/main/java/com/tinyengine/it/service/platform/PlatformService.java @@ -12,6 +12,7 @@ package com.tinyengine.it.service.platform; +import com.tinyengine.it.common.base.Result; import com.tinyengine.it.model.entity.Platform; import org.apache.ibatis.annotations.Param; @@ -51,23 +52,23 @@ public interface PlatformService { * 根据主键id删除t_platform数据 * * @param id the id - * @return the integer + * @return the Result */ - Integer deletePlatformById(@Param("id") Integer id); + Result deletePlatformById(@Param("id") Integer id); /** * 根据主键id更新表t_platform信息 * * @param platform the platform - * @return the integer + * @return the Result */ - Integer updatePlatformById(Platform platform); + Result updatePlatformById(Platform platform); /** * 新增表t_platform数据 * * @param platform the platform - * @return the integer + * @return the Result */ - Integer createPlatform(Platform platform); + Result createPlatform(Platform platform); } diff --git a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java new file mode 100644 index 00000000..3f869523 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.service.platform.impl; + +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.exception.ExceptionEnum; +import com.tinyengine.it.mapper.PlatformHistoryMapper; +import com.tinyengine.it.model.entity.PlatformHistory; +import com.tinyengine.it.service.platform.PlatformHistoryService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * The interface platform history service. + * + * @since 2025-05-09 + */ +@Service +@Slf4j +public class PlatformHistorySrviceImpl implements PlatformHistoryService { + @Autowired + private PlatformHistoryMapper platformHistoryMapper; + + /** + * 查询表t_platform_history所有信息 + * + * @return the list + */ + @Override + public List queryAllPlatformHistory() { + return platformHistoryMapper.queryAllPlatformHistory(); + } + + /** + * 根据主键id查询表t_platform_history信息 + * + * @param id the id + * @return the platformHistory + */ + @Override + public PlatformHistory queryPlatformHistoryById(Integer id) { + return platformHistoryMapper.queryPlatformHistoryById(id); + } + + /** + * 根据条件查询表t_platform_history信息 + * + * @param platformHistory the platformHistory + * @return the list + */ + @Override + public List queryPlatformHistoryByCondition(PlatformHistory platformHistory) { + return platformHistoryMapper.queryPlatformHistoryByCondition(platformHistory); + } + + /** + * 根据主键id删除t_platform_history数据 + * + * @param id the id + * @return the Result + */ + @Override + public Result deletePlatformHistoryById(Integer id) { + PlatformHistory platformHistory = this.queryPlatformHistoryById(id); + if (platformHistory == null || platformHistory.getId() == null) { + return Result.success(); + } + int deleteResult = platformHistoryMapper.deletePlatformHistoryById(id); + if (deleteResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + return Result.success(platformHistory); + } + + /** + * 根据主键id更新表t_platform_history信息 + * + * @param platformHistory the platformHistory + * @return the Result + */ + @Override + public Result updatePlatformHistoryById(PlatformHistory platformHistory) { + int updateResult = platformHistoryMapper.updatePlatformHistoryById(platformHistory); + if (updateResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + PlatformHistory platformHistoryResult = this.queryPlatformHistoryById(platformHistory.getId()); + return Result.success(platformHistoryResult); + } + + /** + * 新增表t_platform_history数据 + * + * @param platformHistory the platformHistory + * @return the Result + */ + @Override + public Result createPlatformHistory(PlatformHistory platformHistory) { + int createResult = platformHistoryMapper.createPlatformHistory(platformHistory); + if (createResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + return Result.success(platformHistory); + } +} diff --git a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java index ee4d37d4..b9d06600 100644 --- a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java @@ -12,6 +12,8 @@ package com.tinyengine.it.service.platform.impl; +import com.tinyengine.it.common.base.Result; +import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.mapper.PlatformMapper; import com.tinyengine.it.model.entity.Platform; import com.tinyengine.it.service.platform.PlatformService; @@ -71,32 +73,49 @@ public List queryPlatformByCondition(Platform platform) { * 根据主键id删除表t_platform数据 * * @param id id - * @return execute success data number + * @return Result */ @Override - public Integer deletePlatformById(@Param("id") Integer id) { - return platformMapper.deletePlatformById(id); + public Result deletePlatformById(@Param("id") Integer id) { + Platform platform = this.queryPlatformById(id); + if (platform == null || platform.getId() == null) { + return Result.success(); + } + int deleteResult = platformMapper.deletePlatformById(id); + if (deleteResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + return Result.success(platform); } /** * 根据主键id更新表t_platform数据 * * @param platform platform - * @return execute success data number + * @return Result */ @Override - public Integer updatePlatformById(Platform platform) { - return platformMapper.updatePlatformById(platform); + public Result updatePlatformById(Platform platform) { + int updateResult = platformMapper.updatePlatformById(platform); + if (updateResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + Platform platformResult = platformMapper.queryPlatformById(platform.getId()); + return Result.success(platformResult); } /** * 新增表t_platform数据 * * @param platform platform - * @return execute success data number + * @return Result */ @Override - public Integer createPlatform(Platform platform) { - return platformMapper.createPlatform(platform); + public Result createPlatform(Platform platform) { + int createResult = platformMapper.createPlatform(platform); + if (createResult != 1) { + return Result.failed(ExceptionEnum.CM008); + } + return Result.success(platform); } } diff --git a/base/src/main/resources/mappers/PlatformHistoryMapper.xml b/base/src/main/resources/mappers/PlatformHistoryMapper.xml new file mode 100644 index 00000000..52c7871f --- /dev/null +++ b/base/src/main/resources/mappers/PlatformHistoryMapper.xml @@ -0,0 +1,239 @@ + + + + + + + + + id, ref_id, name, version, publish_url, vscode_url, description, material_history_id, sub_count, material_pkg_name, + material_version, image_url, tenant_id, renter_id, site_id, created_by, last_updated_by, + created_time, last_updated_time + + + + + + AND ref_id = #{refId} + + + AND name = #{name} + + + AND publish_url = #{publishUrl} + + + AND version = #{version} + + + AND description = #{description} + + + AND vscode_url = #{vscodeUrl} + + + AND material_history_id = #{materialHistoryId} + + + AND image_url = #{imageUrl} + + + AND sub_count = #{subCount} + + + AND material_pkg_name = #{materialPkgName} + + + AND material_version = #{materialVersion} + + + AND tenant_id = #{tenantId} + + + AND renter_id = #{renterId} + + + AND site_id = #{siteId} + + + AND created_by = #{createdBy} + + + AND last_updated_by = #{lastUpdatedBy} + + + AND created_time = #{createdTime} + + + AND last_updated_time = #{lastUpdatedTime} + + + + + + + ref_id = #{refId}, + + + name = #{name}, + + + publish_url = #{publishUrl}, + + + version = #{version}, + + + description = #{description}, + + + vscode_url = #{vscodeUrl}, + + + material_history_id = #{materialHistoryId}, + + + image_url = #{imageUrl}, + + + sub_count = #{subCount}, + + + material_pkg_name = #{materialPkgName}, + + + material_version = #{materialVersion}, + + + tenant_id = #{tenantId}, + + + renter_id = #{renterId}, + + + site_id = #{siteId}, + + + created_by = #{createdBy}, + + + last_updated_by = #{lastUpdatedBy}, + + + created_time = #{createdTime}, + + + last_updated_time = #{lastUpdatedTime}, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE + FROM t_platform_history + WHERE id = #{id} + + + + + UPDATE t_platform_history + + + + WHERE + id=#{id} + + + + + INSERT INTO t_platform_history ( id + , ref_id + , name + , version + , publish_url + , description + , sub_count + , material_history_id + , image_url + , material_pkg_name + , material_version + , vscode_url + , tenant_id + , renter_id + , site_id + , created_by + , last_updated_by + , created_time + , last_updated_time) + VALUES ( #{id} + , #{refId} + , #{name} + , #{version} + , #{publishUrl} + , #{description} + , #{subCount} + , #{materialHistoryId} + , #{imageUrl} + , #{materialPkgName} + , #{materialVersion} + , #{vscodeUrl} + , #{tenantId} + , #{renterId} + , #{siteId} + , #{createdBy} + , #{lastUpdatedBy} + , #{createdTime} + , #{lastUpdatedTime}) + + diff --git a/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java index 86990dee..cfbc00e2 100644 --- a/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java @@ -14,6 +14,7 @@ import static org.mockito.Mockito.when; +import com.tinyengine.it.common.base.Result; import com.tinyengine.it.mapper.PlatformMapper; import com.tinyengine.it.model.entity.Platform; @@ -73,19 +74,22 @@ void testQueryPlatformByCondition() { @Test void testDeletePlatformById() { + Platform mockData = new Platform(); + when(platformMapper.queryPlatformById(1)).thenReturn(mockData); when(platformMapper.deletePlatformById(1)).thenReturn(2); - Integer result = platformServiceImpl.deletePlatformById(1); - Assertions.assertEquals(2, result); + Result result = platformServiceImpl.deletePlatformById(1); + Assertions.assertEquals(mockData, result.getData()); } @Test void testUpdatePlatformById() { Platform param = new Platform(); when(platformMapper.updatePlatformById(param)).thenReturn(1); - - Integer result = platformServiceImpl.updatePlatformById(param); - Assertions.assertEquals(1, result); + Platform mockData = new Platform(); + when(platformMapper.queryPlatformById(1)).thenReturn(mockData); + Result result = platformServiceImpl.updatePlatformById(param); + Assertions.assertEquals(mockData, result.getData()); } @Test @@ -93,7 +97,7 @@ void testCreatePlatform() { Platform param = new Platform(); when(platformMapper.createPlatform(param)).thenReturn(1); - Integer result = platformServiceImpl.createPlatform(param); - Assertions.assertEquals(1, result); + Result result = platformServiceImpl.createPlatform(param); + Assertions.assertEquals(param, result.getData()); } } \ No newline at end of file From 7f875cee03124475d63c50f33ffec9bea039a4ef Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Mon, 12 May 2025 19:27:37 -0700 Subject: [PATCH 60/72] feat: platform API --- app/src/main/resources/sql/h2/update_all_tables_ddl.sql | 3 ++- app/src/main/resources/sql/mysql/update_all_tables_ddl.sql | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/resources/sql/h2/update_all_tables_ddl.sql b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql index 4c5c7a09..1e59d2a8 100644 --- a/app/src/main/resources/sql/h2/update_all_tables_ddl.sql +++ b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql @@ -4,4 +4,5 @@ ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, ALTER TABLE t_datasource DROP INDEX u_idx_datasource; ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`); -ALTER TABLE t_platform_history MODIFY sub_count int NULL; \ No newline at end of file +ALTER TABLE t_platform_history MODIFY sub_count int NULL; +ALTER TABLE t_platform_history MODIFY publish_url varchar(255) NULL; \ No newline at end of file diff --git a/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql index 4c5c7a09..1e59d2a8 100644 --- a/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql +++ b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql @@ -4,4 +4,5 @@ ALTER TABLE t_component ADD INDEX u_idx_component (tenant_id, name_en, version, ALTER TABLE t_datasource DROP INDEX u_idx_datasource; ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`); -ALTER TABLE t_platform_history MODIFY sub_count int NULL; \ No newline at end of file +ALTER TABLE t_platform_history MODIFY sub_count int NULL; +ALTER TABLE t_platform_history MODIFY publish_url varchar(255) NULL; \ No newline at end of file From 091ed5e4b962feaa614aba2a9da3eab5d9660889 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 13 May 2025 01:38:39 -0700 Subject: [PATCH 61/72] feat: Add inspection file --- .../it/common/exception/ExceptionEnum.java | 17 +- .../common/utils/SecurityFileCheckUtil.java | 178 ++++++++++++++++++ .../material/impl/ComponentServiceImpl.java | 21 ++- .../service/app/impl/PageServiceImplTest.java | 3 +- .../impl/ComponentServiceImplTest.java | 2 + .../impl/PlatformServiceImplTest.java | 4 +- 6 files changed, 219 insertions(+), 6 deletions(-) create mode 100644 base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java diff --git a/base/src/main/java/com/tinyengine/it/common/exception/ExceptionEnum.java b/base/src/main/java/com/tinyengine/it/common/exception/ExceptionEnum.java index 12a791a4..3e604e12 100644 --- a/base/src/main/java/com/tinyengine/it/common/exception/ExceptionEnum.java +++ b/base/src/main/java/com/tinyengine/it/common/exception/ExceptionEnum.java @@ -235,7 +235,22 @@ public enum ExceptionEnum implements IBaseError { /** * Cm 322 exception enum. */ - CM322("CM322", "调用接口失败"); + CM322("CM322", "调用接口失败"), + + /** + * Cm 323 exception enum. + */ + CM323("CM323", "文件名长度范围为1-100,以数字或字母开头"), + + /** + * Cm 324 exception enum. + */ + CM324("CM324","文件名或路径无效"), + + /** + * Cm 325 exception enum. + */ + CM325("CM325","文件校验失败"); /** * 错误码 diff --git a/base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java b/base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java new file mode 100644 index 00000000..444cb188 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java @@ -0,0 +1,178 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + */ + +package com.tinyengine.it.common.utils; + +import cn.hutool.core.util.ObjectUtil; +import com.tinyengine.it.common.exception.ExceptionEnum; +import com.tinyengine.it.common.exception.ServiceException; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.util.Map; +import java.util.Objects; +import java.util.regex.Pattern; + +/** + * The file check Utils. + * + * @since 2025-05-13 + */ +public class SecurityFileCheckUtil { + + private static final String REGX_FILE_NAME = "^[a-z0-9A-Z][^\\\\/:*<>|]+$"; + private static final Pattern PATTERN_FILE_NAME = Pattern.compile(REGX_FILE_NAME); + + /** + * Determine whether the file has cross path connections. + * + * @param dirOrFileName the dirOrFileName + * @return true or false + */ + public static boolean checkPathHasCrossDir(String dirOrFileName) { + if (!dirOrFileName.contains("../") && !dirOrFileName.contains("/..")) { + if (!dirOrFileName.contains("..\\") && !dirOrFileName.contains("\\..")) { + return dirOrFileName.contains("./") || dirOrFileName.contains(".\\.\\") || dirOrFileName.contains("%00"); + } else { + return true; + } + } else { + return true; + } + } + + /** + * Type of inspection document. + * + * @param file the file + * @param fileTypeMap the fileTypeMap + * @return true or false + */ + public static boolean checkFileType(MultipartFile file, Map fileTypeMap) { + if (Objects.isNull(file) || fileTypeMap.isEmpty()) { + throw new ServiceException(ExceptionEnum.CM307.getResultCode(), ExceptionEnum.CM307.getResultMsg()); + } + String originalFileName = file.getOriginalFilename(); + for (Map.Entry entry : fileTypeMap.entrySet()) { + if (originalFileName.endsWith(entry.getKey())) { + return checkFileType(file, entry.getKey(), entry.getValue()); + } + } + return false; + } + + /** + * Type of inspection document. + * + * @param file the file + * @param fileNameEnd the fileNameEnd + * @param fileType the fileType + * @return true or false + */ + public static boolean checkFileType(MultipartFile file, String fileNameEnd, String fileType) { + String originalFileName = file.getOriginalFilename(); + String contentType = file.getContentType(); + if (ObjectUtil.isEmpty(originalFileName) || ObjectUtil.isEmpty(contentType)) { + return false; + } + if (!originalFileName.endsWith(fileNameEnd)) { + return false; + } + if (!contentType.equalsIgnoreCase(fileType)) { + return false; + } + return true; + } + + /** + * Inspection file name. + * + * @param fileName the fileName + */ + public static void validFileName(String fileName) { + if (!StringUtils.hasText(fileName)) { + throw new ServiceException(ExceptionEnum.CM320.getResultCode(), ExceptionEnum.CM320.getResultMsg()); + } + if (!checkFileNameLength(fileName, 1, 100)) { + throw new ServiceException(ExceptionEnum.CM323.getResultCode(), ExceptionEnum.CM323.getResultMsg()); + } + if (!filePathIsValid(fileName)) { + throw new ServiceException(ExceptionEnum.CM324.getResultCode(), ExceptionEnum.CM324.getResultMsg()); + } + String fullFileName = getFileName(fileName); + if (!PATTERN_FILE_NAME.matcher(fullFileName).matches()) { + throw new ServiceException(ExceptionEnum.CM324.getResultCode(), ExceptionEnum.CM324.getResultMsg()); + } + } + + /** + * Check if the file name length is within the specified range. + * + * @param fileName the fileName + * @param min the min + * @param max the max + * @return true or false + */ + public static boolean checkFileNameLength(String fileName, int min, int max) { + if (!StringUtils.hasText(fileName)) { + return min <= 0; + } + String temp = fileName.replaceAll("[^\\x00-\\xff]", "**"); + return temp.length() <= max; + } + + /** + * Verify file path. + * + * @param fileName the fileName + * @return true or false + */ + public static boolean filePathIsValid(String fileName) { + if (fileName == null || fileName.trim().isEmpty()) { + return false; + } + + // 获取当前操作系统的名称 + String os = System.getProperty("os.name").toLowerCase(); + + // 定义通用的非法字符 + String illegalChars = ""; + + if (os.contains("win")) { + // 针对Windows的非法字符 + illegalChars = "[<>:\"/\\|?*]"; + } else if (os.contains("nix") || os.contains("nux") || os.contains("mac")) { + // 针对Linux和macOS的非法字符(一般来说,Linux和macOS对文件名的限制较少,但有一些常见的非法字符) + illegalChars = "[/]"; // Linux和macOS的路径不能包含斜杠 '/' + } + // 检查路径中是否包含非法字符 + if (fileName.matches(".*" + illegalChars + ".*")) { + return false; + } + // 检查路径是否超过文件系统允许的最大长度(例如,Windows上的路径限制通常为260个字符) + if (fileName.length() > 260) { + return false; + } + + // 检查路径中是否包含空格或其他特殊字符,视需要进行定制 + // 如果需要你也可以根据不同操作系统做不同的检查 + + return true; + } + + private static String getFileName(String filePath) { + File file = new File(filePath); + return file.getName(); + } + + +} diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java index 4e6680f1..d5778722 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java @@ -15,6 +15,7 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.common.log.SystemServiceLog; +import com.tinyengine.it.common.utils.SecurityFileCheckUtil; import com.tinyengine.it.common.utils.Utils; import com.tinyengine.it.mapper.ComponentLibraryMapper; import com.tinyengine.it.mapper.ComponentMapper; @@ -180,6 +181,10 @@ public Result readFileAndBulkCreate(MultipartFile file) { @Override @SystemServiceLog(description = "bundleSplit 拆分bundle.json实现方法") public Result bundleSplit(MultipartFile file) { + boolean isFileCheck = this.checkFile(file); + if (!isFileCheck){ + return Result.failed(ExceptionEnum.CM325); + } // 获取bundle.json数据 Result result = Utils.parseJsonFileStream(file); if (!result.isSuccess()) { @@ -317,10 +322,10 @@ public Result bulkCreate(List componentList) { List queryComponent = findComponentByCondition(componentParam); // 查询组件库id String packageName = null; - if(null!= component.getNpm() && null != component.getNpm().get("package")){ + if (null != component.getNpm() && null != component.getNpm().get("package")) { packageName = String.valueOf(component.getNpm().get("package")); } - if(null != packageName && !packageName.isEmpty()){ + if (null != packageName && !packageName.isEmpty()) { ComponentLibrary componentLibrary = new ComponentLibrary(); componentLibrary.setPackageName(String.valueOf(component.getNpm().get("package"))); componentLibrary.setVersion(component.getVersion()); @@ -379,4 +384,16 @@ private String toPascalCase(String input) { } return result.toString(); } + + public boolean checkFile(MultipartFile file) { + SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); + + Map fileTypeMap = new HashMap<>(); + fileTypeMap.put(".json", "application/json"); + boolean isCheckFileType = SecurityFileCheckUtil.checkFileType(file, fileTypeMap); + if (!isCheckFileType) { + return false; + } + return true; + } } diff --git a/base/src/test/java/com/tinyengine/it/service/app/impl/PageServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/app/impl/PageServiceImplTest.java index bc496654..286c60df 100644 --- a/base/src/test/java/com/tinyengine/it/service/app/impl/PageServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/app/impl/PageServiceImplTest.java @@ -278,8 +278,7 @@ void testGetDepth() { when(pageMapper.queryPageById(1)).thenReturn(page); Result result = pageServiceImpl.getDepth("1"); - Assertions.assertFalse(result.isSuccess()); - assertEquals("Exceeded depth", result.getMessage()); + assertEquals(page.getDepth(), result.getData()); } @Test diff --git a/base/src/test/java/com/tinyengine/it/service/material/impl/ComponentServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/material/impl/ComponentServiceImplTest.java index 1834486d..40954e5e 100644 --- a/base/src/test/java/com/tinyengine/it/service/material/impl/ComponentServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/material/impl/ComponentServiceImplTest.java @@ -134,6 +134,8 @@ void testReadFileAndBulkCreate() { componentLibraryList.add(componentLibrary); when(componentLibraryMapper.queryComponentLibraryByCondition(componentLibrary)).thenReturn(componentLibraryList); MultipartFile file = mock(MultipartFile.class); + when(file.getOriginalFilename()).thenReturn("example.json"); + when(file.getContentType()).thenReturn("application/json"); HashMap fileContent = new HashMap<>(); BundleMaterial bundleMaterial = new BundleMaterial(); ArrayList> components = new ArrayList<>(); diff --git a/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java index cfbc00e2..19b7ae65 100644 --- a/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java @@ -75,8 +75,9 @@ void testQueryPlatformByCondition() { @Test void testDeletePlatformById() { Platform mockData = new Platform(); + mockData.setId(1); when(platformMapper.queryPlatformById(1)).thenReturn(mockData); - when(platformMapper.deletePlatformById(1)).thenReturn(2); + when(platformMapper.deletePlatformById(1)).thenReturn(1); Result result = platformServiceImpl.deletePlatformById(1); Assertions.assertEquals(mockData, result.getData()); @@ -85,6 +86,7 @@ void testDeletePlatformById() { @Test void testUpdatePlatformById() { Platform param = new Platform(); + param.setId(1); when(platformMapper.updatePlatformById(param)).thenReturn(1); Platform mockData = new Platform(); when(platformMapper.queryPlatformById(1)).thenReturn(mockData); From 3438b968451e395c84d59384efa14cf11ace9320 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 13 May 2025 02:24:10 -0700 Subject: [PATCH 62/72] feat: Add inspection file --- .../it/controller/PlatformController.java | 20 ++++++++++++++++++- .../controller/PlatformHistoryController.java | 3 ++- .../material/impl/ComponentServiceImpl.java | 7 +++++-- ...l.java => PlatformHistoryServiceImpl.java} | 20 ++++++++++++++++++- .../platform/impl/PlatformServiceImpl.java | 9 +++++++++ .../mappers/PlatformHistoryMapper.xml | 2 +- .../impl/PlatformServiceImplTest.java | 1 + 7 files changed, 56 insertions(+), 6 deletions(-) rename base/src/main/java/com/tinyengine/it/service/platform/impl/{PlatformHistorySrviceImpl.java => PlatformHistoryServiceImpl.java} (78%) diff --git a/base/src/main/java/com/tinyengine/it/controller/PlatformController.java b/base/src/main/java/com/tinyengine/it/controller/PlatformController.java index 6f9b1185..4fe4dd6d 100644 --- a/base/src/main/java/com/tinyengine/it/controller/PlatformController.java +++ b/base/src/main/java/com/tinyengine/it/controller/PlatformController.java @@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -143,6 +144,23 @@ public Result updatePlatform(@PathVariable Integer id, @RequestBody Pl * @param id the id * @return platform信息 result */ + @Operation(summary = "删除platform信息,与js同路由", + description = "删除platform信息,与js同路由", + parameters = { + @Parameter(name = "id", description = "Platform主键id") + }, + responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} + ) + @SystemControllerLog(description = "删除platform信息,与js同路由") + @GetMapping("/platform/delete/{id}") + public Result delete(@PathVariable Integer id) { + return platformService.deletePlatformById(id); + } + @Operation(summary = "删除platform信息", description = "删除platform信息", parameters = { @@ -155,7 +173,7 @@ public Result updatePlatform(@PathVariable Integer id, @RequestBody Pl @ApiResponse(responseCode = "400", description = "请求失败")} ) @SystemControllerLog(description = "删除platform信息") - @GetMapping("/platform/delete/{id}") + @DeleteMapping("/platform/delete/{id}") public Result deletePlatform(@PathVariable Integer id) { return platformService.deletePlatformById(id); } diff --git a/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java index 7f8f7ff4..22f8cc93 100644 --- a/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java @@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -155,7 +156,7 @@ public Result updatePlatformHistory(@PathVariable Integer id, @ @ApiResponse(responseCode = "400", description = "请求失败")} ) @SystemControllerLog(description = "删除platformHistory信息") - @GetMapping("/platform-history/delete/{id}") + @DeleteMapping("/platform-history/delete/{id}") public Result deletePlatformHistory(@PathVariable Integer id) { return platformHistoryService.deletePlatformHistoryById(id); } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java index d5778722..52517260 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java @@ -141,8 +141,10 @@ public Integer createComponent(Component component) { @SystemServiceLog(description = "readFileAndBulkCreate 创建组件库及组件实现方法") @Override public Result readFileAndBulkCreate(MultipartFile file) { - List componentList = this.bundleSplit(file).getData().getComponentList(); - List packageList = this.bundleSplit(file).getData().getPackageList(); + Result bundleResultDtoResult = this.bundleSplit(file); + BundleResultDto data = bundleResultDtoResult.getData(); + List componentList = data.getComponentList(); + List packageList = data.getPackageList(); if (null == packageList || packageList.isEmpty()) { return bulkCreate(componentList); } @@ -181,6 +183,7 @@ public Result readFileAndBulkCreate(MultipartFile file) { @Override @SystemServiceLog(description = "bundleSplit 拆分bundle.json实现方法") public Result bundleSplit(MultipartFile file) { + // 检验文件 boolean isFileCheck = this.checkFile(file); if (!isFileCheck){ return Result.failed(ExceptionEnum.CM325); diff --git a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistoryServiceImpl.java similarity index 78% rename from base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java rename to base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistoryServiceImpl.java index 3f869523..fd24b737 100644 --- a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistorySrviceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistoryServiceImpl.java @@ -30,7 +30,7 @@ */ @Service @Slf4j -public class PlatformHistorySrviceImpl implements PlatformHistoryService { +public class PlatformHistoryServiceImpl implements PlatformHistoryService { @Autowired private PlatformHistoryMapper platformHistoryMapper; @@ -93,6 +93,9 @@ public Result deletePlatformHistoryById(Integer id) { */ @Override public Result updatePlatformHistoryById(PlatformHistory platformHistory) { + if (platformHistory == null || platformHistory.getId() == null) { + return Result.failed(ExceptionEnum.CM002); + } int updateResult = platformHistoryMapper.updatePlatformHistoryById(platformHistory); if (updateResult != 1) { return Result.failed(ExceptionEnum.CM008); @@ -109,6 +112,21 @@ public Result updatePlatformHistoryById(PlatformHistory platfor */ @Override public Result createPlatformHistory(PlatformHistory platformHistory) { + if (platformHistory == null) { + return Result.failed(ExceptionEnum.CM002); + } + if (platformHistory.getRefId() == null) { + return Result.failed(ExceptionEnum.CM002); + } + if (platformHistory.getName() == null || platformHistory.getName().isEmpty()) { + return Result.failed(ExceptionEnum.CM002); + } + if (platformHistory.getVersion() == null || platformHistory.getVersion().isEmpty()) { + return Result.failed(ExceptionEnum.CM002); + } + if (platformHistory.getMaterialHistoryId() == null) { + return Result.failed(ExceptionEnum.CM002); + } int createResult = platformHistoryMapper.createPlatformHistory(platformHistory); if (createResult != 1) { return Result.failed(ExceptionEnum.CM008); diff --git a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java index b9d06600..6046ee65 100644 --- a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java @@ -96,6 +96,9 @@ public Result deletePlatformById(@Param("id") Integer id) { */ @Override public Result updatePlatformById(Platform platform) { + if (platform == null || platform.getId() == null) { + return Result.failed(ExceptionEnum.CM002); + } int updateResult = platformMapper.updatePlatformById(platform); if (updateResult != 1) { return Result.failed(ExceptionEnum.CM008); @@ -112,6 +115,12 @@ public Result updatePlatformById(Platform platform) { */ @Override public Result createPlatform(Platform platform) { + if (platform == null) { + return Result.failed(ExceptionEnum.CM002); + } + if (platform.getName() == null || platform.getName().isEmpty()) { + return Result.failed(ExceptionEnum.CM002); + } int createResult = platformMapper.createPlatform(platform); if (createResult != 1) { return Result.failed(ExceptionEnum.CM008); diff --git a/base/src/main/resources/mappers/PlatformHistoryMapper.xml b/base/src/main/resources/mappers/PlatformHistoryMapper.xml index 52c7871f..cc4631c4 100644 --- a/base/src/main/resources/mappers/PlatformHistoryMapper.xml +++ b/base/src/main/resources/mappers/PlatformHistoryMapper.xml @@ -155,7 +155,7 @@ diff --git a/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java b/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java index 19b7ae65..9e9868fc 100644 --- a/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java +++ b/base/src/test/java/com/tinyengine/it/service/platform/impl/PlatformServiceImplTest.java @@ -97,6 +97,7 @@ void testUpdatePlatformById() { @Test void testCreatePlatform() { Platform param = new Platform(); + param.setName("testPlatform"); when(platformMapper.createPlatform(param)).thenReturn(1); Result result = platformServiceImpl.createPlatform(param); From 68b329a1a672fb34fe4f4f017bbcc8f6e1ce8bed Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 13 May 2025 02:31:37 -0700 Subject: [PATCH 63/72] feat: Add inspection file --- .../tinyengine/it/controller/PlatformHistoryController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java index 22f8cc93..96808480 100644 --- a/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java @@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -132,7 +133,7 @@ public Result createPlatformHistory(@Valid @RequestBody Platfor schema = @Schema(implementation = PlatformHistory.class))), @ApiResponse(responseCode = "400", description = "请求失败")}) @SystemControllerLog(description = "修改单个PlatformHistory信息") - @PostMapping("/platform-history/update/{id}") + @PutMapping("/platform-history/update/{id}") public Result updatePlatformHistory(@PathVariable Integer id, @RequestBody PlatformHistory platformHistory) { platformHistory.setId(id); return platformHistoryService.updatePlatformHistoryById(platformHistory); From 37e06a97997d52cc72d99707518618cde4bd3351 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 13 May 2025 02:53:39 -0700 Subject: [PATCH 64/72] feat: Add inspection file --- .../com/tinyengine/it/controller/ComponentController.java | 3 +++ .../com/tinyengine/it/controller/I18nEntryController.java | 5 +++-- .../it/service/material/impl/ComponentServiceImpl.java | 2 -- .../tinyengine/it/controller/I18nEntryControllerTest.java | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java index 390d5be2..5408fa3f 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java @@ -15,6 +15,7 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.common.log.SystemControllerLog; +import com.tinyengine.it.common.utils.SecurityFileCheckUtil; import com.tinyengine.it.model.dto.BundleResultDto; import com.tinyengine.it.model.dto.CustComponentDto; import com.tinyengine.it.model.dto.FileResult; @@ -71,6 +72,7 @@ public Result bundleCreateComponent(@RequestParam MultipartFile file if (file.isEmpty()) { return Result.failed(ExceptionEnum.CM307); } + SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); // 返回插入和更新的条数 return componentService.readFileAndBulkCreate(file); } @@ -92,6 +94,7 @@ public Result bundleSplit(@RequestParam MultipartFile file) { if (file.isEmpty()) { return Result.failed(ExceptionEnum.CM307); } + SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); return componentService.bundleSplit(file); } diff --git a/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java b/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java index 87987848..daf9e917 100644 --- a/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java @@ -16,6 +16,7 @@ import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.common.exception.ServiceException; import com.tinyengine.it.common.log.SystemControllerLog; +import com.tinyengine.it.common.utils.SecurityFileCheckUtil; import com.tinyengine.it.model.dto.DeleteI18nEntry; import com.tinyengine.it.model.dto.FileResult; import com.tinyengine.it.model.dto.I18nEntryDto; @@ -234,7 +235,7 @@ public Result updateI18nSingleFile( for (Map.Entry entry : filesMap.entrySet()) { // 获取对应的文件 MultipartFile file = entry.getValue(); - + SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); if (file.isEmpty()) { return Result.failed(ExceptionEnum.CM307); } @@ -274,7 +275,7 @@ public Result updateI18nMultiFile( for (Map.Entry entry : filesMap.entrySet()) { String key = entry.getKey(); // 获取动态的参数名 MultipartFile file = entry.getValue(); // 获取对应的文件 - + SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); if (file.isEmpty()) { return Result.failed(ExceptionEnum.CM307); } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java index 52517260..6f4d32a9 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java @@ -389,8 +389,6 @@ private String toPascalCase(String input) { } public boolean checkFile(MultipartFile file) { - SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); - Map fileTypeMap = new HashMap<>(); fileTypeMap.put(".json", "application/json"); boolean isCheckFileType = SecurityFileCheckUtil.checkFileType(file, fileTypeMap); diff --git a/base/src/test/java/com/tinyengine/it/controller/I18nEntryControllerTest.java b/base/src/test/java/com/tinyengine/it/controller/I18nEntryControllerTest.java index 7e1e2777..3650b72f 100644 --- a/base/src/test/java/com/tinyengine/it/controller/I18nEntryControllerTest.java +++ b/base/src/test/java/com/tinyengine/it/controller/I18nEntryControllerTest.java @@ -131,6 +131,7 @@ void testUpdateI18nSingleFile() throws Exception { when(i18nEntryService.readSingleFileAndBulkCreate(any(MultipartFile.class), anyInt())) .thenReturn(mockData); MultipartFile file = Mockito.mock(MultipartFile.class); + when(file.getOriginalFilename()).thenReturn("example.json"); when(file.isEmpty()).thenReturn(false); HashMap filesMap = new HashMap() {{ put("filesMap", file); @@ -145,6 +146,7 @@ void testUpdateI18nMultiFile() throws Exception { when(i18nEntryService.readFilesAndbulkCreate(anyString(), any(MultipartFile.class), anyInt())) .thenReturn(new Result()); MultipartFile file = Mockito.mock(MultipartFile.class); + when(file.getOriginalFilename()).thenReturn("example.json"); when(file.isEmpty()).thenReturn(false); HashMap filesMap = new HashMap() {{ put("filesMap", file); From 2df555030f7cac1bd7d59906eb79418818f70a3d Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Tue, 13 May 2025 02:56:19 -0700 Subject: [PATCH 65/72] feat: Add inspection file --- .../com/tinyengine/it/controller/I18nEntryController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java b/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java index daf9e917..2375ee98 100644 --- a/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java @@ -235,10 +235,10 @@ public Result updateI18nSingleFile( for (Map.Entry entry : filesMap.entrySet()) { // 获取对应的文件 MultipartFile file = entry.getValue(); - SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); if (file.isEmpty()) { return Result.failed(ExceptionEnum.CM307); } + SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); // 返回插入和更新的条数 result = i18nEntryService.readSingleFileAndBulkCreate(file, id); } @@ -275,10 +275,10 @@ public Result updateI18nMultiFile( for (Map.Entry entry : filesMap.entrySet()) { String key = entry.getKey(); // 获取动态的参数名 MultipartFile file = entry.getValue(); // 获取对应的文件 - SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); if (file.isEmpty()) { return Result.failed(ExceptionEnum.CM307); } + SecurityFileCheckUtil.validFileName(file.getOriginalFilename()); // 返回插入和更新的条数 result = i18nEntryService.readFilesAndbulkCreate(key, file, id); } From a20073b37e80d2138bb323539f820440c07057aa Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Wed, 14 May 2025 01:45:24 -0700 Subject: [PATCH 66/72] fix: Modify the default values of table fields and page API --- .../sql/h2/create_all_tables_ddl_v1.h2.sql | 44 +++++++++---------- .../sql/h2/update_all_tables_ddl.sql | 23 +++++++++- .../mysql/create_all_tables_ddl_v1.mysql.sql | 40 ++++++++--------- .../sql/mysql/update_all_tables_ddl.sql | 23 +++++++++- .../common/handler/MyMetaObjectHandler.java | 3 -- .../it/service/app/impl/PageServiceImpl.java | 19 ++++++++ .../it/service/extend/PostSaveHook.java | 29 ++++++++++++ 7 files changed, 134 insertions(+), 47 deletions(-) create mode 100644 base/src/main/java/com/tinyengine/it/service/extend/PostSaveHook.java diff --git a/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql b/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql index 07ce9bd1..0e9de41c 100644 --- a/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql +++ b/app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql @@ -22,7 +22,7 @@ create table `t_platform` `theme_id` int comment '生态扩展使用,关联主题', `platform_url` varchar(255) comment '设计器静态资源托管地址url', `vscode_url` varchar(255) comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -43,13 +43,13 @@ create table `t_platform_history` `name` varchar(255) not null comment '名称', `publish_url` varchar(255) comment '设计器静态资源托管地址', `description` varchar(2000) comment '描述', - `vscode_url` varchar(255) comment '设计预留字段', + `vscode_url` varchar(255) comment '设计预留字段', `material_history_id` int not null comment '关联物料包历史id', `sub_count` int comment '设计预留字段', `material_pkg_name` varchar(255) comment '物料包名称', `material_version` varchar(255) comment '物料包版本', `image_url` varchar(255) comment '封面图地址', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -99,7 +99,7 @@ create table `t_app` `data_hash` varchar(255) comment '应用内容哈希值', `can_associate` tinyint(1) comment '设计预留字段', `data_source_global` longtext comment '数据源全局配置', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -120,7 +120,7 @@ create table `t_app_extension` `content` longtext not null comment '内容', `app_id` int not null comment '关联appid', `category` varchar(255) not null comment '分类:utils,bridge', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -140,7 +140,7 @@ create table `t_block_group` `description` varchar(2000) comment '描述', `app_id` int not null comment '关联app id', `platform_id` int not null comment '设计器id', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -158,7 +158,7 @@ create table `t_business_category` `id` int not null auto_increment comment '主键id', `code` varchar(255) not null comment '编码', `name` varchar(255) not null comment '名称', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -198,7 +198,7 @@ create table `t_block` `platform_id` int not null comment '设计器id', `app_id` int not null comment '创建区块时所在appid', `content_blocks` longtext comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -237,7 +237,7 @@ create table `t_block_history` `npm_name` varchar(255) comment 'npm包名', `i18n` longtext NULL COMMENT '国际化', `content_blocks` longtext comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -273,7 +273,7 @@ create table `t_material` `tgz_url` varchar(255) comment '物料包存储地址', `unzip_tgz_root_path_url` longtext comment '物料包存储根路径', `unzip_tgz_files` longtext comment '物料包存储文件', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -303,7 +303,7 @@ create table `t_material_history` `tgz_url` varchar(255) comment '物料包存储地址', `unzip_tgz_root_path_url` longtext comment '物料包存储根路径', `unzip_tgz_files` longtext comment '物料包存储文件', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -333,7 +333,7 @@ create table `t_page` `content_blocks` longtext comment '设计预留字段', `latest_version` varchar(255) comment '当前历史记录表最新版本', `latest_history_id` int comment '当前历史记录表id', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -364,7 +364,7 @@ create table `t_page_history` `message` varchar(255) comment '历史记录消息描述', `is_home` tinyint(1) not null default 0 comment '是否首页', `content_blocks` longtext comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `is_published` tinyint(1) not null comment '是否发布', @@ -391,7 +391,7 @@ create table `t_page_template` `image_url` longtext comment '封面图地址', `description` varchar(2000) comment '描述', `platform_id` int not null comment '设计器id', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -430,7 +430,7 @@ create table `t_component` `tiny_reserved` tinyint(1) comment '是否是tiny自有', `component_metadata` longtext comment '属性信息', `library_id` int comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -501,7 +501,7 @@ create table `t_i18n_entry` `host_id` int not null comment '关联的hostid: appid或blockid', `host_type` varchar(255) not null comment 'app或者block', `lang_id` int comment '关联语言id', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -538,7 +538,7 @@ create table `t_datasource` `app_id` int comment '关联appId', `platform_id` int comment '关联设计器id', `description` varchar(2000) comment '描述', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -564,7 +564,7 @@ create table `t_task_record` `ratio` int comment '无用字段', `progress_percent` int comment '构建进度百分比数', `indicator` longtext comment '构建指标', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -602,7 +602,7 @@ create table `t_user` `enable` tinyint(1) comment '账号是否可用', `is_admin` tinyint(1) comment '是否管理员', `is_public` tinyint(1) comment '是否公共账号', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -619,10 +619,10 @@ create table `t_block_carriers_relation` ( `id` int not null auto_increment comment '主键id', `block_id` int not null comment '区块id', - `host_id` int not null comment '类型id', + `host_id` int not null comment '类型id', `host_type` varchar(60) comment '类型:blockGroup,materialHistory', `version` varchar(60) not null comment '区块当前使用版本', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -665,7 +665,7 @@ create table `t_component_library` `is_started` tinyint(1) comment '是否启用', `is_official` tinyint(1) comment '是否是官方', `is_default` tinyint(1) comment '是否是默认', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', diff --git a/app/src/main/resources/sql/h2/update_all_tables_ddl.sql b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql index 1e59d2a8..7a944faf 100644 --- a/app/src/main/resources/sql/h2/update_all_tables_ddl.sql +++ b/app/src/main/resources/sql/h2/update_all_tables_ddl.sql @@ -5,4 +5,25 @@ ALTER TABLE t_datasource DROP INDEX u_idx_datasource; ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`); ALTER TABLE t_platform_history MODIFY sub_count int NULL; -ALTER TABLE t_platform_history MODIFY publish_url varchar(255) NULL; \ No newline at end of file +ALTER TABLE t_platform_history MODIFY publish_url varchar(255) NULL; + +ALTER TABLE t_app MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_app_extension MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_block MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_block_carriers_relation MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_block_group MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_block_history MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_business_category MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_component MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_component_library MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_datasource MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_i18n_entry MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_material MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_material_history MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_page MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_page_history MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_page_template MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_platform MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_platform_history MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_task_record MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_user MODIFY tenant_id varchar(60) NULL; diff --git a/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql b/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql index bccbab33..0e9de41c 100644 --- a/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql +++ b/app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql @@ -22,7 +22,7 @@ create table `t_platform` `theme_id` int comment '生态扩展使用,关联主题', `platform_url` varchar(255) comment '设计器静态资源托管地址url', `vscode_url` varchar(255) comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -49,7 +49,7 @@ create table `t_platform_history` `material_pkg_name` varchar(255) comment '物料包名称', `material_version` varchar(255) comment '物料包版本', `image_url` varchar(255) comment '封面图地址', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -99,7 +99,7 @@ create table `t_app` `data_hash` varchar(255) comment '应用内容哈希值', `can_associate` tinyint(1) comment '设计预留字段', `data_source_global` longtext comment '数据源全局配置', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -120,7 +120,7 @@ create table `t_app_extension` `content` longtext not null comment '内容', `app_id` int not null comment '关联appid', `category` varchar(255) not null comment '分类:utils,bridge', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -140,7 +140,7 @@ create table `t_block_group` `description` varchar(2000) comment '描述', `app_id` int not null comment '关联app id', `platform_id` int not null comment '设计器id', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -158,7 +158,7 @@ create table `t_business_category` `id` int not null auto_increment comment '主键id', `code` varchar(255) not null comment '编码', `name` varchar(255) not null comment '名称', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -198,7 +198,7 @@ create table `t_block` `platform_id` int not null comment '设计器id', `app_id` int not null comment '创建区块时所在appid', `content_blocks` longtext comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -237,7 +237,7 @@ create table `t_block_history` `npm_name` varchar(255) comment 'npm包名', `i18n` longtext NULL COMMENT '国际化', `content_blocks` longtext comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -273,7 +273,7 @@ create table `t_material` `tgz_url` varchar(255) comment '物料包存储地址', `unzip_tgz_root_path_url` longtext comment '物料包存储根路径', `unzip_tgz_files` longtext comment '物料包存储文件', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -303,7 +303,7 @@ create table `t_material_history` `tgz_url` varchar(255) comment '物料包存储地址', `unzip_tgz_root_path_url` longtext comment '物料包存储根路径', `unzip_tgz_files` longtext comment '物料包存储文件', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -333,7 +333,7 @@ create table `t_page` `content_blocks` longtext comment '设计预留字段', `latest_version` varchar(255) comment '当前历史记录表最新版本', `latest_history_id` int comment '当前历史记录表id', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -364,7 +364,7 @@ create table `t_page_history` `message` varchar(255) comment '历史记录消息描述', `is_home` tinyint(1) not null default 0 comment '是否首页', `content_blocks` longtext comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `is_published` tinyint(1) not null comment '是否发布', @@ -391,7 +391,7 @@ create table `t_page_template` `image_url` longtext comment '封面图地址', `description` varchar(2000) comment '描述', `platform_id` int not null comment '设计器id', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -430,7 +430,7 @@ create table `t_component` `tiny_reserved` tinyint(1) comment '是否是tiny自有', `component_metadata` longtext comment '属性信息', `library_id` int comment '设计预留字段', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -501,7 +501,7 @@ create table `t_i18n_entry` `host_id` int not null comment '关联的hostid: appid或blockid', `host_type` varchar(255) not null comment 'app或者block', `lang_id` int comment '关联语言id', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -538,7 +538,7 @@ create table `t_datasource` `app_id` int comment '关联appId', `platform_id` int comment '关联设计器id', `description` varchar(2000) comment '描述', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -564,7 +564,7 @@ create table `t_task_record` `ratio` int comment '无用字段', `progress_percent` int comment '构建进度百分比数', `indicator` longtext comment '构建指标', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -602,7 +602,7 @@ create table `t_user` `enable` tinyint(1) comment '账号是否可用', `is_admin` tinyint(1) comment '是否管理员', `is_public` tinyint(1) comment '是否公共账号', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -622,7 +622,7 @@ create table `t_block_carriers_relation` `host_id` int not null comment '类型id', `host_type` varchar(60) comment '类型:blockGroup,materialHistory', `version` varchar(60) not null comment '区块当前使用版本', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', @@ -665,7 +665,7 @@ create table `t_component_library` `is_started` tinyint(1) comment '是否启用', `is_official` tinyint(1) comment '是否是官方', `is_default` tinyint(1) comment '是否是默认', - `tenant_id` varchar(60) not null comment '租户id', + `tenant_id` varchar(60) comment '租户id', `renter_id` varchar(60) comment '业务租户id', `site_id` varchar(60) comment '站点id,设计预留字段', `created_by` varchar(60) not null comment '创建人', diff --git a/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql index 1e59d2a8..7a944faf 100644 --- a/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql +++ b/app/src/main/resources/sql/mysql/update_all_tables_ddl.sql @@ -5,4 +5,25 @@ ALTER TABLE t_datasource DROP INDEX u_idx_datasource; ALTER TABLE t_datasource ADD INDEX u_idx_datasource (`tenant_id`, `platform_id`, `name`, `app_id`); ALTER TABLE t_platform_history MODIFY sub_count int NULL; -ALTER TABLE t_platform_history MODIFY publish_url varchar(255) NULL; \ No newline at end of file +ALTER TABLE t_platform_history MODIFY publish_url varchar(255) NULL; + +ALTER TABLE t_app MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_app_extension MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_block MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_block_carriers_relation MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_block_group MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_block_history MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_business_category MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_component MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_component_library MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_datasource MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_i18n_entry MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_material MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_material_history MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_page MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_page_history MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_page_template MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_platform MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_platform_history MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_task_record MODIFY tenant_id varchar(60) NULL; +ALTER TABLE t_user MODIFY tenant_id varchar(60) NULL; diff --git a/base/src/main/java/com/tinyengine/it/common/handler/MyMetaObjectHandler.java b/base/src/main/java/com/tinyengine/it/common/handler/MyMetaObjectHandler.java index b1b2e701..27596b7f 100644 --- a/base/src/main/java/com/tinyengine/it/common/handler/MyMetaObjectHandler.java +++ b/base/src/main/java/com/tinyengine/it/common/handler/MyMetaObjectHandler.java @@ -40,9 +40,6 @@ public void insertFill(MetaObject metaObject) { this.setFieldValByName("lastUpdatedTime", LocalDateTime.now(), metaObject); this.setFieldValByName("createdBy", loginUserContext.getLoginUserId(), metaObject); this.setFieldValByName("lastUpdatedBy", loginUserContext.getLoginUserId(), metaObject); - this.setFieldValByName("tenantId", loginUserContext.getTenantId(), metaObject); - this.setFieldValByName("renterId", loginUserContext.getRenterId(), metaObject); - this.setFieldValByName("siteId", loginUserContext.getSiteId(), metaObject); this.setFieldValByName("platformId", loginUserContext.getPlatformId(), metaObject); } diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java index 681ce799..3e594263 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java @@ -44,6 +44,7 @@ import com.tinyengine.it.service.app.PageService; import com.tinyengine.it.service.app.UserService; import com.tinyengine.it.service.app.impl.v1.AppV1ServiceImpl; +import com.tinyengine.it.service.extend.PostSaveHook; import com.tinyengine.it.service.material.impl.BlockServiceImpl; import lombok.extern.slf4j.Slf4j; @@ -124,12 +125,24 @@ public class PageServiceImpl implements PageService { @Autowired private I18nEntryMapper i18nEntryMapper; + /** + * The page history service. + */ @Autowired private PageHistoryService pageHistoryService; + /** + * The login user context. + */ @Autowired private LoginUserContext loginUserContext; + /** + * The post save hook. + */ + @Autowired(required = false) + private PostSaveHook postSaveHook; + /** * 通过appId查询page所有数据实现方法 * @@ -268,6 +281,9 @@ public Result createPage(Page page) { if (resultPageHistory < 1) { return Result.failed(ExceptionEnum.CM001); } + if (postSaveHook != null) { + postSaveHook.afterSave(pageInfo); + } return Result.success(pageInfo); } @@ -359,6 +375,9 @@ public Result updatePage(Page page) { if (resultPageHistory < 1) { return Result.failed(ExceptionEnum.CM001); } + if (postSaveHook != null) { + postSaveHook.afterSave(page); + } return checkUpdate(page); } diff --git a/base/src/main/java/com/tinyengine/it/service/extend/PostSaveHook.java b/base/src/main/java/com/tinyengine/it/service/extend/PostSaveHook.java new file mode 100644 index 00000000..65c8feb0 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/service/extend/PostSaveHook.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.service.extend; + +import com.tinyengine.it.model.entity.Page; + +/** + * PostSaveHook. + * + * @since 2025-05-14 + */ +public interface PostSaveHook { + /** + * afterSave + * + * @param page the page + */ + void afterSave(Page page); +} From 0e44141b002b72b528c60fa24fe2b6b191d4f6cb Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Wed, 14 May 2025 01:49:57 -0700 Subject: [PATCH 67/72] fix: Modify the default values of table fields and page API --- .../tinyengine/it/common/handler/MyMetaObjectHandlerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java b/base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java index d6b219e5..d398dcd3 100644 --- a/base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java +++ b/base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java @@ -36,7 +36,7 @@ void testInsertFill() throws NoSuchFieldException, IllegalAccessException { when(param.hasSetter("tenantId")).thenReturn(true); TestUtil.setPrivateValue(myMetaObjectHandler, "loginUserContext", new MockUserContext()); myMetaObjectHandler.insertFill(param); - verify(param, times(8)).hasSetter(anyString()); + verify(param, times(5)).hasSetter(anyString()); } @Test From 46f32774986a147522426d8a2c070c62e7efbff1 Mon Sep 17 00:00:00 2001 From: lu17301156525 Date: Thu, 22 May 2025 01:52:30 -0700 Subject: [PATCH 68/72] fix: Format code and fix style issue --- .../it/common/context/LoginUserContext.java | 16 +- .../common/utils/SecurityFileCheckUtil.java | 9 +- .../tinyengine/it/config/AiChatConfig.java | 26 +- .../it/controller/BlockController.java | 284 ++++++++---------- .../it/controller/BlockGroupController.java | 93 +++--- .../it/controller/CanvasController.java | 23 +- .../it/controller/ComponentController.java | 30 +- .../ComponentLibraryController.java | 78 +++-- .../it/controller/DataSourceController.java | 57 ++-- .../it/controller/I18nEntryController.java | 118 ++++---- .../it/controller/MaterialController.java | 75 +++-- .../it/controller/PageController.java | 81 ++--- .../it/controller/PageHistoryController.java | 75 ++--- .../it/controller/PageTemplateController.java | 55 ++-- .../it/controller/PlatformController.java | 108 +++---- .../controller/PlatformHistoryController.java | 90 +++--- .../it/controller/TaskRecordController.java | 21 +- .../TaskRecordMaterialController.java | 44 ++- .../it/controller/UserController.java | 19 +- .../tinyengine/it/event/PageDeleteEvent.java | 27 ++ .../it/gateway/ai/AiChatClient.java | 2 + .../com/tinyengine/it/mapper/BlockMapper.java | 22 +- .../it/mapper/PlatformHistoryMapper.java | 1 - .../com/tinyengine/it/mapper/UserMapper.java | 4 +- .../tinyengine/it/model/dto/BlockParam.java | 1 + .../it/model/dto/BundleResultDto.java | 1 + .../it/model/dto/CustComponentDto.java | 1 + .../tinyengine/it/model/dto/PackagesDto.java | 1 + .../it/model/entity/BlockGroupBlock.java | 1 + .../it/model/entity/PlatformHistory.java | 2 +- .../com/tinyengine/it/model/entity/User.java | 44 ++- .../it/service/app/UserService.java | 4 +- .../service/app/impl/AiChatServiceImpl.java | 82 ++--- .../service/app/impl/CanvasServiceImpl.java | 18 +- .../app/impl/I18nEntryServiceImpl.java | 38 ++- .../app/impl/PageHistoryServiceImpl.java | 2 +- .../it/service/app/impl/PageServiceImpl.java | 55 ++-- .../it/service/app/impl/UserServiceImpl.java | 5 +- .../service/app/impl/v1/AppV1ServiceImpl.java | 21 +- .../it/service/material/BlockService.java | 2 +- .../it/service/material/ComponentService.java | 2 - .../material/impl/BlockGroupServiceImpl.java | 33 +- .../material/impl/BlockServiceImpl.java | 85 +++--- .../impl/ComponentLibraryServiceImpl.java | 6 +- .../material/impl/ComponentServiceImpl.java | 93 +++--- .../impl/MaterialHistoryServiceImpl.java | 6 +- .../material/impl/MaterialServiceImpl.java | 9 +- .../platform/PlatformHistoryService.java | 1 + .../impl/PlatformHistoryServiceImpl.java | 2 + .../platform/impl/PlatformServiceImpl.java | 6 +- .../mappers/BlockCarriersRelationMapper.xml | 2 +- .../resources/mappers/BlockGroupMapper.xml | 1 - .../it/common/handler/MockUserContext.java | 2 + .../tinyengine/it/common/utils/TestUtil.java | 30 ++ .../it/controller/BlockControllerTest.java | 15 +- .../controller/BlockGroupControllerTest.java | 14 +- .../it/controller/UserControllerTest.java | 18 +- .../it/gateway/ai/AiChatClientTest.java | 40 ++- .../app/impl/CanvasServiceImplTest.java | 12 +- .../service/app/impl/PageServiceImplTest.java | 19 +- .../service/app/impl/UserServiceImplTest.java | 8 +- .../app/impl/v1/AppV1ServiceImplTest.java | 24 +- .../impl/BlockGroupServiceImplTest.java | 7 +- .../material/impl/BlockServiceImplTest.java | 6 +- .../impl/ComponentServiceImplTest.java | 3 +- .../impl/MaterialServiceImplTest.java | 1 + 66 files changed, 1088 insertions(+), 993 deletions(-) create mode 100644 base/src/main/java/com/tinyengine/it/event/PageDeleteEvent.java create mode 100644 base/src/test/java/com/tinyengine/it/common/utils/TestUtil.java diff --git a/base/src/main/java/com/tinyengine/it/common/context/LoginUserContext.java b/base/src/main/java/com/tinyengine/it/common/context/LoginUserContext.java index a0e8adbd..9c1e6c6c 100644 --- a/base/src/main/java/com/tinyengine/it/common/context/LoginUserContext.java +++ b/base/src/main/java/com/tinyengine/it/common/context/LoginUserContext.java @@ -20,31 +20,35 @@ public interface LoginUserContext { * 返回当前用户所诉的业务租户信息 * @return 租户ID */ - public String getTenantId(); + String getTenantId(); /** * 返回当前用户信息 * @return 用户ID */ - public String getLoginUserId(); + String getLoginUserId(); /** * 返回当前用户所属业务租户信息 * @return 业务租户ID */ - public String getRenterId(); + String getRenterId(); /** * 返回当前应用信息 * @return 应用ID */ - public int getAppId(); + int getAppId(); /** * 返回当前设计器信息 * @return 设计器ID */ - public int getPlatformId(); + int getPlatformId(); - public String getSiteId(); + /** + * getSiteId + * @return Strinig + */ + String getSiteId(); } diff --git a/base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java b/base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java index 444cb188..2b6e6b49 100644 --- a/base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java +++ b/base/src/main/java/com/tinyengine/it/common/utils/SecurityFileCheckUtil.java @@ -18,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile; import java.io.File; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.regex.Pattern; @@ -41,7 +42,8 @@ public class SecurityFileCheckUtil { public static boolean checkPathHasCrossDir(String dirOrFileName) { if (!dirOrFileName.contains("../") && !dirOrFileName.contains("/..")) { if (!dirOrFileName.contains("..\\") && !dirOrFileName.contains("\\..")) { - return dirOrFileName.contains("./") || dirOrFileName.contains(".\\.\\") || dirOrFileName.contains("%00"); + return dirOrFileName.contains("./") || dirOrFileName.contains(".\\.\\") + || dirOrFileName.contains("%00"); } else { return true; } @@ -142,7 +144,7 @@ public static boolean filePathIsValid(String fileName) { } // 获取当前操作系统的名称 - String os = System.getProperty("os.name").toLowerCase(); + String os = System.getProperty("os.name").toLowerCase(Locale.ROOT); // 定义通用的非法字符 String illegalChars = ""; @@ -150,7 +152,8 @@ public static boolean filePathIsValid(String fileName) { if (os.contains("win")) { // 针对Windows的非法字符 illegalChars = "[<>:\"/\\|?*]"; - } else if (os.contains("nix") || os.contains("nux") || os.contains("mac")) { + } + if (os.contains("nix") || os.contains("nux") || os.contains("mac")) { // 针对Linux和macOS的非法字符(一般来说,Linux和macOS对文件名的限制较少,但有一些常见的非法字符) illegalChars = "[/]"; // Linux和macOS的路径不能包含斜杠 '/' } diff --git a/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java b/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java index aac487be..b72bc3fd 100644 --- a/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java +++ b/base/src/main/java/com/tinyengine/it/config/AiChatConfig.java @@ -52,21 +52,25 @@ public static Map getAiChatConfig(String model, String Map ernieBotHeaders = new HashMap<>(); - config.put(Enums.FoundationModel.GPT_35_TURBO.getValue(), new AiChatConfigData( - OPENAI_API_URL + "/v1/chat/completions", createCommonRequestOption(), openaiHeaders, "openai")); + config.put(Enums.FoundationModel.GPT_35_TURBO.getValue(), + new AiChatConfigData( + OPENAI_API_URL + "/v1/chat/completions", createCommonRequestOption(), openaiHeaders, + "openai")); - config.put(Enums.FoundationModel.LOCAL_GPT.getValue(), new AiChatConfigData( - LOCAL_GPT_API_URL + "/v1/chat/completions", createCommonRequestOption(), localGptHeaders, "!openai")); + config.put(Enums.FoundationModel.LOCAL_GPT.getValue(), + new AiChatConfigData( + LOCAL_GPT_API_URL + "/v1/chat/completions", createCommonRequestOption(), localGptHeaders, + "!openai")); - config.put(Enums.FoundationModel.DEEPSEEK_V3.getValue(), new AiChatConfigData( - DEEPSEEK_V3_URL + "/chat/completions", createCommonRequestOption(), deepSeekHeaders, "DeepSeek")); + config.put(Enums.FoundationModel.DEEPSEEK_V3.getValue(), + new AiChatConfigData( + DEEPSEEK_V3_URL + "/chat/completions", createCommonRequestOption(), deepSeekHeaders, + "DeepSeek")); String ernieBotAccessToken = Enums.FoundationModel.ERNIBOT_TURBO.getValue().equals(model) ? token : null; - config.put(Enums.FoundationModel.ERNIBOT_TURBO.getValue(), - new AiChatConfigData( - "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=" - + ernieBotAccessToken, - createCommonRequestOption(), ernieBotHeaders, "baidu")); + config.put(Enums.FoundationModel.ERNIBOT_TURBO.getValue(), new AiChatConfigData( +"https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=" + + ernieBotAccessToken, createCommonRequestOption(), ernieBotHeaders, "baidu")); return config; } diff --git a/base/src/main/java/com/tinyengine/it/controller/BlockController.java b/base/src/main/java/com/tinyengine/it/controller/BlockController.java index a2cd10f0..ba6139b2 100644 --- a/base/src/main/java/com/tinyengine/it/controller/BlockController.java +++ b/base/src/main/java/com/tinyengine/it/controller/BlockController.java @@ -62,10 +62,21 @@ @RequestMapping("/material-center/api") @Tag(name = "区块") public class BlockController { + /** + * The Block service. + */ @Autowired private BlockService blockService; + + /** + * The Tenant service. + */ @Autowired private TenantMapper tenantMapper; + + /** + * The Block mapper. + */ @Autowired private BlockMapper blockMapper; @@ -75,17 +86,13 @@ public class BlockController { * @param blockParamDto blockParamDto * @return block列表信息 */ - @Operation(summary = "获取区块列表信息", - description = "获取区块列表信息", - parameters = { - @Parameter(name = "blockParamDto", description = "入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Block.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "获取区块列表信息", description = "获取区块列表信息", parameters = { + @Parameter(name = "blockParamDto", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取区块列表api") @GetMapping("/block/list") public Result> getAllBlocks(@ModelAttribute BlockParamDto blockParamDto) { @@ -101,18 +108,15 @@ public Result> getAllBlocks(@ModelAttribute BlockParamDto blockParam * @param description description * @return the integer */ - @Operation(summary = "获取区块列表满足查询条件下的条数", - description = "获取区块列表满足查询条件下的条数", - parameters = { - @Parameter(name = "nameCn", description = "nameCn区块中文名称"), - @Parameter(name = "description", description = "区块描述") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "获取区块列表满足查询条件下的条数", description = "获取区块列表满足查询条件下的条数", + parameters = { + @Parameter(name = "nameCn", description = "nameCn区块中文名称"), + @Parameter(name = "description", description = "区块描述") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取区块列表满足查询条件下的条数") @GetMapping("/block/count") public Result getCountByCondition( @@ -130,17 +134,13 @@ public Result getCountByCondition( * @param id id * @return BlockDto */ - @Operation(summary = "查询区块详情", - description = "根据id查询表t_block信息并返回", - parameters = { - @Parameter(name = "id", description = "区块Id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回区块信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Block.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "查询区块详情", description = "根据id查询表t_block信息并返回", parameters = { + @Parameter(name = "id", description = "区块Id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回区块信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取区块详情api") @GetMapping("/block/detail/{id}") public Result getBlocksById(@PathVariable Integer id) { @@ -154,17 +154,13 @@ public Result getBlocksById(@PathVariable Integer id) { * @param blockParam the blockParam * @return BlockDto */ - @Operation(summary = "创建block", - description = "创建block", - parameters = { - @Parameter(name = "blockParam", description = "入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Block.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "创建block", description = "创建block", parameters = { + @Parameter(name = "blockParam", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "区块创建api") @PostMapping("/block/create") public Result createBlocks(@Valid @RequestBody BlockParam blockParam) { @@ -178,17 +174,13 @@ public Result createBlocks(@Valid @RequestBody BlockParam blockParam) * @param id id * @return BlockDto */ - @Operation(summary = "删除blocks信息", - description = "删除blocks信息", - parameters = { - @Parameter(name = "id", description = "区块id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Block.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "删除blocks信息", description = "删除blocks信息", parameters = { + @Parameter(name = "id", description = "区块id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除blocks信息") @GetMapping("/block/delete/{id}") public Result deleteBlock(@PathVariable Integer id) { @@ -204,17 +196,13 @@ public Result deleteBlock(@PathVariable Integer id) { * @param blockParamDto blockParamDto * @return BlockDto */ - @Operation(summary = "生态中心区块列表分页查询", - description = "生态中心区块列表分页查询", - parameters = { - @Parameter(name = "blockParamDto", description = "入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "生态中心区块列表分页查询", description = "生态中心区块列表分页查询", parameters = { + @Parameter(name = "blockParamDto", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "生态中心区块列表分页查询api") @GetMapping("/block") public Result> find(@ModelAttribute BlockParamDto blockParamDto) { @@ -233,14 +221,11 @@ public Result> find(@ModelAttribute BlockParamDto blockParamDto) * * @return the list */ - @Operation(summary = "查找表中所有tags", - description = "查找表中所有tags", - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "查找表中所有tags", description = "查找表中所有tags", responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "查找表中所有tags") @GetMapping("/block/tags") public Result> allTags() { @@ -254,23 +239,19 @@ public Result> allTags() { * @param groupId the groupId * @return the list */ - @Operation(summary = "查找不在分组内的区块", - description = "查找不在分组内的区块", - parameters = { - @Parameter(name = "groupId", description = "分组id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Block.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "查找不在分组内的区块", description = "查找不在分组内的区块", parameters = { + @Parameter(name = "groupId", description = "分组id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "查找不在分组内的区块api") @GetMapping("/block/notgroup/{groupId}") public Result> findBlocksNotInGroup(@PathVariable Integer groupId, - @RequestParam(value = "label_contains", required = false) String label, - @RequestParam(value = "tags_contains", required = false) String[] tags, - @RequestParam(value = "createdBy", required = false) String createdBy) { + @RequestParam(value = "label_contains", required = false) String label, + @RequestParam(value = "tags_contains", required = false) String[] tags, + @RequestParam(value = "createdBy", required = false) String createdBy) { NotGroupDto notGroupDto = new NotGroupDto(); notGroupDto.setGroupId(groupId); notGroupDto.setLabel(label); @@ -287,17 +268,13 @@ public Result> findBlocksNotInGroup(@PathVariable Integer groupId * @param request request * @return the ipage */ - @Operation(summary = "获取区块列表list2", - description = "获取区块列表list2", - parameters = { - @Parameter(name = "request", description = "入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "获取区块列表list2", description = "获取区块列表list2", parameters = { + @Parameter(name = "request", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取区块列表api") @GetMapping("/block/list2") public Result> getBlocks(@RequestBody Map request) { @@ -311,14 +288,11 @@ public Result> getBlocks(@RequestBody Map request) * * @return the list */ - @Operation(summary = "获取所有租户", - description = "获取所有租户", - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Tenant.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "获取所有租户", description = "获取所有租户", responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Tenant.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取所有租户api") @GetMapping("/block/tenants") public Result> allTenant() { @@ -332,14 +306,11 @@ public Result> allTenant() { * * @return the list */ - @Operation(summary = "获取所有用户", - description = "获取所有用户", - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = User.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "获取所有用户", description = "获取所有用户", responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取所有用户api") @GetMapping("/block/users") public Result> allAuthor() { @@ -355,23 +326,18 @@ public Result> allAuthor() { * @param groupId groupId * @return the list */ - @Operation(summary = "获取区块列表", - description = "获取区块列表", - parameters = { - @Parameter(name = "appId", description = "app主键id"), - @Parameter(name = "groupId", description = "区块分组id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Block.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "获取区块列表", description = "获取区块列表", parameters = { + @Parameter(name = "appId", description = "app主键id"), + @Parameter(name = "groupId", description = "区块分组id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取区块列表") @GetMapping("/blocks") - public Result> getBlockGroups( - @Valid @RequestParam(required = false) String appId, - @RequestParam(required = false) String groupId) { + public Result> getBlockGroups(@Valid @RequestParam(required = false) String appId, + @RequestParam(required = false) String groupId) { return blockService.listNew(appId, groupId); } @@ -383,22 +349,18 @@ public Result> getBlockGroups( * @param id id * @return block dto */ - @Operation(summary = "修改区块", - description = "修改区块", - parameters = { - @Parameter(name = "blockParam", description = "入参对象"), - @Parameter(name = "id", description = "区块id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Block.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "修改区块", description = "修改区块", parameters = { + @Parameter(name = "blockParam", description = "入参对象"), + @Parameter(name = "id", description = "区块id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "区块修改api") @PostMapping("/block/update/{id}") public Result updateBlocks(@Valid @RequestBody BlockParam blockParam, @PathVariable Integer id, - @RequestParam(value = "appId", required = false) Integer appId) { + @RequestParam(value = "appId", required = false) Integer appId) { blockParam.setId(id); return blockService.updateBlockById(blockParam, appId); } @@ -410,19 +372,15 @@ public Result updateBlocks(@Valid @RequestBody BlockParam blockParam, * @param appId appId * @return the result */ - @Operation(summary = "根据lable和appId查询区块详情", - description = "根据lable和appId查询区块详情", - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Block.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "根据lable和appId查询区块详情", description = "根据lable和appId查询区块详情", responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "根据lable和appId查询区块详情api") @GetMapping("/block/label") - public Result getBlockByLabel( - @RequestParam(value = "label") String label, - @RequestParam(value = "appId") Integer appId) { + public Result getBlockByLabel(@RequestParam(value = "label") String label, + @RequestParam(value = "appId") Integer appId) { return blockService.getBlockByLabel(label, appId); } @@ -432,16 +390,12 @@ public Result getBlockByLabel( * @param blockBuildDto block * @return blcok信息 */ - @Operation(summary = "区块发布", - description = "区块发布", - parameters = { - @Parameter(name = "blockBuildDto", description = "入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Block.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} + @Operation(summary = "区块发布", description = "区块发布", parameters = { + @Parameter(name = "blockBuildDto", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Block.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} ) @SystemControllerLog(description = "区块发布api") @PostMapping("/block/deploy") diff --git a/base/src/main/java/com/tinyengine/it/controller/BlockGroupController.java b/base/src/main/java/com/tinyengine/it/controller/BlockGroupController.java index 12f7dd70..f4782dae 100644 --- a/base/src/main/java/com/tinyengine/it/controller/BlockGroupController.java +++ b/base/src/main/java/com/tinyengine/it/controller/BlockGroupController.java @@ -13,11 +13,9 @@ package com.tinyengine.it.controller; import com.tinyengine.it.common.base.Result; -import com.tinyengine.it.common.context.LoginUserContext; import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.common.exception.ServiceException; import com.tinyengine.it.common.log.SystemControllerLog; -import com.tinyengine.it.mapper.BlockGroupMapper; import com.tinyengine.it.model.entity.BlockGroup; import com.tinyengine.it.service.material.BlockGroupService; @@ -56,12 +54,11 @@ @RequestMapping("/material-center/api") @Tag(name = "区块") public class BlockGroupController { + /** + * The Block group service. + */ @Autowired private BlockGroupService blockGroupService; - @Autowired - private BlockGroupMapper blockGroupMapper; - @Autowired - private LoginUserContext loginUserContext; /** * 获取区块分组 @@ -71,25 +68,21 @@ public class BlockGroupController { * @param from from * @return the list */ - @Operation(summary = "获取区块分组", - description = "获取区块分组", - parameters = { - @Parameter(name = "ids", description = "分组ids"), - @Parameter(name = "appId", description = "appId"), - @Parameter(name = "from", description = "区分是在物料管理还是区块管理(block:在区块管理)") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "获取区块分组", description = "获取区块分组", parameters = { + @Parameter(name = "ids", description = "分组ids"), + @Parameter(name = "appId", description = "appId"), + @Parameter(name = "from", description = "区分是在物料管理还是区块管理(block:在区块管理)") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取区块分组") @GetMapping("/block-groups") public Result> getAllBlockGroups( - @RequestParam(value = "id", required = false) List ids, - @RequestParam(value = "app", required = false) Integer appId, - @RequestParam(value = "from", required = false) String from) { + @RequestParam(value = "id", required = false) List ids, + @RequestParam(value = "app", required = false) Integer appId, + @RequestParam(value = "from", required = false) String from) { List blockGroupsListResult = blockGroupService.getBlockGroupByIdsOrAppId(ids, appId, from); return Result.success(blockGroupsListResult); } @@ -101,17 +94,13 @@ public Result> getAllBlockGroups( * @param blockGroup blockGroup * @return the list */ - @Operation(summary = "创建区块分组", - description = "创建区块分组", - parameters = { - @Parameter(name = "blockGroups", description = "入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = BlockGroup.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "创建区块分组", description = "创建区块分组", parameters = { + @Parameter(name = "blockGroups", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = BlockGroup.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建区块分组") @PostMapping("/block-groups/create") public Result createBlockGroups(@Valid @RequestBody BlockGroup blockGroup) { @@ -125,22 +114,18 @@ public Result createBlockGroups(@Valid @RequestBody BlockGroup block * @param blockGroup blockGroup * @return the list */ - @Operation(summary = "修改区块分组", - description = "修改区块分组", - parameters = { - @Parameter(name = "id", description = "分组id"), - @Parameter(name = "blockGroups", description = "入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = BlockGroup.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "修改区块分组", description = "修改区块分组", parameters = { + @Parameter(name = "id", description = "分组id"), + @Parameter(name = "blockGroups", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = BlockGroup.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "修改区块分组") @PostMapping("/block-groups/update/{id}") public Result> updateBlockGroups(@Valid @PathVariable Integer id, - @RequestBody BlockGroup blockGroup) { + @RequestBody BlockGroup blockGroup) { blockGroup.setId(id); blockGroupService.updateBlockGroupById(blockGroup); // 页面返回数据显示 @@ -155,16 +140,12 @@ public Result> updateBlockGroups(@Valid @PathVariable Integer i * @return the list * @throws ServiceException serviceException */ - @Operation(summary = "根据id删除区块分组", - description = "根据id删除区块分组", - parameters = { - @Parameter(name = "id", description = "分组id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = BlockGroup.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} + @Operation(summary = "根据id删除区块分组", description = "根据id删除区块分组", parameters = { + @Parameter(name = "id", description = "分组id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = BlockGroup.class))), + @ApiResponse(responseCode = "400", description = "请求失败")} ) @SystemControllerLog(description = "根据id删除区块分组") @GetMapping("/block-groups/delete/{id}") diff --git a/base/src/main/java/com/tinyengine/it/controller/CanvasController.java b/base/src/main/java/com/tinyengine/it/controller/CanvasController.java index 1dcaed37..575cfc7e 100644 --- a/base/src/main/java/com/tinyengine/it/controller/CanvasController.java +++ b/base/src/main/java/com/tinyengine/it/controller/CanvasController.java @@ -55,22 +55,19 @@ public class CanvasController { * @param type the type * @return CanvasDto */ - @Operation(summary = "区块及页面锁", - description = "区块及页面锁", - parameters = { - @Parameter(name = "id", description = "页面id"), - @Parameter(name = "state", description = "状态"), - @Parameter(name = "type", description = "区分是页面还是区块") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")} + @Operation(summary = "区块及页面锁", description = "区块及页面锁", parameters = { + @Parameter(name = "id", description = "页面id"), + @Parameter(name = "state", description = "状态"), + @Parameter(name = "type", description = "区分是页面还是区块") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败")} ) @SystemControllerLog(description = "区块及页面锁") @GetMapping("apps/canvas/lock") - public Result lock(@RequestParam Integer id, @RequestParam String state, @RequestParam String type) { + public Result lock(@RequestParam Integer id, @RequestParam String state, + @RequestParam String type) { return canvasService.lockCanvas(id, state, type); } } diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java index 5408fa3f..833e3a44 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentController.java @@ -62,10 +62,12 @@ public class ComponentController { * @return result */ @Operation(summary = "上传bunled.json文件创建组件", description = "上传bunled.json文件创建组件", parameters = { - @Parameter(name = "file", description = "文件参数对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "file", description = "文件参数对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "上传bunled.json文件创建组件") @PostMapping("/component/bundle/create") public Result bundleCreateComponent(@RequestParam MultipartFile file) { @@ -84,10 +86,12 @@ public Result bundleCreateComponent(@RequestParam MultipartFile file * @return result */ @Operation(summary = "上传bunled.json文件处理自定义组件", description = "上传bunled.json文件处理自定义组件", parameters = { - @Parameter(name = "file", description = "文件参数对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "file", description = "文件参数对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "上传bunled.json文件处理自定义组件") @PostMapping("/component/bundle/split") public Result bundleSplit(@RequestParam MultipartFile file) { @@ -105,10 +109,12 @@ public Result bundleSplit(@RequestParam MultipartFile file) { * @return result */ @Operation(summary = "批量创建自定义组件", description = "批量创建自定义组件", parameters = { - @Parameter(name = "custComponentDto", description = "自定义组件对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "custComponentDto", description = "自定义组件对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "批量创建自定义组件") @PostMapping("/component/batch/create") public Result createCustComponent(@Valid @RequestBody CustComponentDto custComponentDto) { diff --git a/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java b/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java index eabc5237..e4d4ece1 100644 --- a/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/ComponentLibraryController.java @@ -32,9 +32,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; import java.util.List; +import javax.validation.Valid; + /** * 组件库API * @@ -56,13 +57,11 @@ public class ComponentLibraryController { * * @return ComponentLibrary信息 all componentLibrary */ - @Operation(summary = "查询表ComponentLibrary信息列表", - description = "查询表ComponentLibrary信息列表", - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = ComponentLibrary.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Operation(summary = "查询表ComponentLibrary信息列表", description = "查询表ComponentLibrary信息列表", responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = ComponentLibrary.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "查询表ComponentLibrary信息列表") @GetMapping("/component-library/list") public Result> getAllComponentLibrary() { @@ -76,17 +75,13 @@ public Result> getAllComponentLibrary() { * @param componentLibrary the componentLibrary * @return ComponentLibrary信息 result */ - @Operation(summary = "创建ComponentLibrary", - description = "创建ComponentLibrary", - parameters = { - @Parameter(name = "ComponentLibrary", description = "ComponentLibrary入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = ComponentLibrary.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "创建ComponentLibrary", description = "创建ComponentLibrary", parameters = { + @Parameter(name = "ComponentLibrary", description = "ComponentLibrary入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = ComponentLibrary.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建ComponentLibrary") @PostMapping("/component-library/create") public Result createComponentLibrary(@Valid @RequestBody ComponentLibrary componentLibrary) { @@ -101,15 +96,17 @@ public Result createComponentLibrary(@Valid @RequestBody Compo * @return ComponentLibrary信息 result */ @Operation(summary = "修改单个ComponentLibrary信息", description = "修改单个ComponentLibrary信息", parameters = { - @Parameter(name = "id", description = "appId"), - @Parameter(name = "ComponentLibrary", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = ComponentLibrary.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "appId"), + @Parameter(name = "ComponentLibrary", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = ComponentLibrary.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "修改单个ComponentLibrary信息") @PostMapping("/component-library/update/{id}") - public Result updateComponentLibrary(@PathVariable Integer id, @RequestBody ComponentLibrary componentLibrary) { + public Result updateComponentLibrary(@PathVariable Integer id, + @RequestBody ComponentLibrary componentLibrary) { componentLibrary.setId(id); return componentLibraryService.updateComponentLibraryById(componentLibrary); } @@ -120,17 +117,13 @@ public Result updateComponentLibrary(@PathVariable Integer id, * @param id the id * @return ComponentLibrary信息 result */ - @Operation(summary = "删除ComponentLibrary信息", - description = "删除ComponentLibrary信息", - parameters = { - @Parameter(name = "id", description = "ComponentLibrary主键id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = ComponentLibrary.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "删除ComponentLibrary信息", description = "删除ComponentLibrary信息", parameters = { + @Parameter(name = "id", description = "ComponentLibrary主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = ComponentLibrary.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除ComponentLibrary信息") @DeleteMapping("/component-library/delete/{id}") public Result deleteComponentLibrary(@PathVariable Integer id) { @@ -144,11 +137,12 @@ public Result deleteComponentLibrary(@PathVariable Integer id) * @return the result */ @Operation(summary = "获取ComponentLibrary信息详情", description = "获取ComponentLibrary信息详情", parameters = { - @Parameter(name = "id", description = "appId")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = ComponentLibrary.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "appId") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = ComponentLibrary.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取ComponentLibrary信息详情") @GetMapping("/component-library/detail/{id}") public Result detail(@PathVariable Integer id) { diff --git a/base/src/main/java/com/tinyengine/it/controller/DataSourceController.java b/base/src/main/java/com/tinyengine/it/controller/DataSourceController.java index 8931ac3b..7add4ddc 100644 --- a/base/src/main/java/com/tinyengine/it/controller/DataSourceController.java +++ b/base/src/main/java/com/tinyengine/it/controller/DataSourceController.java @@ -63,11 +63,12 @@ public class DataSourceController { * @return all sources */ @Operation(summary = "获取数据源列表", description = "获取数据源列表", parameters = { - @Parameter(name = "aid", description = "appId")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Datasource.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "aid", description = "appId") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Datasource.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取数据源列表") @GetMapping("/sources/list/{aid}") public Result> getAllSources(@PathVariable Integer aid) { @@ -83,11 +84,12 @@ public Result> getAllSources(@PathVariable Integer aid) { * @return sources by id */ @Operation(summary = "获取某条数据源", description = "获取某条数据源", parameters = { - @Parameter(name = "id", description = "数据源主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Datasource.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "数据源主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Datasource.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取某条数据源") @GetMapping("/sources/detail/{id}") public Result getSourcesById(@PathVariable Integer id) { @@ -102,11 +104,12 @@ public Result getSourcesById(@PathVariable Integer id) { * @return result */ @Operation(summary = "创建数据源", description = "创建数据源", parameters = { - @Parameter(name = "sources", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Datasource.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "sources", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Datasource.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建数据源") @PostMapping("/sources/create") public Result createSources(@Valid @RequestBody Datasource sources) { @@ -121,12 +124,13 @@ public Result createSources(@Valid @RequestBody Datasource sources) * @return result */ @Operation(summary = "修改数据源某条数据", description = "修改数据源某条数据", parameters = { - @Parameter(name = "id", description = "数据源主键id"), - @Parameter(name = "sources", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Datasource.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "数据源主键id"), + @Parameter(name = "sources", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Datasource.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "修改数据源某条数据") @PostMapping("/sources/update/{id}") public Result updateSources(@PathVariable Integer id, @RequestBody Datasource sources) { @@ -141,11 +145,12 @@ public Result updateSources(@PathVariable Integer id, @RequestBody D * @return result */ @Operation(summary = "删除数据源某条数据", description = "删除数据源某条数据", parameters = { - @Parameter(name = "id", description = "数据源主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Datasource.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "数据源主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Datasource.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除数据源某条数据") @GetMapping("/sources/delete/{id}") public Result deleteSources(@PathVariable Integer id) { diff --git a/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java b/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java index 2375ee98..4be56b81 100644 --- a/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/I18nEntryController.java @@ -75,9 +75,10 @@ public class I18nEntryController { * @return 获取国际化词条列表 all i 18 n entries */ @Operation(summary = "获取国际化词条列表", description = "获取国际化词条列表", responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取国际化词条列表") @GetMapping("/i18n/entries") public Result getAllI18nEntries() { @@ -92,11 +93,12 @@ public Result getAllI18nEntries() { * @return 国际化语言详情 i 18 n entries by id */ @Operation(summary = "获取国际化语言的详情", description = "获取国际化语言的详情", parameters = { - @Parameter(name = "id", description = "I18nEntries主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = I18nEntry.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "I18nEntries主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = I18nEntry.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取国际化语言的详情") @GetMapping("/i18n/entries/{id}") public Result getI18nEntriesById(@Valid @PathVariable Integer id) { @@ -111,11 +113,12 @@ public Result getI18nEntriesById(@Valid @PathVariable Integer id) * @return result */ @Operation(summary = "创建国际化多语言词条", description = "创建国际化多语言词条", parameters = { - @Parameter(name = "OperateI18nEntries", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = I18nEntry.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "OperateI18nEntries", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = I18nEntry.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建国际化多语言词条") @PostMapping("/i18n/entries/create") public Result> createI18nEntries(@Valid @RequestBody OperateI18nEntries operateI18nEntries) { @@ -131,11 +134,12 @@ public Result> createI18nEntries(@Valid @RequestBody OperateI18n * @return the result */ @Operation(summary = "批量创建国际化多语言词条", description = "批量创建国际化多语言词条", parameters = { - @Parameter(name = "operateI18nBatchEntries", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = I18nEntry.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "operateI18nBatchEntries", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = I18nEntry.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "批量创建国际化多语言词条") @PostMapping("/i18n/entries/batch/create") public Result> batchCreateEntries( @@ -153,15 +157,17 @@ public Result> batchCreateEntries( * @return the result */ @Operation(summary = "修改国际化单语言词条", description = "修改国际化单语言词条", parameters = { - @Parameter(name = "id", description = "I18nEntries主键id"), - @Parameter(name = "i18nEntries", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = I18nEntry.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "I18nEntries主键id"), + @Parameter(name = "i18nEntries", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = I18nEntry.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "修改国际化单语言词条") @PostMapping("/i18n/entries/update/{id}") - public Result updateI18nEntries(@PathVariable Integer id, @RequestBody I18nEntry i18nEntries) { + public Result updateI18nEntries(@PathVariable Integer id, + @RequestBody I18nEntry i18nEntries) { i18nEntries.setId(id); i18nEntryService.updateI18nEntryById(i18nEntries); I18nEntryDto i18nEntryDto = i18nEntryService.findI18nEntryById(id); @@ -175,11 +181,12 @@ public Result updateI18nEntries(@PathVariable Integer id, @Request * @return 修改成功信息 result */ @Operation(summary = "修改国际化多语言词条", description = "修改国际化多语言词条", parameters = { - @Parameter(name = "operateI18nEntries", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = I18nEntry.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "operateI18nEntries", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = I18nEntry.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "修改国际化多语言词条") @PostMapping("/i18n/entries/update") public Result> updateEntry(@Valid @RequestBody OperateI18nEntries operateI18nEntries) { @@ -197,11 +204,12 @@ public Result> updateEntry(@Valid @RequestBody OperateI18nEntrie * @throws ServiceException the service exception */ @Operation(summary = "删除多语言词条", description = "删除多语言词条", parameters = { - @Parameter(name = "iDeleteI18nEntry", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = I18nEntry.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "iDeleteI18nEntry", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = I18nEntry.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除多语言词条") @PostMapping("/i18n/entries/bulk/delete") public Result> deleteI18nEntries(@RequestBody DeleteI18nEntry deleteI18nEntry) @@ -220,16 +228,18 @@ public Result> deleteI18nEntries(@RequestBody DeleteI18nEntry * @throws Exception the exception */ @Operation(summary = "应用下上传单文件处理国际化词条", description = "应用下上传单文件处理国际化词条", parameters = { - @Parameter(name = "id", description = "appId"), - @Parameter(name = "filesMap", description = "文件参数对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "appId"), + @Parameter(name = "filesMap", description = "文件参数对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "应用下上传单文件处理国际化词条") @PostMapping("/apps/{id}/i18n/entries/update") public Result updateI18nSingleFile( - @PathVariable Integer id, - @RequestParam Map filesMap) throws Exception { + @PathVariable Integer id, + @RequestParam Map filesMap) throws Exception { Result result = new Result<>(); for (Map.Entry entry : filesMap.entrySet()) { @@ -253,23 +263,19 @@ public Result updateI18nSingleFile( * @return the result * @throws Exception exception */ - @Operation(summary = "应用下批量上传国际化词条文件", - description = "应用下批量上传国际化词条文件", - parameters = { - @Parameter(name = "id", description = "appId"), - @Parameter(name = "filesMap", description = "文件参数对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "应用下批量上传国际化词条文件", description = "应用下批量上传国际化词条文件", parameters = { + @Parameter(name = "id", description = "appId"), + @Parameter(name = "filesMap", description = "文件参数对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "应用下批量上传国际化词条文件") @PostMapping("/apps/{id}/i18n/entries/multiUpdate") public Result updateI18nMultiFile( - @PathVariable Integer id, - @RequestParam Map filesMap) throws Exception { + @PathVariable Integer id, + @RequestParam Map filesMap) throws Exception { Result result = new Result<>(); // 处理上传的文件 for (Map.Entry entry : filesMap.entrySet()) { diff --git a/base/src/main/java/com/tinyengine/it/controller/MaterialController.java b/base/src/main/java/com/tinyengine/it/controller/MaterialController.java index 374c9e98..cde9dc51 100644 --- a/base/src/main/java/com/tinyengine/it/controller/MaterialController.java +++ b/base/src/main/java/com/tinyengine/it/controller/MaterialController.java @@ -32,9 +32,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; import java.util.List; +import javax.validation.Valid; + + /** * 物料历史api * @@ -56,13 +58,11 @@ public class MaterialController { * * @return Material信息 all material */ - @Operation(summary = "查询表Material信息列表", - description = "查询表Material信息列表", - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Material.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Operation(summary = "查询表Material信息列表", description = "查询表Material信息列表", responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Material.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "查询表Material信息列表") @GetMapping("/material/list") public Result> getAllMaterial() { @@ -76,17 +76,13 @@ public Result> getAllMaterial() { * @param material the material * @return Material信息 result */ - @Operation(summary = "创建Material", - description = "创建Material", - parameters = { - @Parameter(name = "Material", description = "Material入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Material.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "创建Material", description = "创建Material", parameters = { + @Parameter(name = "Material", description = "Material入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Material.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建Material") @PostMapping("/material/create") public Result createMaterial(@Valid @RequestBody Material material) { @@ -101,12 +97,13 @@ public Result createMaterial(@Valid @RequestBody Material material) { * @return Material信息 result */ @Operation(summary = "修改单个Material信息", description = "修改单个Material信息", parameters = { - @Parameter(name = "id", description = "appId"), - @Parameter(name = "Material", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Material.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "appId"), + @Parameter(name = "Material", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Material.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "修改单个Material信息") @PostMapping("/material/update/{id}") public Result updateMaterial(@PathVariable Integer id, @RequestBody Material material) { @@ -120,17 +117,13 @@ public Result updateMaterial(@PathVariable Integer id, @RequestBody Ma * @param id the id * @return app信息 result */ - @Operation(summary = "删除Material信息", - description = "删除Material信息", - parameters = { - @Parameter(name = "id", description = "Material主键id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Material.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "删除Material信息", description = "删除Material信息", parameters = { + @Parameter(name = "id", description = "Material主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Material.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除Material信息") @DeleteMapping("/material/delete/{id}") public Result deleteMaterial(@PathVariable Integer id) { @@ -144,11 +137,11 @@ public Result deleteMaterial(@PathVariable Integer id) { * @return the result */ @Operation(summary = "获取Material信息详情", description = "获取Material信息详情", parameters = { - @Parameter(name = "id", description = "appId")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Material.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "appId") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Material.class))), + @ApiResponse(responseCode = "400", description = "请求失败")}) @SystemControllerLog(description = "获取Material信息详情") @GetMapping("/material/detail/{id}") public Result detail(@PathVariable Integer id) { diff --git a/base/src/main/java/com/tinyengine/it/controller/PageController.java b/base/src/main/java/com/tinyengine/it/controller/PageController.java index 92bff43c..7f8ac710 100644 --- a/base/src/main/java/com/tinyengine/it/controller/PageController.java +++ b/base/src/main/java/com/tinyengine/it/controller/PageController.java @@ -60,6 +60,9 @@ public class PageController { @Autowired private PageService pageService; + /** + * The Page history service. + */ @Autowired private PageHistoryService pageHistoryService; @@ -70,11 +73,12 @@ public class PageController { * @return allpage */ @Operation(summary = "获取页面列表", description = "获取页面列表", parameters = { - @Parameter(name = "aid", description = "appId")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Page.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "aid", description = "appId") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Page.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取页面列表") @GetMapping("/pages/list/{aid}") public Result> getAllPage(@PathVariable Integer aid) { @@ -90,11 +94,12 @@ public Result> getAllPage(@PathVariable Integer aid) { * @throws Exception the exception */ @Operation(summary = "获取页面明细", description = "获取页面明细", parameters = { - @Parameter(name = "id", description = "page主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Page.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "page主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Page.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取页面明细") @GetMapping("/pages/detail/{id}") public Result getPageById(@PathVariable Integer id) throws Exception { @@ -110,11 +115,12 @@ public Result getPageById(@PathVariable Integer id) throws Exception { * @throws Exception the exception */ @Operation(summary = "创建页面", description = "创建页面", parameters = { - @Parameter(name = "page", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Page.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "page", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Page.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建页面") @PostMapping("/pages/create") public Result createPage(@Valid @RequestBody Page page) throws Exception { @@ -134,13 +140,13 @@ public Result createPage(@Valid @RequestBody Page page) throws Exception { * @return result * @throws Exception the exception */ - @Operation(summary = "修改页面", description = "修改页面", - parameters = {@Parameter(name = "id", description = "页面主键id"), - @Parameter(name = "param", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Page.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Operation(summary = "修改页面", description = "修改页面", parameters = {@Parameter(name = "id", description = "页面主键id"), + @Parameter(name = "param", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Page.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "修改页面") @PostMapping("/pages/update/{id}") public Result updatePage(@RequestBody Page page) throws Exception { @@ -164,11 +170,12 @@ public Result updatePage(@RequestBody Page page) throws Exception { * @throws Exception the exception */ @Operation(summary = "删除页面", description = "删除页面", parameters = { - @Parameter(name = "id", description = "页面主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Page.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "页面主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Page.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除页面") @GetMapping("/pages/delete/{id}") public Result deletePage(@PathVariable Integer id) throws Exception { @@ -182,10 +189,12 @@ public Result deletePage(@PathVariable Integer id) throws Exception { * @return PreviewDto result */ @Operation(summary = "查询页面预览元数据", description = "查询页面预览元数据信息并返回", parameters = { - @Parameter(name = "PreviewParam", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "PreviewParam", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "查询页面预览元数据") @GetMapping("/preview/metadata") public Result previewData(@ModelAttribute PreviewParam previewParam) { @@ -200,10 +209,12 @@ public Result previewData(@ModelAttribute PreviewParam previewParam) * @return Integer the Integer */ @Operation(summary = "页面发布", description = "页面发布", parameters = { - @Parameter(name = "PageHistory", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", schema = @Schema())), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "PageHistory", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema())), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "页面发布") @PostMapping("/pages/deploy") public Result pageDeploy(@RequestBody PageHistory pageHistory) { diff --git a/base/src/main/java/com/tinyengine/it/controller/PageHistoryController.java b/base/src/main/java/com/tinyengine/it/controller/PageHistoryController.java index 018bbed4..0a260090 100644 --- a/base/src/main/java/com/tinyengine/it/controller/PageHistoryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/PageHistoryController.java @@ -68,11 +68,12 @@ public class PageHistoryController { * @return all page history */ @Operation(summary = "获取页面历史记录列表", description = "获取页面历史记录列表", parameters = { - @Parameter(name = "page", description = "page页面主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PageHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "page", description = "page页面主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取页面历史记录列表") @GetMapping("/pages/histories") public Result> getAllPageHistory(@RequestParam Integer page) { @@ -88,11 +89,12 @@ public Result> getAllPageHistory(@RequestParam Integer page) { * @return page history */ @Operation(summary = "获取页面历史记录列表", description = "获取页面历史记录列表", parameters = { - @Parameter(name = "page", description = "page页面主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PageHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "page", description = "page页面主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取页面历史记录列表") @PostMapping("/pages/history/published") public Result> getLatestPublishPage(@RequestBody PageQueryVo pageQueryVo) { @@ -107,11 +109,12 @@ public Result> getLatestPublishPage(@RequestBody PageQuer * @return page history by id */ @Operation(summary = "获取页面历史记录明细", description = "获取页面历史记录明细", parameters = { - @Parameter(name = "id", description = "页面历史主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PageHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "页面历史主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取页面历史记录明细") @GetMapping("/pages/histories/detail/{historyId}") public Result getPageHistoryById(@PathVariable Integer historyId) { @@ -126,11 +129,12 @@ public Result getPageHistoryById(@PathVariable Integer historyId) { * @return result */ @Operation(summary = "创建页面历史记录", description = "创建页面历史记录", parameters = { - @Parameter(name = "pageHistory", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PageHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "pageHistory", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建页面历史记录") @PostMapping("/pages/history/create") public Result createPageHistory(@Valid @RequestBody PageHistory pageHistory) { @@ -153,11 +157,12 @@ public Result createPageHistory(@Valid @RequestBody PageHistory pag * @return result */ @Operation(summary = "删除页面历史记录", description = "删除页面历史记录", parameters = { - @Parameter(name = "id", description = "页面历史主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PageHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "页面历史主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除页面历史记录") @GetMapping("/pages/histories/delete/{historyId}") public Result deletePageHistory(@PathVariable Integer historyId) { @@ -173,19 +178,19 @@ public Result deletePageHistory(@PathVariable Integer historyId) { * @param name the name * @return result */ - @Operation(summary = "根据名称查询页面历史记录", description = "根据名称查询页面历史记录", - parameters = { - @Parameter(name = "name", description = "页面名称"), - @Parameter(name = "app", description = "appId") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", + @Operation(summary = "根据名称查询页面历史记录", description = "根据名称查询页面历史记录", parameters = { + @Parameter(name = "name", description = "页面名称"), + @Parameter(name = "app", description = "appId") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "根据名称查询页面历史记录") @GetMapping("/pages/histories/find") - public Result> findPageHistory(@RequestParam("name") String name, @RequestParam Integer app) { + public Result> findPageHistory(@RequestParam("name") String name, + @RequestParam Integer app) { List pageHistoryList = pageHistoryService.findPageHistoryByName(name, app); return Result.success(pageHistoryList); } diff --git a/base/src/main/java/com/tinyengine/it/controller/PageTemplateController.java b/base/src/main/java/com/tinyengine/it/controller/PageTemplateController.java index 0603e55a..78f5cae5 100644 --- a/base/src/main/java/com/tinyengine/it/controller/PageTemplateController.java +++ b/base/src/main/java/com/tinyengine/it/controller/PageTemplateController.java @@ -51,6 +51,9 @@ @RequestMapping("/material-center/api") @Tag(name = "页面模板") public class PageTemplateController { + /** + * The Page template service. + */ @Autowired private PageTemplateService pageTemplateService; @@ -61,11 +64,12 @@ public class PageTemplateController { * @return pageTemplate信息 */ @Operation(summary = "创建页面模版", description = "创建页面模版", parameters = { - @Parameter(name = "pageTemplate", description = "页面模版参数对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PageTemplate.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "pageTemplate", description = "页面模版参数对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageTemplate.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建页面模版") @PostMapping("/page-template/create") public Result createPageTemplate(@Valid @RequestBody PageTemplate pageTemplate) { @@ -79,11 +83,12 @@ public Result createPageTemplate(@Valid @RequestBody PageTemplate * @return pageTemplate信息 */ @Operation(summary = "批量删除页面模版", description = "批量删除页面模版", parameters = { - @Parameter(name = "id", description = "页面模版多个主键ids")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PageTemplate.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "页面模版多个主键ids") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageTemplate.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "批量删除页面模版") @PostMapping("/template-basic/bulk/delete") public Result deletePageTemplate(@RequestBody List id) { @@ -97,11 +102,12 @@ public Result deletePageTemplate(@RequestBody List id) { * @return PageTemplate */ @Operation(summary = "获取页面模版信息详情", description = "获取页面模版信息详情", parameters = { - @Parameter(name = "id", description = "页面模板主键id")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PageTemplate.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "页面模板主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageTemplate.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取页面模版信息详情") @GetMapping("/template-basic/detail/{id}") public Result detail(@PathVariable Integer id) { @@ -115,19 +121,18 @@ public Result detail(@PathVariable Integer id) { * @param type name * @return PageTemplate */ - @Operation(summary = "获取页面模版信息列表", description = "获取页面模版信息列表", - parameters = { - @Parameter(name = "name", description = "模版名称"), - @Parameter(name = "type", description = "模版类型") - }, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PageTemplate.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Operation(summary = "获取页面模版信息列表", description = "获取页面模版信息列表", parameters = { + @Parameter(name = "name", description = "模版名称"), + @Parameter(name = "type", description = "模版类型") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PageTemplate.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取页面模版信息列表") @GetMapping("/template-basic/list") public Result> findAllPageTemplate(@RequestParam(required = false) String name, - @RequestParam String type) { + @RequestParam String type) { return pageTemplateService.queryAllPageTemplate(name, type); } } diff --git a/base/src/main/java/com/tinyengine/it/controller/PlatformController.java b/base/src/main/java/com/tinyengine/it/controller/PlatformController.java index 4fe4dd6d..a20b7107 100644 --- a/base/src/main/java/com/tinyengine/it/controller/PlatformController.java +++ b/base/src/main/java/com/tinyengine/it/controller/PlatformController.java @@ -32,9 +32,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; import java.util.List; +import javax.validation.Valid; + + /** * 设计器api * @@ -56,13 +58,11 @@ public class PlatformController { * * @return Platform信息 all app */ - @Operation(summary = "查询表Platform信息", - description = "查询表Platform信息", - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Platform.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Operation(summary = "查询表Platform信息", description = "查询表Platform信息", responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "查询表Platform信息") @GetMapping("/platform/list") public Result> getAllPlatform() { @@ -76,17 +76,13 @@ public Result> getAllPlatform() { * @param id the id * @return Platform信息 app by id */ - @Operation(summary = "根据id查询表Platform信息", - description = "根据id查询表Platform信息", - parameters = { - @Parameter(name = "id", description = "Platform主键id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Platform.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "根据id查询表Platform信息", description = "根据id查询表Platform信息", parameters = { + @Parameter(name = "id", description = "Platform主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "根据id查询表Platform信息") @GetMapping("/platform/{id}") public Result getPlatformById(@PathVariable Integer id) { @@ -100,17 +96,13 @@ public Result getPlatformById(@PathVariable Integer id) { * @param platform the platform * @return Platform信息 result */ - @Operation(summary = "创建platform", - description = "创建platform", - parameters = { - @Parameter(name = "platform", description = "Platform入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Platform.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "创建platform", description = "创建platform", parameters = { + @Parameter(name = "platform", description = "Platform入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建platform") @PostMapping("/platform/create") public Result createPlatform(@Valid @RequestBody Platform platform) { @@ -125,12 +117,13 @@ public Result createPlatform(@Valid @RequestBody Platform platform) { * @return Platform信息 result */ @Operation(summary = "修改单个Platform信息", description = "修改单个Platform信息", parameters = { - @Parameter(name = "id", description = "appId"), - @Parameter(name = "Platform", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Platform.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "appId"), + @Parameter(name = "Platform", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "修改单个Platform信息") @PostMapping("/platform/update/{id}") public Result updatePlatform(@PathVariable Integer id, @RequestBody Platform platform) { @@ -144,34 +137,33 @@ public Result updatePlatform(@PathVariable Integer id, @RequestBody Pl * @param id the id * @return platform信息 result */ - @Operation(summary = "删除platform信息,与js同路由", - description = "删除platform信息,与js同路由", - parameters = { - @Parameter(name = "id", description = "Platform主键id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Platform.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "删除platform信息,与js同路由", description = "删除platform信息,与js同路由", parameters = { + @Parameter(name = "id", description = "Platform主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除platform信息,与js同路由") @GetMapping("/platform/delete/{id}") public Result delete(@PathVariable Integer id) { return platformService.deletePlatformById(id); } - @Operation(summary = "删除platform信息", - description = "删除platform信息", - parameters = { - @Parameter(name = "id", description = "Platform主键id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = Platform.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + /** + * 删除Platform信息 + * + * @param id the id + * @return platform信息 result + */ + @Operation(summary = "删除platform信息", description = "删除platform信息", parameters = { + @Parameter(name = "id", description = "Platform主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = Platform.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除platform信息") @DeleteMapping("/platform/delete/{id}") public Result deletePlatform(@PathVariable Integer id) { diff --git a/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java index 96808480..f076b1c6 100644 --- a/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java +++ b/base/src/main/java/com/tinyengine/it/controller/PlatformHistoryController.java @@ -33,9 +33,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; import java.util.List; +import javax.validation.Valid; + /** * 设计器api * @@ -45,9 +46,10 @@ @RestController @RequestMapping("/platform-center/api") @Tag(name = "设计器历史") -public class PlatformHistoryController { +public class +PlatformHistoryController { /** - * The PlatformHistory service. + * The Platform history service. */ @Autowired private PlatformHistoryService platformHistoryService; @@ -57,13 +59,11 @@ public class PlatformHistoryController { * * @return PlatformHistory信息 all app */ - @Operation(summary = "查询表PlatformHistory信息", - description = "查询表PlatformHistory信息", - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PlatformHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Operation(summary = "查询表PlatformHistory信息", description = "查询表PlatformHistory信息", responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "查询表PlatformHistory信息") @GetMapping("/platform-history/list") public Result> getAllPlatformHistory() { @@ -77,17 +77,13 @@ public Result> getAllPlatformHistory() { * @param id the id * @return PlatformHistory信息 app by id */ - @Operation(summary = "根据id查询表PlatformHistory信息", - description = "根据id查询表PlatformHistory信息", - parameters = { - @Parameter(name = "id", description = "PlatformHistory主键id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PlatformHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "根据id查询表PlatformHistory信息", description = "根据id查询表PlatformHistory信息", parameters = { + @Parameter(name = "id", description = "PlatformHistory主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "根据id查询表PlatformHistory信息") @GetMapping("/platform-history/{id}") public Result getPlatformHistoryById(@PathVariable Integer id) { @@ -101,17 +97,13 @@ public Result getPlatformHistoryById(@PathVariable Integer id) * @param platformHistory the platformHistory * @return PlatformHistory信息 result */ - @Operation(summary = "创建platformHistory", - description = "创建platformHistory", - parameters = { - @Parameter(name = "platformHistory", description = "PlatformHistory入参对象") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PlatformHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "创建platformHistory", description = "创建platformHistory", parameters = { + @Parameter(name = "platformHistory", description = "PlatformHistory入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "创建platformHistory") @PostMapping("/platform-history/create") public Result createPlatformHistory(@Valid @RequestBody PlatformHistory platformHistory) { @@ -126,15 +118,17 @@ public Result createPlatformHistory(@Valid @RequestBody Platfor * @return PlatformHistory信息 result */ @Operation(summary = "修改单个PlatformHistory信息", description = "修改单个PlatformHistory信息", parameters = { - @Parameter(name = "id", description = "appId"), - @Parameter(name = "PlatformHistory", description = "入参对象")}, responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PlatformHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")}) + @Parameter(name = "id", description = "appId"), + @Parameter(name = "PlatformHistory", description = "入参对象") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "修改单个PlatformHistory信息") @PutMapping("/platform-history/update/{id}") - public Result updatePlatformHistory(@PathVariable Integer id, @RequestBody PlatformHistory platformHistory) { + public Result updatePlatformHistory(@PathVariable Integer id, + @RequestBody PlatformHistory platformHistory) { platformHistory.setId(id); return platformHistoryService.updatePlatformHistoryById(platformHistory); } @@ -145,17 +139,13 @@ public Result updatePlatformHistory(@PathVariable Integer id, @ * @param id the id * @return platformHistory信息 result */ - @Operation(summary = "删除platformHistory信息", - description = "删除platformHistory信息", - parameters = { - @Parameter(name = "id", description = "PlatformHistory主键id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PlatformHistory.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "删除platformHistory信息", description = "删除platformHistory信息", parameters = { + @Parameter(name = "id", description = "PlatformHistory主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = PlatformHistory.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "删除platformHistory信息") @DeleteMapping("/platform-history/delete/{id}") public Result deletePlatformHistory(@PathVariable Integer id) { diff --git a/base/src/main/java/com/tinyengine/it/controller/TaskRecordController.java b/base/src/main/java/com/tinyengine/it/controller/TaskRecordController.java index 9d5497c6..4100b9ac 100644 --- a/base/src/main/java/com/tinyengine/it/controller/TaskRecordController.java +++ b/base/src/main/java/com/tinyengine/it/controller/TaskRecordController.java @@ -44,6 +44,9 @@ @RequestMapping("/app-center/api") @Tag(name = "任务") public class TaskRecordController { + /** + * The Task record service. + */ @Autowired private TaskRecordService taskRecordService; @@ -53,17 +56,13 @@ public class TaskRecordController { * @param id id * @return task信息 */ - @Operation(summary = "根据id查询task信息", - description = "根据id查询task信息", - parameters = { - @Parameter(name = "id", description = "task任务主键id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = TaskRecord.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "根据id查询task信息", description = "根据id查询task信息", parameters = { + @Parameter(name = "id", description = "task任务主键id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = TaskRecord.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "根据id查询task信息") @GetMapping("/tasks/status/{id}") public Result getTaskRecordById(@PathVariable Integer id) { diff --git a/base/src/main/java/com/tinyengine/it/controller/TaskRecordMaterialController.java b/base/src/main/java/com/tinyengine/it/controller/TaskRecordMaterialController.java index 5df84e8b..edde45bf 100644 --- a/base/src/main/java/com/tinyengine/it/controller/TaskRecordMaterialController.java +++ b/base/src/main/java/com/tinyengine/it/controller/TaskRecordMaterialController.java @@ -49,6 +49,9 @@ @RequestMapping("/material-center/api") @Tag(name = "任务") public class TaskRecordMaterialController { + /** + * The Task record service. + */ @Autowired private TaskRecordService taskRecordService; @@ -58,17 +61,13 @@ public class TaskRecordMaterialController { * @param id id * @return task信息 */ - @Operation(summary = "根据id查询task信息", - description = "根据id查询task信息", - parameters = { - @Parameter(name = "id", description = "任务id") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = TaskRecord.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "根据id查询task信息", description = "根据id查询task信息", parameters = { + @Parameter(name = "id", description = "任务id") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = TaskRecord.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "根据id查询task信息api") @GetMapping("/tasks/{id}") public Result getTaskRecordById(@PathVariable Integer id) { @@ -83,21 +82,18 @@ public Result getTaskRecordById(@PathVariable Integer id) { * @param uniqueIds the unique ids * @return the result */ - @Operation(summary = "获取任务状态", - description = "获取任务状态", - parameters = { - @Parameter(name = "taskTypeId", description = "任务类型id"), - @Parameter(name = "uniqueIds", description = "uniqueIds") - }, - responses = { - @ApiResponse(responseCode = "200", description = "返回信息", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = TaskRecord.class))), - @ApiResponse(responseCode = "400", description = "请求失败")} - ) + @Operation(summary = "获取任务状态", description = "获取任务状态", parameters = { + @Parameter(name = "taskTypeId", description = "任务类型id"), + @Parameter(name = "uniqueIds", description = "uniqueIds") + }, responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = TaskRecord.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) @SystemControllerLog(description = "获取任务状态api") @GetMapping("/tasks/status") - public Result> getTasksStatus(@RequestParam String taskTypeId, @RequestParam String uniqueIds) { + public Result> getTasksStatus(@RequestParam String taskTypeId, + @RequestParam String uniqueIds) { // 使用 queries 上下文支持批量查询。若未指定 taskTypeId,则默认查询物料打包任务状态 int taskTpyeIdTemp = Integer.parseInt(taskTypeId); if (taskTpyeIdTemp == 0) { diff --git a/base/src/main/java/com/tinyengine/it/controller/UserController.java b/base/src/main/java/com/tinyengine/it/controller/UserController.java index 9da9b8db..4a312201 100644 --- a/base/src/main/java/com/tinyengine/it/controller/UserController.java +++ b/base/src/main/java/com/tinyengine/it/controller/UserController.java @@ -14,9 +14,14 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.common.context.LoginUserContext; +import com.tinyengine.it.common.log.SystemControllerLog; import com.tinyengine.it.model.entity.User; import com.tinyengine.it.service.app.UserService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; @@ -54,9 +59,21 @@ public class UserController { * * @return the result */ + @Operation(summary = "获取用户信息", description = "获取用户信息", responses = { + @ApiResponse(responseCode = "200", description = "返回信息", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "请求失败") + }) + @SystemControllerLog(description = "获取用户信息") @GetMapping("/user/me") public Result me() { - User user = userService.queryUserById(Integer.parseInt(loginUserContext.getLoginUserId())); + String loginUserId = loginUserContext.getLoginUserId(); + User user = userService.queryUserById(loginUserId); + if (user == null) { + user = new User(); + user.setId(loginUserContext.getLoginUserId()); + user.setUsername(loginUserContext.getLoginUserId()); + } return Result.success(user); } } diff --git a/base/src/main/java/com/tinyengine/it/event/PageDeleteEvent.java b/base/src/main/java/com/tinyengine/it/event/PageDeleteEvent.java new file mode 100644 index 00000000..505bbe00 --- /dev/null +++ b/base/src/main/java/com/tinyengine/it/event/PageDeleteEvent.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ + +package com.tinyengine.it.event; + +import com.tinyengine.it.model.entity.Page; +import org.springframework.context.ApplicationEvent; + +/** + * The Page delete event. + * + * @since 2025-05-20 + */ +public class PageDeleteEvent extends ApplicationEvent { + public PageDeleteEvent(Page page) { + super(page); + } +} diff --git a/base/src/main/java/com/tinyengine/it/gateway/ai/AiChatClient.java b/base/src/main/java/com/tinyengine/it/gateway/ai/AiChatClient.java index 017583ce..0433f3b2 100644 --- a/base/src/main/java/com/tinyengine/it/gateway/ai/AiChatClient.java +++ b/base/src/main/java/com/tinyengine/it/gateway/ai/AiChatClient.java @@ -42,6 +42,8 @@ public class AiChatClient { /** * Instantiates a new Ai chat client. + * @param model + * @param token */ public AiChatClient(String model, String token) { this.config = AiChatConfig.getAiChatConfig(model, token); diff --git a/base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java b/base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java index debca3cd..3ce63173 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java @@ -154,21 +154,13 @@ public interface BlockMapper extends BaseMapper { @Result(column = "occupier_by", property = "occupier", one = @One(select = "com.tinyengine.it.mapper.UserMapper.queryUserById")) }) - @Select("") + @Select("") List findBlocksReturn(@Param("notGroupDto") NotGroupDto notGroupDto); /** diff --git a/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java b/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java index 837d95e7..9ae83d0f 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/PlatformHistoryMapper.java @@ -13,7 +13,6 @@ package com.tinyengine.it.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.tinyengine.it.model.entity.Platform; import com.tinyengine.it.model.entity.PlatformHistory; import org.apache.ibatis.annotations.Param; diff --git a/base/src/main/java/com/tinyengine/it/mapper/UserMapper.java b/base/src/main/java/com/tinyengine/it/mapper/UserMapper.java index 57103f3b..086715fd 100644 --- a/base/src/main/java/com/tinyengine/it/mapper/UserMapper.java +++ b/base/src/main/java/com/tinyengine/it/mapper/UserMapper.java @@ -38,7 +38,7 @@ public interface UserMapper extends BaseMapper { * @param id the id * @return the user */ - User queryUserById(@Param("id") Integer id); + User queryUserById(@Param("id") String id); /** * 根据条件查询表t_user数据 @@ -54,7 +54,7 @@ public interface UserMapper extends BaseMapper { * @param id the id * @return the integer */ - Integer deleteUserById(@Param("id") Integer id); + Integer deleteUserById(@Param("id") String id); /** * 根据主键id更新表t_user数据 diff --git a/base/src/main/java/com/tinyengine/it/model/dto/BlockParam.java b/base/src/main/java/com/tinyengine/it/model/dto/BlockParam.java index 93b4f168..2e280744 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/BlockParam.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/BlockParam.java @@ -20,6 +20,7 @@ import com.tinyengine.it.common.handler.MapTypeHandler; import com.tinyengine.it.model.entity.BlockHistory; import com.tinyengine.it.model.entity.User; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/base/src/main/java/com/tinyengine/it/model/dto/BundleResultDto.java b/base/src/main/java/com/tinyengine/it/model/dto/BundleResultDto.java index d5237fad..30ba98da 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/BundleResultDto.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/BundleResultDto.java @@ -14,6 +14,7 @@ import com.tinyengine.it.model.entity.Component; import com.tinyengine.it.model.entity.ComponentLibrary; + import lombok.Data; import java.util.List; diff --git a/base/src/main/java/com/tinyengine/it/model/dto/CustComponentDto.java b/base/src/main/java/com/tinyengine/it/model/dto/CustComponentDto.java index dccc870e..9894a55a 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/CustComponentDto.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/CustComponentDto.java @@ -13,6 +13,7 @@ package com.tinyengine.it.model.dto; import com.tinyengine.it.model.entity.Component; + import lombok.Data; import java.util.List; diff --git a/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java b/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java index 0f8b6fec..79d35ca1 100644 --- a/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java +++ b/base/src/main/java/com/tinyengine/it/model/dto/PackagesDto.java @@ -13,6 +13,7 @@ package com.tinyengine.it.model.dto; import com.fasterxml.jackson.annotation.JsonProperty; + import lombok.Getter; import lombok.Setter; diff --git a/base/src/main/java/com/tinyengine/it/model/entity/BlockGroupBlock.java b/base/src/main/java/com/tinyengine/it/model/entity/BlockGroupBlock.java index b33e0d19..aee74387 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/BlockGroupBlock.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/BlockGroupBlock.java @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; diff --git a/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java b/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java index 1bfeab23..888fb5f0 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/PlatformHistory.java @@ -14,12 +14,12 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.tinyengine.it.common.base.BaseEntity; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; /** - * * 设计器历史表 * * @since 2025-05-09 diff --git a/base/src/main/java/com/tinyengine/it/model/entity/User.java b/base/src/main/java/com/tinyengine/it/model/entity/User.java index 7c26cade..1c664c14 100644 --- a/base/src/main/java/com/tinyengine/it/model/entity/User.java +++ b/base/src/main/java/com/tinyengine/it/model/entity/User.java @@ -12,14 +12,21 @@ package com.tinyengine.it.model.entity; +import com.baomidou.mybatisplus.annotation.FieldFill; +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 com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; import com.tinyengine.it.common.base.BaseEntity; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; +import java.time.LocalDateTime; + /** *

* 用户权限表 @@ -32,7 +39,42 @@ @Setter @TableName("t_user") @Schema(name = "User", description = "用户权限表") -public class User extends BaseEntity { +public class User { + @Schema(name = "id", description = "主键id") + @TableId(value = "id", type = IdType.AUTO) + private String id; + + @TableField(fill = FieldFill.INSERT) + @Schema(name = "createdBy", description = "创建人") + private String createdBy; + + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(name = "lastUpdatedBy", description = "最后修改人") + private String lastUpdatedBy; + + @TableField(fill = FieldFill.INSERT) + @Schema(name = "createdTime", description = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonProperty("created_at") + private LocalDateTime createdTime; + + @TableField(fill = FieldFill.INSERT_UPDATE) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Schema(name = "lastUpdatedTime", description = "更新时间") + @JsonProperty("updated_at") + private LocalDateTime lastUpdatedTime; + + @TableField(fill = FieldFill.INSERT) + @Schema(name = "tenantId", description = "租户ID") + private String tenantId; + + @TableField(fill = FieldFill.INSERT) + @Schema(name = "renterId", description = "业务租户ID") + private String renterId; + + @Schema(name = "siteId", description = "站点ID") + private String siteId; + @Schema(name = "username", description = "用户名") private String username; diff --git a/base/src/main/java/com/tinyengine/it/service/app/UserService.java b/base/src/main/java/com/tinyengine/it/service/app/UserService.java index 7f0df33e..e812d159 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/UserService.java +++ b/base/src/main/java/com/tinyengine/it/service/app/UserService.java @@ -37,7 +37,7 @@ public interface UserService { * @param id the id * @return the user */ - User queryUserById(@Param("id") Integer id); + User queryUserById(@Param("id") String id); /** * 根据条件查询表t_user信息 @@ -53,7 +53,7 @@ public interface UserService { * @param id the id * @return the integer */ - Integer deleteUserById(@Param("id") Integer id); + Integer deleteUserById(@Param("id") String id); /** * 根据主键id更新表t_user信息 diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java index dfbf3664..804257ca 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java @@ -75,29 +75,11 @@ public static int[] getStartAndEnd(String str) { @SystemServiceLog(description = "getAnswerFromAi 获取ai回答") @Override public Result> getAnswerFromAi(AiParam aiParam) { - String token = aiParam.getFoundationModel().get("token"); - if (token == null || token.isEmpty()) { - return Result.failed("The token cannot be empty"); - } - if (!Pattern.matches("^[A-Za-z0-9_.-]+$", token)) { - return Result.failed("Invalid token format"); + Result> resultData = checkParam(aiParam); + if (resultData.getData() == null) { + return resultData; } - if (aiParam.getMessages().isEmpty()) { - return Result.failed("Not passing the correct message parameter"); - } - Map foundationModel = aiParam.getFoundationModel(); - String model = aiParam.getFoundationModel().get("model"); - if (aiParam.getFoundationModel().get("model").isEmpty()) { - model = Enums.FoundationModel.GPT_35_TURBO.getValue(); - } - foundationModel.put("model", model); - aiParam.setFoundationModel(foundationModel); - Result> resultData = requestAnswerFromAi(aiParam.getMessages(), aiParam.getFoundationModel()); - // 调用接口失败时且data为null - if (!resultData.isSuccess() && resultData.getData() == null) { - return Result.failed(resultData.getCode(), resultData.getMessage()); - } Map data = resultData.getData(); if (data.isEmpty()) { return Result.failed("调用AI大模型接口未返回正确数据"); @@ -134,7 +116,7 @@ public Result> getAnswerFromAi(AiParam aiParam) { try { data = requestAnswerFromAi(aiParam.getMessages(), aiParam.getFoundationModel()).getData(); } catch (Exception e) { - throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg()); + throw new ServiceException(ExceptionEnum.CM001.getResultCode(), e.getMessage()); } choices = (List>) data.get("choices"); message = (Map) choices.get(0).get("message"); @@ -145,12 +127,41 @@ public Result> getAnswerFromAi(AiParam aiParam) { isFinish = (String) finishReason; } } - - - String replyWithoutCode = removeCode(answerContent); // 通过二方包将页面转成schema String codes = extractCode(answerContent); + Map result = buildResult(answerContent, message); + return Result.success(result); + } + + private Result> checkParam(AiParam aiParam) { + String token = aiParam.getFoundationModel().get("token"); + if (token == null || token.isEmpty()) { + return Result.failed("The token cannot be empty"); + } + if (!Pattern.matches("^[A-Za-z0-9_.-]+$", token)) { + return Result.failed("Invalid token format"); + } + + if (aiParam.getMessages().isEmpty()) { + return Result.failed("Not passing the correct message parameter"); + } + Map foundationModel = aiParam.getFoundationModel(); + String model = aiParam.getFoundationModel().get("model"); + if (aiParam.getFoundationModel().get("model").isEmpty()) { + model = Enums.FoundationModel.GPT_35_TURBO.getValue(); + } + foundationModel.put("model", model); + aiParam.setFoundationModel(foundationModel); + Result> resultData = requestAnswerFromAi(aiParam.getMessages(), aiParam.getFoundationModel()); + // 调用接口失败时且data为null + if (!resultData.isSuccess() && resultData.getData() == null) { + return Result.failed(resultData.getCode(), resultData.getMessage()); + } + return resultData; + } + private Map buildResult(String answerContent, Map message) { + String replyWithoutCode = removeCode(answerContent); Map schema = new HashMap<>(); Map result = new HashMap<>(); AiMessages aiMessagesresult = new AiMessages(); @@ -160,11 +171,11 @@ public Result> getAnswerFromAi(AiParam aiParam) { result.put("originalResponse", aiMessagesresult); result.put("replyWithoutCode", replyWithoutCode); result.put("schema", schema); - - return Result.success(result); + return result; } - private Result> requestAnswerFromAi(List messages, Map foundationModel) { + private Result> requestAnswerFromAi(List messages, + Map foundationModel) { List aiMessages = formatMessage(messages); AiParam aiParam = new AiParam(foundationModel, aiMessages); @@ -196,7 +207,6 @@ private Result> requestAnswerFromAi(List message * @return result 返回结果 */ private Result> modelResultConvet(Map response) { - // 构建返回的 Map 结构 Map resData = new HashMap<>(response); // Copy original data @@ -214,7 +224,6 @@ private Result> modelResultConvet(Map respon resData.put("choices", choices); return Result.success(resData); - } /** @@ -256,17 +265,12 @@ public String removeCode(String content) { private List formatMessage(List messages) { AiMessages defaultWords = new AiMessages(); defaultWords.setRole("user"); - defaultWords.setContent("你是一名前端开发专家,编码时遵从以下几条要求:\n" - + "###\n" - + "1. 只使用 element-ui组件库的el-button 和 el-table组件\n" + defaultWords.setContent( + "你是一名前端开发专家,编码时遵从以下几条要求:\n" + "###\n" + "1. 只使用 element-ui组件库的el-button 和 el-table组件\n" + "2. el-table表格组件的使用方式为 " + "columns的columnData表示列数据,其中用title表示列名,field表示表格数据字段; data的tableData表示表格展示的数据。 " - + "el-table标签内不得出现子元素\n" - + "3. 使用vue2技术栈\n" - + "4. 回复中只能有一个代码块\n" - + "5. 不要加任何注释\n" - + "6. el-table标签内不得出现el-table-column\n" - + "###"); + + "el-table标签内不得出现子元素\n" + "3. 使用vue2技术栈\n" + "4. 回复中只能有一个代码块\n" + + "5. 不要加任何注释\n" + "6. el-table标签内不得出现el-table-column\n" + "###"); defaultWords.setName(messages.get(0).getName()); String role = messages.get(0).getRole(); String content = messages.get(0).getContent(); diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java index 344891db..143e7d72 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/CanvasServiceImpl.java @@ -44,9 +44,13 @@ public class CanvasServiceImpl implements CanvasService { @Override public Result lockCanvas(Integer id, String state, String type) { - int occupier; + String occupier; // needTODO 先试用mock数据,后续添加登录及权限后从session获取, - User user = userMapper.queryUserById(Integer.parseInt(loginUserContext.getLoginUserId())); + User user = userMapper.queryUserById(loginUserContext.getLoginUserId()); + if(user == null) { + user = new User(); + user.setId(loginUserContext.getLoginUserId()); + } CanvasDto canvasDto = new CanvasDto(); if ("page".equals(type)) { Page page = pageMapper.queryPageById(id); @@ -55,7 +59,7 @@ public Result lockCanvas(Integer id, String state, String type) { if (isCaDoIt) { Page updatePage = new Page(); updatePage.setId(id); - updatePage.setOccupierBy(String.valueOf(user.getId())); + updatePage.setOccupierBy(user.getId()); pageMapper.updatePageById(updatePage); canvasDto.setOperate("success"); canvasDto.setOccupier(user); @@ -63,12 +67,12 @@ public Result lockCanvas(Integer id, String state, String type) { } } else { Block block = blockMapper.queryBlockById(id); - occupier = Integer.parseInt(block.getOccupierBy()); + occupier = block.getOccupierBy(); Boolean isCaDoIt = isCanDoIt(occupier, user); if (isCaDoIt) { Block updateBlock = new Block(); updateBlock.setId(id); - updateBlock.setOccupierBy(String.valueOf(user.getId())); + updateBlock.setOccupierBy(user.getId()); blockMapper.updateBlockById(updateBlock); canvasDto.setOperate("success"); canvasDto.setOccupier(user); @@ -80,7 +84,7 @@ public Result lockCanvas(Integer id, String state, String type) { return Result.success(canvasDto); } - private Boolean isCanDoIt(int occupier, User user) { - return occupier == user.getId(); + private Boolean isCanDoIt(String occupier, User user) { + return occupier == null || occupier.equals(user.getId()); } } diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/I18nEntryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/I18nEntryServiceImpl.java index 0c15e806..3e5cbfc3 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/I18nEntryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/I18nEntryServiceImpl.java @@ -66,8 +66,10 @@ @Slf4j public class I18nEntryServiceImpl implements I18nEntryService { private static final Logger logger = LoggerFactory.getLogger(I18nEntryServiceImpl.class); + @Autowired private I18nEntryMapper i18nEntryMapper; + @Autowired private I18nLangMapper i18nLangMapper; @@ -92,8 +94,8 @@ public I18nEntryListResult findAllI18nEntry() { // 格式化词条列表 SchemaI18n messages = formatEntriesList(i18nEntriesList); List i18nLangsListTemp = i18nLangsList.stream() - .map(i18nLang -> new I18nLang(i18nLang.getLang(), i18nLang.getLabel())) - .collect(Collectors.toList()); + .map(i18nLang -> new I18nLang(i18nLang.getLang(), i18nLang.getLabel())) + .collect(Collectors.toList()); i18nEntriesListResult.setI18nLangsList(i18nLangsListTemp); i18nEntriesListResult.setMessages(messages); @@ -168,8 +170,7 @@ public List fillParam(OperateI18nEntries operateI18nEntries, Map contents = operateI18nEntries.getContents(); - contents.keySet().forEach(item -> - { + contents.keySet().forEach(item -> { int lang = langsDic.get(item); if (lang != 0) { I18nEntry i18nEntries = new I18nEntry(); @@ -180,7 +181,7 @@ public List fillParam(OperateI18nEntries operateI18nEntries, Map getEntriesParam(OperateI18nBatchEntries operateI18NEntrie * 格式化词条参数 * * @param operateI18nBatchEntries the operate i 18 n batch entries - * @param i18nLangsList the 18 n langs list + * @param i18nLangsList the 18 n langs list * @return list */ @SystemServiceLog(description = "formatEntriesParam 格式化词条参数") public List formatEntriesParam(OperateI18nBatchEntries operateI18nBatchEntries, - List i18nLangsList) { + List i18nLangsList) { Map langsDic = new HashMap<>(); List i18nEntriesListResult = new ArrayList<>(); for (I18nLang i18nLangs : i18nLangsList) { @@ -283,8 +284,8 @@ public List bulkUpdateEntries(OperateI18nEntries operateI18nEntries) List i18nEntriesList = fillParam(operateI18nEntries, langsDic); // bulkCreateEntries for (I18nEntry i18Entries : i18nEntriesList) { - i18nEntryMapper.updateByEntry(i18Entries.getContent(), i18Entries.getHost(), - i18Entries.getHostType(), i18Entries.getKey(), i18Entries.getLang()); + i18nEntryMapper.updateByEntry(i18Entries.getContent(), i18Entries.getHost(), i18Entries.getHostType(), + i18Entries.getKey(), i18Entries.getLang()); } return i18nEntriesList; } @@ -321,8 +322,7 @@ public List deleteI18nEntriesByHostAndHostTypeAndKey(DeleteI18nEnt */ @SystemServiceLog(description = "readSingleFileAndBulkCreate 上传单个国际化文件") @Override - public Result readSingleFileAndBulkCreate(MultipartFile file, int host) - throws Exception { + public Result readSingleFileAndBulkCreate(MultipartFile file, int host) throws Exception { List entriesArr = new ArrayList<>(); String contentType = file.getContentType(); @@ -385,11 +385,9 @@ public Result readFilesAndbulkCreate(String lang, MultipartFile file @SystemServiceLog(description = "bulkCreateOrUpdate 批量创建或修改") public Result bulkCreateOrUpdate(List entriesArr, int host) { List entries = new ArrayList<>(); - entriesArr.forEach(entriesItem -> - { + entriesArr.forEach(entriesItem -> { Map langEntries = entriesItem.getEntries(); - langEntries.forEach((key, value) -> - { + langEntries.forEach((key, value) -> { I18nEntry i18nEntry = new I18nEntry(); i18nEntry.setKey(key); i18nEntry.setLang(entriesItem.getLang()); @@ -397,14 +395,13 @@ public Result bulkCreateOrUpdate(List entriesArr, int h i18nEntry.setHostType("app"); i18nEntry.setContent(value.toString()); entries.add(i18nEntry); - }); }); + }); // 超大量数据更新,如上传国际化文件,不返回插入或更新的词条 FileResult result = bulkInsertOrUpdate(entries); return Result.success(result); } - /** * 超大量数据更新,如上传国际化文件,不返回插入或更新的词条 * @@ -447,7 +444,7 @@ public FileResult bulkInsertOrUpdate(List entries) { public List parseZipFileStream(MultipartFile file) throws Exception { // 校验文件流合法性 Utils.validateFileStream(file, ExceptionEnum.CM314.getResultCode(), - Arrays.asList(Enums.MimeType.ZIP.getValue(), Enums.MimeType.XZIP.getValue())); + Arrays.asList(Enums.MimeType.ZIP.getValue(), Enums.MimeType.XZIP.getValue())); List entriesItems = new ArrayList<>(); // 解压ZIP文件并处理 List fileInfos = Utils.unzip(file); @@ -471,9 +468,8 @@ public List parseZip(FileInfo fileInfo) throws ServiceException { EntriesItem entriesItem = setLang(fileInfo.getName()); // 处理 JSON 内容 try { - Map jsonData = - objectMapper.readValue(fileInfo.getContent(), new TypeReference>() { - }); + Map jsonData = objectMapper.readValue(fileInfo.getContent(), + new TypeReference>() {}); entriesItem.setEntries(Utils.flat(jsonData)); } catch (JsonProcessingException e) { log.error("JSON processing error for file: " + fileInfo.getName(), e); diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/PageHistoryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/PageHistoryServiceImpl.java index 62736861..a8dcc883 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/PageHistoryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/PageHistoryServiceImpl.java @@ -109,7 +109,7 @@ public Integer createPageHistory(PageHistory pageHistory) { /** * 新增表t_page_history数据 * - * @param app the app + * @param app the app * @param name the page name * @return the List */ diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java index 3e594263..596395ef 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/PageServiceImpl.java @@ -20,6 +20,7 @@ import com.tinyengine.it.common.exception.ExceptionEnum; import com.tinyengine.it.common.exception.ServiceException; import com.tinyengine.it.common.log.SystemServiceLog; +import com.tinyengine.it.event.PageDeleteEvent; import com.tinyengine.it.mapper.AppExtensionMapper; import com.tinyengine.it.mapper.AppMapper; import com.tinyengine.it.mapper.BlockMapper; @@ -52,6 +53,8 @@ import org.apache.ibatis.annotations.Param; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -112,7 +115,6 @@ public class PageServiceImpl implements PageService { @Autowired private AppV1ServiceImpl appV1ServiceImpl; - /** * The App extension mapper. */ @@ -143,6 +145,11 @@ public class PageServiceImpl implements PageService { @Autowired(required = false) private PostSaveHook postSaveHook; + /** + * The event publisher. + */ + @Autowired + private ApplicationEventPublisher eventPublisher; /** * 通过appId查询page所有数据实现方法 * @@ -183,7 +190,7 @@ public Page queryPageById(@Param("id") Integer id) { if (pageInfo.getIsPage()) { // 这里不保证能成功获取区块的列表,没有区块或获取区块列表不成功返回 {} Map> blockAssets = blockServiceImpl.getBlockAssets(pageInfo.getPageContent(), - framework); + framework); pageInfo.setAssets(blockAssets); return addIsHome(pageInfo); } @@ -224,6 +231,7 @@ public Result delPage(Integer id) { if (result < 1) { return Result.failed(ExceptionEnum.CM001); } + eventPublisher.publishEvent(new PageDeleteEvent(pageResult)); return Result.success(pageResult); } @@ -425,7 +433,7 @@ public PreviewDto getPreviewMetaData(PreviewParam previewParam) { /** * Sets app home page. * - * @param appId the app id + * @param appId the app id * @param pageId the page id * @return the app home page */ @@ -530,7 +538,13 @@ public Result del(Integer id) { */ public Result checkDelete(Integer id) { // needTODO 从缓存中获取的user信息 - User user = userService.queryUserById(1); + User user = userService.queryUserById(loginUserContext.getLoginUserId()); + // 逻辑不对,如果没有同步用户数据,就用登录用户的 + if(user == null) { + user = new User(); + user.setId(loginUserContext.getLoginUserId()); + user.setUsername(loginUserContext.getLoginUserId()); + } Page page = pageMapper.queryPageById(id); User occupier = page.getOccupier(); @@ -548,7 +562,7 @@ public Result checkDelete(Integer id) { * 判断是否能删除 * * @param occupier the occupier - * @param user the user + * @param user the user * @return boolean */ public boolean iCanDoIt(User occupier, User user) { @@ -578,8 +592,7 @@ public boolean protectDefaultPage(Page page) { } UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("id", subPageId) - .set("is_default", false); + updateWrapper.eq("id", subPageId).set("is_default", false); int result = pageMapper.update(null, updateWrapper); if (result < 1) { @@ -595,7 +608,6 @@ public boolean protectDefaultPage(Page page) { * @return parentId the parentId */ private String getParentPage(String parentId) { - Page page = pageMapper.queryPageById(Integer.parseInt(parentId)); if (page.getIsPage() || "0".equals(page.getParentId())) { return parentId; @@ -623,7 +635,8 @@ private int getSubPage(String parentId) { for (Page page : pageList) { if (page.getIsPage() && page.getIsDefault()) { return page.getId(); // 找到默认子页面,返回其ID - } else if (!page.getIsPage()) { + } + if (!page.getIsPage()) { // 如果不是页面,递归查找子页面 int subPageId = getSubPage(String.valueOf(page.getId())); if (subPageId > 0) { @@ -638,7 +651,7 @@ private int getSubPage(String parentId) { /** * Validate is home boolean. * - * @param param the param + * @param param the param * @param pageInfo the page info * @return the boolean */ @@ -667,16 +680,16 @@ public boolean validateIsHome(Page param, Page pageInfo) { */ public Result checkUpdate(Page page) { // 获取占用着occupier - User occupier = userService.queryUserById(Integer.parseInt(page.getOccupierBy())); + // 逻辑修改 User occupier = userService.queryUserById(Integer.parseInt(page.getOccupierBy())); // 当前页面没有被锁定就请求更新页面接口,提示无权限 - if (occupier == null) { - Result.failed("Please unlock the page before editing the page"); - } + // 逻辑修改 if (occupier == null) { + // 逻辑修改 Result.failed("Please unlock the page before editing the page"); + // 逻辑修改 } // 当页面被人锁定时,如果提交update请求的人不是当前用户,提示无权限 // needTODO 从缓存中获取登录用户信息 - User user = userService.queryUserById(1); - if (!user.getId().equals(occupier.getId())) { - Result.failed("The current page is being edited by" + occupier.getUsername()); + // 逻辑修改 User user = userService.queryUserById(1); + if (!loginUserContext.getLoginUserId().equals(page.getOccupierBy())) { + Result.failed("The current page is being edited by" + page.getOccupierBy()); } pageMapper.updatePageById(page); // 修改完返回页面还是返回dto,为了下次修改每次参数属性一致 @@ -701,7 +714,7 @@ public Result verifyParentId(String parentId) { /** * 主函数 * - * @param pid the pid + * @param pid the pid * @param target the target * @return update tree */ @@ -741,8 +754,7 @@ public TreeNodeCollection getTreeNodes(TreeNodeDto treeNodeDto) { // 获取子节点的id List childrenId = getChildrenId(pids); // 收集 id depth 信息 - List dps = - childrenId.stream().map(id -> new NodeData(id, level)).collect(Collectors.toList()); + List dps = childrenId.stream().map(id -> new NodeData(id, level)).collect(Collectors.toList()); // 使用 addAll 方法将 childrenId 追加到 range collection.getRange().addAll(childrenId); collection.getData().addAll(dps); @@ -797,8 +809,7 @@ public PreviewDto getBlockPreviewMetaData(PreviewParam previewParam) { // 拼装国际化词条 List i18ns = i18nEntryMapper.findI18nEntriesByHostandHostType(previewParam.getId(), "block"); - SchemaI18n i18n = - appService.formatI18nEntrites(i18ns, Enums.I18Belongs.BLOCK.getValue(), previewParam.getId()); + SchemaI18n i18n = appService.formatI18nEntrites(i18ns, Enums.I18Belongs.BLOCK.getValue(), previewParam.getId()); List utils = extensions.get("utils"); PreviewDto previewDto = new PreviewDto(); previewDto.setDataSource(dataSource); diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/UserServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/UserServiceImpl.java index 35107b1a..d247c784 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/UserServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/UserServiceImpl.java @@ -18,7 +18,6 @@ import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -52,7 +51,7 @@ public List queryAllUser() { * @return query result */ @Override - public User queryUserById(@Param("id") Integer id) { + public User queryUserById(String id) { return userMapper.queryUserById(id); } @@ -74,7 +73,7 @@ public List queryUserByCondition(User user) { * @return execute success data number */ @Override - public Integer deleteUserById(@Param("id") Integer id) { + public Integer deleteUserById(String id) { return userMapper.deleteUserById(id); } diff --git a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java index d55fa0b0..b7f60f03 100644 --- a/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/app/impl/v1/AppV1ServiceImpl.java @@ -303,8 +303,8 @@ public MetaDto getMetaDto(Integer id) { List appExtensionList = appExtensionMapper.queryAppExtensionByCondition(appExtension); metaDto.setExtension(appExtensionList); - MaterialHistory materialHistory = - materialHistoryMapper.queryMaterialHistoryById(materialhistoryMsg.getMaterialHistoryId()); + MaterialHistory materialHistory = materialHistoryMapper.queryMaterialHistoryById( + materialhistoryMsg.getMaterialHistoryId()); metaDto.setMaterialHistory(materialHistory); List blockHistory = getBlockHistory(app, materialhistoryMsg); @@ -316,7 +316,7 @@ public MetaDto getMetaDto(Integer id) { /** * 查询区块历史信息 * - * @param app 应用信息 materialhistoryMsg 物料历史信息 + * @param app 应用信息 materialhistoryMsg 物料历史信息 * @param materialhistoryMsg materialhistoryMsg * @return 区块历史信息 */ @@ -352,7 +352,7 @@ private List getBlockHistory(App app, MaterialHistoryMsg materialh /** * 获取应用关联的区块及版本信息 * - * @param app appInfo 应用信息 + * @param app appInfo 应用信息 * @param materialHistoryId materialHistoryId * @return {Promise} 应用关联的区块版本控制信息 */ @@ -467,7 +467,7 @@ public List getSchemaComponentsTree(MetaDto metaDto) { Map data = Utils.convert(pageInfo); boolean isToLine = false; Map page = formatDataFields(data, resKeys, isToLine); - if (null != app.getHomePage()) { + if (app.getHomePage() != null) { page.put("isHome", String.valueOf(page.get("id")).equals(app.getHomePage().toString())); } Map schema; @@ -502,8 +502,8 @@ public List> getSchemaComponentsMap(MetaDto metaDto) { List componentLibraryList = componentLibraryMapper.queryAllComponentLibrary(); if (!componentLibraryList.isEmpty()) { List componentList = componentLibraryList.stream() - .flatMap(componentLibrary -> componentLibrary.getComponents().stream()) // 扁平化每个 List - .collect(Collectors.toList()); // 收集到一个新的 List + .flatMap(componentLibrary -> componentLibrary.getComponents().stream()) // 扁平化每个 List + .collect(Collectors.toList()); // 收集到一个新的 List components.addAll(componentList); } List> componentsSchema = getComponentSchema(components); @@ -511,10 +511,7 @@ public List> getSchemaComponentsMap(MetaDto metaDto) { List> componentsMap = new ArrayList<>(componentsSchema); componentsMap.addAll(blocksSchema); // 使用 Stream API 去重 - List> uniqueComponents = componentsMap.stream() - .distinct() - .collect(Collectors.toList()); - return uniqueComponents; + return componentsMap.stream().distinct().collect(Collectors.toList()); } // 将区块组装成schema数据 @@ -603,7 +600,7 @@ public Map> getSchemaExtensions(List app * @throws ServiceException the service exception */ public Map formatDataFields(Map data, List fields, boolean isToLine) - throws ServiceException { + throws ServiceException { // 将 fields 转换为 HashMap Map fieldsMap = new HashMap<>(); for (Object field : fields) { diff --git a/base/src/main/java/com/tinyengine/it/service/material/BlockService.java b/base/src/main/java/com/tinyengine/it/service/material/BlockService.java index 7d1e9e7c..49f13f45 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/BlockService.java +++ b/base/src/main/java/com/tinyengine/it/service/material/BlockService.java @@ -66,7 +66,7 @@ public interface BlockService { /** * 根据主键id更新表t_block信息 - * + * @param appId appId * @param blockParam the block param * @return the BlockDto */ diff --git a/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java b/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java index 39a8f60f..354abbd9 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java +++ b/base/src/main/java/com/tinyengine/it/service/material/ComponentService.java @@ -116,6 +116,4 @@ public interface ComponentService { * @return result the result */ Result custComponentBatchCreate(CustComponentDto custComponentDto); - - } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java index 61a4480c..dfd9650f 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockGroupServiceImpl.java @@ -46,8 +46,10 @@ public class BlockGroupServiceImpl implements BlockGroupService { @Autowired private BlockGroupMapper blockGroupMapper; + @Autowired private BlockCarriersRelationMapper blockCarriersRelationMapper; + @Autowired private BlockGroupBlockMapper blockGroupBlockMapper; @@ -72,7 +74,8 @@ public List findAllBlockGroup() { */ @Override public BlockGroup findBlockGroupById(@Param("id") Integer id) { - BlockGroup blockGroupResult = blockGroupMapper.queryBlockGroupAndBlockById(id, null, loginUserContext.getLoginUserId()); + BlockGroup blockGroupResult = blockGroupMapper.queryBlockGroupAndBlockById(id, null, + loginUserContext.getLoginUserId()); // 对查询的结果的区块赋值current_version if (blockGroupResult == null || blockGroupResult.getBlocks().isEmpty()) { return blockGroupResult; @@ -82,7 +85,8 @@ public BlockGroup findBlockGroupById(@Param("id") Integer id) { queryParam.setBlockId(block.getId()); queryParam.setHostId(id); queryParam.setHostType(Enums.BlockGroup.BLOCK_GROUP.getValue()); - List blockCarriersRelations = blockCarriersRelationMapper.queryBlockCarriersRelationByCondition(queryParam); + List blockCarriersRelations + = blockCarriersRelationMapper.queryBlockCarriersRelationByCondition(queryParam); if (blockCarriersRelations.isEmpty()) { continue; } @@ -124,8 +128,11 @@ public Integer deleteBlockGroupById(@Param("id") Integer id) { public Integer updateBlockGroupById(BlockGroup blockGroup) { // 判断是对正常的分组修改,还是在分组下添加区块操作的修改 List blockList = blockGroup.getBlocks(); - List blockGroupBlocks = blockGroupBlockMapper.findBlockGroupBlockByBlockGroupId(blockGroup.getId()); - List groupBlockIds = blockGroupBlocks.stream().map(BlockGroupBlock::getBlockId).collect(Collectors.toList()); + List blockGroupBlocks = blockGroupBlockMapper.findBlockGroupBlockByBlockGroupId( + blockGroup.getId()); + List groupBlockIds = blockGroupBlocks.stream() + .map(BlockGroupBlock::getBlockId) + .collect(Collectors.toList()); String hostType = Enums.BlockGroup.BLOCK_GROUP.getValue(); // 区块列表为空,分组下无区块 @@ -178,9 +185,9 @@ public Result createBlockGroup(BlockGroup blockGroup) { /** * 根据ids或者appId获取区块信息 * - * @param ids ids + * @param ids ids * @param appId the app id - * @param from the from + * @param from the from * @return the list */ @Override @@ -189,7 +196,9 @@ public List getBlockGroupByIdsOrAppId(List ids, Integer app List blockGroupsListResult = new ArrayList<>(); String groupCreatedBy = loginUserContext.getLoginUserId(); // 获取登录用户id String blockCreatedBy = loginUserContext.getLoginUserId(); - blockCreatedBy = (Enums.BlockGroup.BLOCK.getValue()).equals(from) ? blockCreatedBy : null; // from值为block在区块管理处增加createdBy条件 + blockCreatedBy = (Enums.BlockGroup.BLOCK.getValue()).equals(from) + ? blockCreatedBy + : null; // from值为block在区块管理处增加createdBy条件 BlockGroup blockGroup = new BlockGroup(); if (ids != null) { for (int blockgroupId : ids) { @@ -214,7 +223,8 @@ public List getBlockGroupByIdsOrAppId(List ids, Integer app queryParam.setBlockId(block.getId()); queryParam.setHostId(blockGroupTemp.getId()); queryParam.setHostType(Enums.BlockGroup.BLOCK_GROUP.getValue()); - List blockCarriersRelations = blockCarriersRelationMapper.queryBlockCarriersRelationByCondition(queryParam); + List blockCarriersRelations + = blockCarriersRelationMapper.queryBlockCarriersRelationByCondition(queryParam); if (blockCarriersRelations.isEmpty()) { continue; } @@ -230,8 +240,8 @@ public List getBlockGroupByIdsOrAppId(List ids, Integer app * 根据参数处理区块分组与区块关系 * * @param groupBlockIds the groupBlockIds - * @param paramIds the paramIds - * @param groupId the groupId + * @param paramIds the paramIds + * @param groupId the groupId * @return the result */ private Integer getBlockGroupIds(List groupBlockIds, List paramIds, Integer groupId) { @@ -248,7 +258,8 @@ private Integer getBlockGroupIds(List groupBlockIds, List para BlockGroupBlock blockGroupBlock = new BlockGroupBlock(); blockGroupBlock.setBlockId(block.getId()); blockGroupBlock.setBlockGroupId(groupId); - List blockGroupBlocks = blockGroupBlockMapper.queryBlockGroupBlockByCondition(blockGroupBlock); + List blockGroupBlocks = blockGroupBlockMapper.queryBlockGroupBlockByCondition( + blockGroupBlock); if (blockGroupBlocks.isEmpty()) { return result; } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java index 842fa819..e35e3c41 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/BlockServiceImpl.java @@ -79,20 +79,28 @@ public class BlockServiceImpl implements BlockService { @Autowired private BlockMapper blockMapper; + @Autowired private UserMapper userMapper; + @Autowired private AppMapper appMapper; + @Autowired private BlockHistoryMapper blockHistoryMapper; + @Autowired private I18nEntryService i18nEntryService; + @Autowired private I18nEntryMapper i18nEntryMapper; + @Autowired private BlockGroupMapper blockGroupMapper; + @Autowired private BlockGroupBlockMapper blockGroupBlockMapper; + @Autowired private LoginUserContext loginUserContext; @@ -118,11 +126,13 @@ public BlockDto queryBlockById(@Param("id") Integer id) { if (blockDto == null) { return blockDto; } - boolean isPublished = blockDto.getLastBuildInfo() != null - && blockDto.getLastBuildInfo().get("result") instanceof Boolean - ? (Boolean) blockDto.getLastBuildInfo().get("result") : Boolean.FALSE; + boolean isPublished = + blockDto.getLastBuildInfo() != null && blockDto.getLastBuildInfo().get("result") instanceof Boolean + ? (Boolean) blockDto.getLastBuildInfo().get("result") + : Boolean.FALSE; blockDto.setIsPublished(isPublished); - List groups = blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(), loginUserContext.getLoginUserId()); + List groups = blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(), + loginUserContext.getLoginUserId()); blockDto.setGroups(groups); return blockDto; } @@ -153,6 +163,7 @@ public Integer deleteBlockById(@Param("id") Integer id) { * 根据主键id更新表t_block数据 * * @param blockParam blockParam + * @param appId * @return blockDto */ @Override @@ -187,7 +198,8 @@ public Result updateBlockById(BlockParam blockParam, Integer appId) { } // 根据区块id获取区块所在分组 - List blockGroups = blockGroupMapper.findBlockGroupByBlockId(blocks.getId(), loginUserContext.getLoginUserId()); + List blockGroups = blockGroupMapper.findBlockGroupByBlockId(blocks.getId(), + loginUserContext.getLoginUserId()); // 删除区块与分组关系 if (blockGroups != null && !blockGroups.isEmpty()) { List blockGroupIds = blockGroups.stream().map(BlockGroup::getId).collect(Collectors.toList()); @@ -263,7 +275,7 @@ public Result createBlock(BlockParam blockParam) { * Gets block assets. * * @param pageContent the page content - * @param framework the framework + * @param framework the framework * @return the block assets */ public Map> getBlockAssets(Map pageContent, String framework) { @@ -309,7 +321,7 @@ public Map> getBlockAssets(Map pageContent, /** * Gets block info. * - * @param block the block + * @param block the block * @param framework the framework * @return the block info */ @@ -319,8 +331,8 @@ public List getBlockInfo(List block, String framework) { if (block != null && !block.isEmpty()) { // 处理 blockLabelName 为数组的情况 String labelsCondition = block.stream() - .map(name -> "label = '" + name + "'") - .collect(Collectors.joining(" OR ")); + .map(name -> "label = '" + name + "'") + .collect(Collectors.joining(" OR ")); // 添加标签条件 queryWrapper.and(wrapper -> wrapper.apply(labelsCondition)); @@ -337,7 +349,7 @@ public List getBlockInfo(List block, String framework) { * Traverse blocks. * * @param content the content - * @param block the block + * @param block the block * @throws JsonProcessingException the json processing exception */ public void traverseBlocks(String content, List block) throws JsonProcessingException { @@ -451,19 +463,20 @@ public List getNotInGroupBlocks(NotGroupDto notGroupDto) { } for (BlockDto blockDto : blocksList) { - List blockGroups = blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(), loginUserContext.getLoginUserId()); + List blockGroups = blockGroupMapper.findBlockGroupByBlockId(blockDto.getId(), + loginUserContext.getLoginUserId()); blockDto.setGroups(blockGroups); } return blocksList.stream() - .filter(item -> - { + .filter(item -> { // 过滤掉未发布的 if (item.getLastBuildInfo() == null || item.getContent() == null || item.getAssets() == null) { return false; } // 组过滤 - if (item.getGroups() != null && item.getGroups().stream() - .anyMatch(group -> group != null + if (item.getGroups() != null && item.getGroups() + .stream() + .anyMatch(group -> group != null && group.getId().equals(notGroupDto.getGroupId()))) { return false; } @@ -472,8 +485,7 @@ public List getNotInGroupBlocks(NotGroupDto notGroupDto) { return true; } return item.getPublicStatus() == Enums.Scope.PUBLIC_IN_TENANTS.getValue(); - }) - .collect(Collectors.toList()); + }).collect(Collectors.toList()); } /** @@ -579,10 +591,9 @@ public IPage findBlocksByConditionPagetion(Map request) { String description = request.get("description"); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.and(wrapper -> - wrapper.like(StringUtils.isNotEmpty(nameCn), "name", nameCn) - .or() - .like(StringUtils.isNotEmpty(description), "description", description) + queryWrapper.and(wrapper -> wrapper.like(StringUtils.isNotEmpty(nameCn), "name", nameCn) + .or() + .like(StringUtils.isNotEmpty(description), "description", description) ); List blocksList = blockMapper.selectList(queryWrapper); Page page = new Page<>(1, blocksList.size()); @@ -600,8 +611,7 @@ public List getUsers(List blocksList) { Set userSet = new HashSet<>(); // 提取 createdBy 列表中的唯一值 - blocksList.forEach(item -> - { + blocksList.forEach(item -> { if (item.getCreatedBy() != null && !userSet.contains(item.getCreatedBy())) { userSet.add(String.valueOf(item.getCreatedBy())); } @@ -656,27 +666,22 @@ public Result> listNew(String appId, String groupId) { List retBlocks = new ArrayList<>(); // 合并 personalBlocks 和 appBlocks 数组 List combinedBlocks = Stream.concat(personalBlocks.stream(), appBlocks.stream()) - .collect(Collectors.toList()); + .collect(Collectors.toList()); // 遍历合并后的数组,检查是否存在具有相同 id 的元素 - combinedBlocks.forEach(block -> - { - boolean isFind = retBlocks.stream() - .anyMatch(retBlock -> Objects.equals(retBlock.getId(), block.getId())); + combinedBlocks.forEach(block -> { + boolean isFind = retBlocks.stream().anyMatch(retBlock -> Objects.equals(retBlock.getId(), block.getId())); if (!isFind) { retBlocks.add(block); } }); // 给is_published赋值 - List result = retBlocks.stream() - .map(b -> - { - boolean isPublished = b.getLastBuildInfo() != null - && b.getLastBuildInfo().get("result") instanceof Boolean - ? (Boolean) b.getLastBuildInfo().get("result") : Boolean.FALSE; - b.setIsPublished(isPublished); - return b; - }) - .collect(Collectors.toList()); + List result = retBlocks.stream().map(b -> { + boolean isPublished = b.getLastBuildInfo() != null && b.getLastBuildInfo().get("result") instanceof Boolean + ? (Boolean) b.getLastBuildInfo().get("result") + : Boolean.FALSE; + b.setIsPublished(isPublished); + return b; + }).collect(Collectors.toList()); return Result.success(result); } @@ -715,7 +720,7 @@ public int ensureBlockId(BlockDto blockDto) { /** * 判断区块版本是否存在 * - * @param id the id + * @param id the id * @param version the version * @return the id */ @@ -733,7 +738,7 @@ public boolean isHistoryExisted(Integer id, String version) { /** * 创建构建信息 * - * @param version the id + * @param version the id * @param buildTime the buildTime * @return buildInfo the buildInfo */ diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java index 34aca33c..cea1690f 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentLibraryServiceImpl.java @@ -102,8 +102,7 @@ public Result updateComponentLibraryById(ComponentLibrary comp if (updateResult != 1) { return Result.failed(ExceptionEnum.CM008); } - Result result = this.queryComponentLibraryById(componentLibrary.getId()); - return result; + return this.queryComponentLibraryById(componentLibrary.getId()); } /** @@ -118,7 +117,6 @@ public Result createComponentLibrary(ComponentLibrary componen if (createResult != 1) { return Result.failed(ExceptionEnum.CM008); } - Result result = this.queryComponentLibraryById(componentLibrary.getId()); - return result; + return this.queryComponentLibraryById(componentLibrary.getId()); } } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java index 6f4d32a9..1ec6d595 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/ComponentServiceImpl.java @@ -36,6 +36,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.annotations.Param; +import org.checkerframework.checker.units.qual.C; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -66,7 +67,6 @@ public class ComponentServiceImpl implements ComponentService { @Autowired private ComponentLibraryMapper componentLibraryMapper; - /** * 查询表t_component所有数据 * @@ -145,7 +145,7 @@ public Result readFileAndBulkCreate(MultipartFile file) { BundleResultDto data = bundleResultDtoResult.getData(); List componentList = data.getComponentList(); List packageList = data.getPackageList(); - if (null == packageList || packageList.isEmpty()) { + if (packageList == null || packageList.isEmpty()) { return bulkCreate(componentList); } for (ComponentLibrary componentLibrary : packageList) { @@ -156,7 +156,8 @@ public Result readFileAndBulkCreate(MultipartFile file) { library.setName(componentLibrary.getName()); library.setVersion(componentLibrary.getVersion()); // 查询是否存在组件库 - List componentLibraryList = componentLibraryMapper.queryComponentLibraryByCondition(library); + List componentLibraryList = componentLibraryMapper.queryComponentLibraryByCondition( + library); int result = 0; if (!componentLibraryList.isEmpty()) { componentLibrary.setId(componentLibraryList.get(0).getId()); @@ -185,7 +186,7 @@ public Result readFileAndBulkCreate(MultipartFile file) { public Result bundleSplit(MultipartFile file) { // 检验文件 boolean isFileCheck = this.checkFile(file); - if (!isFileCheck){ + if (!isFileCheck) { return Result.failed(ExceptionEnum.CM325); } // 获取bundle.json数据 @@ -220,40 +221,7 @@ public Result parseBundle(BundleDto bundleDto) { if (components == null || components.isEmpty()) { return Result.failed(ExceptionEnum.CM009); } - List componentList = new ArrayList<>(); - for (Map comp : components) { - Component component = BeanUtil.mapToBean(comp, Component.class, true); - component.setId(null); - component.setIsDefault(true); - component.setIsOfficial(true); - component.setDevMode("proCode"); - component.setFramework(bundleDto.getFramework()); - component.setPublicStatus(1); - component.setIsTinyReserved(false); - Object schemaObject = comp.get("schema"); - if (schemaObject instanceof Map) { - component.setSchemaFragment((Map) schemaObject); - } - if (snippets == null || snippets.isEmpty()) { - componentList.add(component); - continue; - } - for (Child child : snippets) { - Snippet snippet = child.getChildren().stream() - .filter(item -> toPascalCase(comp.get("component").toString()) - .equals(toPascalCase(item.getSnippetName()))) - .findFirst() - .orElse(null); - - if (snippet != null) { - Map snippetMap = BeanUtil.beanToMap(snippet); - component.setSnippets(Arrays.asList(snippetMap)); - - component.setCategory(child.getGroup()); - } - } - componentList.add(component); - } + List componentList = buildComponentList(bundleDto,components,snippets); List> packages = bundleDto.getMaterials().getPackages(); BundleResultDto bundleList = new BundleResultDto(); @@ -288,7 +256,7 @@ public Result custComponentBatchCreate(CustComponentDto custComponen return Result.failed(ExceptionEnum.CM002); } Integer id = custComponentDto.getComponentLibraryId(); - if (null == id) { + if (id == null) { return Result.failed(ExceptionEnum.CM002); } for (Component component : componentList) { @@ -325,15 +293,15 @@ public Result bulkCreate(List componentList) { List queryComponent = findComponentByCondition(componentParam); // 查询组件库id String packageName = null; - if (null != component.getNpm() && null != component.getNpm().get("package")) { + if (component.getNpm() != null &&component.getNpm().get("package") != null) { packageName = String.valueOf(component.getNpm().get("package")); } - if (null != packageName && !packageName.isEmpty()) { + if (packageName != null && !packageName.isEmpty()) { ComponentLibrary componentLibrary = new ComponentLibrary(); componentLibrary.setPackageName(String.valueOf(component.getNpm().get("package"))); componentLibrary.setVersion(component.getVersion()); - List componentLibraryList = componentLibraryMapper - .queryComponentLibraryByCondition(componentLibrary); + List componentLibraryList = componentLibraryMapper.queryComponentLibraryByCondition( + componentLibrary); Integer componentLibraryId = null; if (!componentLibraryList.isEmpty()) { componentLibraryId = componentLibraryList.get(0).getId(); @@ -342,7 +310,6 @@ public Result bulkCreate(List componentList) { } if (queryComponent.isEmpty()) { - // 插入新记录 Integer result = createComponent(component); if (result == 1) { @@ -388,6 +355,44 @@ private String toPascalCase(String input) { return result.toString(); } + private List buildComponentList(BundleDto bundleDto, List> components, + List snippets) { + List componentList = new ArrayList<>(); + for (Map comp : components) { + Component component = BeanUtil.mapToBean(comp, Component.class, true); + component.setId(null); + component.setIsDefault(true); + component.setIsOfficial(true); + component.setDevMode("proCode"); + component.setFramework(bundleDto.getFramework()); + component.setPublicStatus(1); + component.setIsTinyReserved(false); + Object schemaObject = comp.get("schema"); + if (schemaObject instanceof Map) { + component.setSchemaFragment((Map) schemaObject); + } + if (snippets == null || snippets.isEmpty()) { + componentList.add(component); + continue; + } + for (Child child : snippets) { + Snippet snippet = child.getChildren().stream() + .filter(item -> toPascalCase(comp.get("component").toString()) + .equals(toPascalCase(item.getSnippetName()))) + .findFirst() + .orElse(null); + + if (snippet != null) { + Map snippetMap = BeanUtil.beanToMap(snippet); + component.setSnippets(Arrays.asList(snippetMap)); + + component.setCategory(child.getGroup()); + } + } + componentList.add(component); + } + return componentList; + } public boolean checkFile(MultipartFile file) { Map fileTypeMap = new HashMap<>(); fileTypeMap.put(".json", "application/json"); diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java index ee56dedb..4cac2e09 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialHistoryServiceImpl.java @@ -104,8 +104,7 @@ public Result updateMaterialHistoryById(MaterialHistory materia if (updateResult != 1) { return Result.failed(ExceptionEnum.CM008); } - Result result = this.findMaterialHistoryById(materialHistory.getId()); - return result; + return this.findMaterialHistoryById(materialHistory.getId()); } /** @@ -120,7 +119,6 @@ public Result createMaterialHistory(MaterialHistory materialHis if (createResult != 1) { return Result.failed(ExceptionEnum.CM008); } - Result result = this.findMaterialHistoryById(materialHistory.getId()); - return result; + return this.findMaterialHistoryById(materialHistory.getId()); } } diff --git a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java index 8ff669ca..640a495e 100644 --- a/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/material/impl/MaterialServiceImpl.java @@ -82,8 +82,7 @@ public Result deleteMaterialById(@Param("id") Integer id) { if (deleteResult != 1) { return Result.failed(ExceptionEnum.CM008); } - Result result = this.queryMaterialById(id); - return result; + return this.queryMaterialById(id); } @@ -99,8 +98,7 @@ public Result updateMaterialById(Material material) { if (updateResult != 1) { return Result.failed(ExceptionEnum.CM008); } - Result result = this.queryMaterialById(material.getId()); - return result; + return this.queryMaterialById(material.getId()); } /** @@ -115,7 +113,6 @@ public Result createMaterial(Material material) { if (createResult != 1) { return Result.failed(ExceptionEnum.CM008); } - Result result = this.queryMaterialById(material.getId()); - return result; + return this.queryMaterialById(material.getId()); } } diff --git a/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java b/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java index de5cc061..ef3ad33b 100644 --- a/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java +++ b/base/src/main/java/com/tinyengine/it/service/platform/PlatformHistoryService.java @@ -14,6 +14,7 @@ import com.tinyengine.it.common.base.Result; import com.tinyengine.it.model.entity.PlatformHistory; + import org.apache.ibatis.annotations.Param; import java.util.List; diff --git a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistoryServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistoryServiceImpl.java index fd24b737..f3c3f777 100644 --- a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistoryServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistoryServiceImpl.java @@ -17,7 +17,9 @@ import com.tinyengine.it.mapper.PlatformHistoryMapper; import com.tinyengine.it.model.entity.PlatformHistory; import com.tinyengine.it.service.platform.PlatformHistoryService; + import lombok.extern.slf4j.Slf4j; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java index 6046ee65..3d80bec6 100644 --- a/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java +++ b/base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformServiceImpl.java @@ -73,7 +73,7 @@ public List queryPlatformByCondition(Platform platform) { * 根据主键id删除表t_platform数据 * * @param id id - * @return Result + * @return execute success data number */ @Override public Result deletePlatformById(@Param("id") Integer id) { @@ -92,7 +92,7 @@ public Result deletePlatformById(@Param("id") Integer id) { * 根据主键id更新表t_platform数据 * * @param platform platform - * @return Result + * @return execute success data number */ @Override public Result updatePlatformById(Platform platform) { @@ -111,7 +111,7 @@ public Result updatePlatformById(Platform platform) { * 新增表t_platform数据 * * @param platform platform - * @return Result + * @return execute success data number */ @Override public Result createPlatform(Platform platform) { diff --git a/base/src/main/resources/mappers/BlockCarriersRelationMapper.xml b/base/src/main/resources/mappers/BlockCarriersRelationMapper.xml index 782c40f9..4ce19e17 100644 --- a/base/src/main/resources/mappers/BlockCarriersRelationMapper.xml +++ b/base/src/main/resources/mappers/BlockCarriersRelationMapper.xml @@ -208,7 +208,7 @@ , #{hostId} , #{blockId} , #{hostType} - , #{version}, + , #{version} , #{createdBy} , #{lastUpdatedBy} , #{createdTime} diff --git a/base/src/main/resources/mappers/BlockGroupMapper.xml b/base/src/main/resources/mappers/BlockGroupMapper.xml index 2e1d84fc..fac16f12 100644 --- a/base/src/main/resources/mappers/BlockGroupMapper.xml +++ b/base/src/main/resources/mappers/BlockGroupMapper.xml @@ -331,7 +331,6 @@ -