-
Notifications
You must be signed in to change notification settings - Fork 83
feat: Add model API #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Add model API #249
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b5b0a8b
feat: Add model API
lu-yg 3c911df
Merge branch 'opentiny:develop' into feat/model
lu-yg bba181a
feat: Model add query method
lu-yg a88c460
feat: Model add query method
lu-yg f06b026
feat: fix model query method
lu-yg 6b4c674
feat: fix model create method
lu-yg b4a515b
feat: fix model create method
lu-yg 775ba73
feat: fix parametersDto
lu-yg 687280e
feat: fix parametersDto
lu-yg 85bc921
feat: fix model API
lu-yg 1e12c13
feat: fix model API
lu-yg 216177b
feat: fix model API
lu-yg b6ae13e
feat: fix model API
lu-yg ee3ae16
feat: fix model API
lu-yg da990da
feat: fix model API
lu-yg 293a2ef
Merge branch 'opentiny:develop' into feat/model
lu-yg 5afe453
Merge branch 'opentiny:develop' into feat/model
lu-yg dbd88d6
fix: ParametersDto adds new field
lu-yg 7b1230c
fix: model adds new field
lu-yg b78d2f2
fix: model adds new field
lu-yg bf0c9d7
feat: add model API
lu-yg e274fee
fix: modify model API
lu-yg 3051698
fix: modify model API
lu-yg fd35bbe
fix: modify model API
lu-yg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
app/src/main/resources/sql/h2/create_model_ddl_2025_0717.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| drop table if exists `t_model`; | ||
|
|
||
| create table `t_model` | ||
| ( | ||
| `id` int not null auto_increment comment '主键id', | ||
| `name_cn` varchar(255) comment '中文名称', | ||
| `name_en` varchar(255) comment '英文名称', | ||
| `version` varchar(255) comment '版本', | ||
| `parameters` varchar(2000) not null comment '字段参数', | ||
| `method` longtext comment '方法', | ||
| `description` varchar(2000) comment '描述', | ||
| `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 '更新时间', | ||
lu-yg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `tenant_id` varchar(60) comment '租户id', | ||
| `renter_id` varchar(60) comment '业务租户id', | ||
| `site_id` varchar(60) comment '站点id,设计预留字段', | ||
| primary key (`id`) using btree, | ||
| unique index `u_idx_model` (`name_cn`,`version`) using btree | ||
lu-yg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) engine = innodb comment = '模型表'; | ||
lu-yg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| drop table if exists `t_model`; | ||
|
|
||
| create table `t_model` | ||
| ( | ||
| `id` int not null auto_increment comment '主键id', | ||
| `name_cn` varchar(255) comment '中文名称', | ||
| `name_en` varchar(255) comment '英文名称', | ||
| `version` varchar(255) comment '版本', | ||
| `parameters` varchar(2000) not null comment '字段参数', | ||
| `method` longtext comment '方法', | ||
| `description` varchar(2000) comment '描述', | ||
| `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 '更新时间', | ||
lu-yg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `tenant_id` varchar(60) comment '租户id', | ||
| `renter_id` varchar(60) comment '业务租户id', | ||
| `site_id` varchar(60) comment '站点id,设计预留字段', | ||
| primary key (`id`) using btree, | ||
| unique index `u_idx_model` (`name_cn`,`version`) using btree | ||
| ) engine = innodb comment = '模型表'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
182 changes: 182 additions & 0 deletions
182
base/src/main/java/com/tinyengine/it/controller/ModelController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| /** | ||
| * 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.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| import com.tinyengine.it.common.base.Result; | ||
| import com.tinyengine.it.common.log.SystemControllerLog; | ||
| import com.tinyengine.it.model.entity.Model; | ||
| import com.tinyengine.it.service.material.ModelService; | ||
| 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 jakarta.validation.Valid; | ||
| 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; | ||
| 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.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * 模型 | ||
| * | ||
| * @since 2025-07-17 | ||
| */ | ||
| @Validated | ||
| @RestController | ||
| @RequestMapping("/material-center/api") | ||
| @Tag(name = "模型") | ||
| public class ModelController { | ||
| /** | ||
| * The Model service. | ||
| */ | ||
| @Autowired | ||
| private ModelService modelService; | ||
|
|
||
| /** | ||
| * 查询表Model信息 | ||
| * | ||
| * @return all Model信息 | ||
| */ | ||
| @Operation(summary = "查询表Model信息列表", description = "查询表Model信息列表", parameters = { | ||
| @Parameter(name = "currentPage", description = "当前页"), | ||
| @Parameter(name = "pageSize", description = "页数"), | ||
| @Parameter(name = "nameCn", description = "模型中文名称"), | ||
| @Parameter(name = "nameEn", description = "模型英文名称") | ||
| }, responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", | ||
| content = @Content(mediaType = "application/json", schema = @Schema(implementation = Model.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败") | ||
| }) | ||
| @SystemControllerLog(description = "查询表Model信息列表") | ||
| @GetMapping("/model/list") | ||
| public Result<Page<Model>> getAllModel(@RequestParam(value = "currentPage", required = false) Integer currentPage, | ||
| @RequestParam(value = "pageSize", required = false) Integer pageSize, | ||
| @RequestParam(value = "nameCn", required = false) String nameCn, | ||
| @RequestParam(value = "nameEn", required = false) String nameEn) { | ||
| Page<Model> modelPage = modelService.pageQuery(currentPage, pageSize, nameCn, nameEn); | ||
| return Result.success(modelPage); | ||
| } | ||
lu-yg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * 根据name查询表Model信息 | ||
| * | ||
| * @return Model信息 | ||
| */ | ||
| @Operation(summary = "根据name查询表Model信息", description = "根据name查询表Model信息", parameters = { | ||
| @Parameter(name = "name", description = "名称"), | ||
| }, responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", | ||
| content = @Content(mediaType = "application/json", schema = @Schema(implementation = Model.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败") | ||
| }) | ||
| @SystemControllerLog(description = "根据name查询表Model信息") | ||
| @GetMapping("/model/find") | ||
| public Result<List<Model>> getModelByName(@RequestParam(value = "nameCn", required = false) String nameCn) { | ||
| List<Model> modelPage = modelService.getModelByName(nameCn); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return Result.success(modelPage); | ||
| } | ||
|
|
||
| /** | ||
| * 创建Model | ||
| * | ||
| * @param model the model | ||
| * @return Model信息 result | ||
| */ | ||
| @Operation(summary = "创建Model", description = "创建Model", parameters = { | ||
| @Parameter(name = "Model", description = "Model入参对象") | ||
| }, responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", content = @Content(mediaType = "application/json", | ||
| schema = @Schema(implementation = Model.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败") | ||
| }) | ||
| @SystemControllerLog(description = "创建Model") | ||
| @PostMapping("/model/create") | ||
| public Result<Model> createModel(@Valid @RequestBody Model model) { | ||
| Model result = modelService.createModel(model); | ||
| return Result.success(result); | ||
| } | ||
|
|
||
| /** | ||
| * 修改Model信息 | ||
| * | ||
| * @param id the id | ||
| * @param model the model | ||
| * @return Model信息 result | ||
| */ | ||
| @Operation(summary = "修改单个Model信息", description = "修改单个Model信息", parameters = { | ||
| @Parameter(name = "id", description = "appId"), | ||
| @Parameter(name = "Model", description = "入参对象") | ||
| }, responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", | ||
| content = @Content(mediaType = "application/json", schema = @Schema(implementation = Model.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败") | ||
| }) | ||
| @SystemControllerLog(description = "修改单个Model信息") | ||
| @PutMapping("/model/update/{id}") | ||
| public Result<Model> updateModel(@PathVariable Integer id, @RequestBody Model model) { | ||
| model.setId(id); | ||
| Model result = modelService.updateModelById(model); | ||
| return Result.success(result); | ||
| } | ||
|
|
||
| /** | ||
| * 删除Model信息 | ||
| * | ||
| * @param id the id | ||
| * @return app信息 result | ||
| */ | ||
| @Operation(summary = "删除Model信息", description = "删除Model信息", parameters = { | ||
| @Parameter(name = "id", description = "Model主键id") | ||
| }, responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", | ||
| content = @Content(mediaType = "application/json", schema = @Schema(implementation = Model.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败") | ||
| }) | ||
| @SystemControllerLog(description = "删除Model信息") | ||
| @DeleteMapping("/model/delete/{id}") | ||
| public Result<Model> deleteModel(@PathVariable Integer id) { | ||
| Model result = modelService.deleteModelById(id); | ||
| return Result.success(result); | ||
| } | ||
|
|
||
| /** | ||
| * 获取Model信息详情 | ||
| * | ||
| * @param id the id | ||
| * @return the result | ||
| */ | ||
| @Operation(summary = "获取Model信息详情", description = "获取Model信息详情", parameters = { | ||
| @Parameter(name = "id", description = "appId") | ||
| }, responses = { | ||
| @ApiResponse(responseCode = "200", description = "返回信息", | ||
| content = @Content(mediaType = "application/json", schema = @Schema(implementation = Model.class))), | ||
| @ApiResponse(responseCode = "400", description = "请求失败")}) | ||
| @SystemControllerLog(description = "获取Model信息详情") | ||
| @GetMapping("/model/detail/{id}") | ||
| public Result<Model> detail(@PathVariable Integer id) { | ||
| Model result = modelService.queryModelById(id); | ||
| return Result.success(result); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.