Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/src/main/resources/sql/h2/create_model_ddl_2025_0717.sql
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 '更新时间',
`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 = '模型表';
3 changes: 0 additions & 3 deletions app/src/main/resources/sql/h2/update_all_tables_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ 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;

ALTER TABLE t_component_library ADD app_id int NULL;

21 changes: 21 additions & 0 deletions app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql
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 '更新时间',
`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 = '模型表';
144 changes: 144 additions & 0 deletions base/src/main/java/com/tinyengine/it/common/enums/Enums.java
Original file line number Diff line number Diff line change
Expand Up @@ -1003,4 +1003,148 @@ public String getValue() {
return value;
}
}

public enum methodName {

/**
* CREATED name.
*/
CREATED("新增方法"),

/**
* UPDATE name.
*/
UPDATE("修改方法"),

/**
* DELETE name.
*/
DELETE("删除方法"),

/**
* QUERY name.
*/
QUERY("查询方法");

private final String value;

methodName(String value) {
this.value = value;
}

/**
* Gets value.
*
* @return the value
*/
public String getValue() {
return value;
}
}

public enum paramType {

/**
* TYPE name.
*/
OBJECT("Object"),

/**
* CREATED name.
*/
NUMBER("Number"),

/**
* UPDATE name.
*/
STRING("String"),

/**
* DELETE name.
*/
ARRAY("Array");

private final String value;

paramType(String value) {
this.value = value;
}

/**
* Gets value.
*
* @return the value
*/
public String getValue() {
return value;
}
}

public enum methodParam {

/**
* ID
*/
ID("id"),
/**
* CURRENTPAGE
*/
CURRENTPAGE("currentPage"),

/**
* PAGESIZE
*/
PAGESIZE("pageSize"),

/**
* NAMECN
*/
NAMECN("nameCn"),

/**
* NAMEEN
*/
NAMEEN("nameEn"),

/**
* PARAMS
*/
PARAMS("params"),

/**
* CODE
*/
CODE("code"),

/**
* MESSAGE
*/
MESSAGE("message"),

/**
* DATA
*/
DATA("data"),

/**
* TOTAL
*/
TOTAL("total");


private final String value;

methodParam(String value) {
this.value = value;
}

/**
* Gets value.
*
* @return the value
*/
public String getValue() {
return value;
}
}
}
182 changes: 182 additions & 0 deletions base/src/main/java/com/tinyengine/it/controller/ModelController.java
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);
}

/**
* 根据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);
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);
}
}
Loading
Loading