提交 8a90de77 authored 作者: HASEE's avatar HASEE

model layer 优化(2) 填补swagger文档

上级 ba353842
package com.tykj.workflowcore.model_layer.controller;
import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.model_layer.model.ColumnInfo;
import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.model_layer.model.TableVO;
import com.tykj.workflowcore.model_layer.service.ModelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -23,21 +27,22 @@ import java.util.Map;
*/
@RestController
@RequestMapping("/model")
@Api("数据模型层接口")
public class ModelController {
@Autowired
private ModelService modelService;
@Autowired
private ClassLoader classLoader;
/**
* @Author WWW
* @Description 得到所有数据库信息
* @Date 16:19 2021/3/4
* @param
* @return java.util.List<com.tykj.workflowcore.model_layer.model.TableInfo>
**/
/**
* @param
* @return java.util.List<com.tykj.workflowcore.model_layer.model.TableInfo>
* @Author WWW
* @Description 得到所有数据库信息
* @Date 16:19 2021/3/4
**/
@ApiOperation("得到所有数据表信息")
@RequestMapping("/getAllEntity")
public List<TableInfo> getAllEntity() {
public ResponseEntity getAllEntity() {
List<TableInfo> tableInfos = null;
try {
......@@ -46,62 +51,63 @@ public class ModelController {
throwables.printStackTrace();
}
return tableInfos;
return ResultUtil.success(tableInfos);
}
/**
* @Author WWW
* @Description 根据表名得到所有字段名
* @Date 16:20 2021/3/4
* @param tableName
* @return java.util.List<com.tykj.workflowcore.model_layer.model.ColumnInfo>
**/
/**
* @param tableName
* @return java.util.List<com.tykj.workflowcore.model_layer.model.ColumnInfo>
* @Author WWW
* @Description 根据表名得到所有字段名
* @Date 16:20 2021/3/4
**/
@ApiOperation("根据表名获得表所有字段")
@GetMapping("/getAllField")
public List<ColumnInfo> getFields(String tableName) {
if (tableName!=null&&tableName!=""){
return modelService.showModelFields(tableName);
public ResponseEntity getFields(String tableName) {
if (tableName != null && tableName != "") {
return ResultUtil.failed("没有表名");
}
return null;
return ResultUtil.success(modelService.showModelFields(tableName));
}
/**
* @Author WWW
* @Description 新增数据模型
* @Date 16:21 2021/3/4
* @param
* @return org.springframework.http.ResponseEntity
**/
/**
* @param
* @return org.springframework.http.ResponseEntity
* @Author WWW
* @Description 新增数据模型
* @Date 16:21 2021/3/4
**/
@ApiOperation("新增数据模型")
@PostMapping("/addModel")
//入参使用VO直接接收即可
//jsonStr -> TableVo
public ResponseEntity addModel(@RequestBody TableVO tableVO) throws Exception {
List<TableInfo> tableInfos = modelService.ListAllEntities();
for (TableInfo tableInfo : tableInfos) {
if (tableVO.getModelName().equals(tableInfo.getName())){
return new ResponseEntity(HttpStatus.BAD_GATEWAY);
if (tableVO.getModelName().equals(tableInfo.getName())) {
return ResultUtil.failed("表已经存在!");
}
}
modelService.NewTable(tableVO);
return new ResponseEntity(HttpStatus.OK);
return ResultUtil.success("新建成功");
}
/**
* @Author WWW
* @Description 对应表插入数据
* @param map
* @return int
* @Author WWW
* @Description 对应表插入数据
* map (表名,字段数据)
* @Date 16:22 2021/3/4
* @param map
* @return int
**/
* @Date 16:22 2021/3/4
**/
@ApiOperation(value = "根据表名表插入数据")
@PostMapping("/insertValues")
public int insertValues(@RequestBody Map<String,Object> map){
int i = modelService.putValueByEntityName(map);
return i;
public ResponseEntity insertValues(@RequestBody Map<String, Object> map) {
modelService.putValueByEntityName(map);
return ResultUtil.success("数据插入成功");
}
@GetMapping("/getPackge")
public String testPack(){
String name = this.getClass().getPackage().getName();
return name;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论