提交 69fd07c1 authored 作者: ww1xhqc's avatar ww1xhqc

[数据模型] 删除了魔法值!

上级 ef3ededa
package com.tykj.workflowcore.model_layer.myEnum;
/**
* @ClassName ModelType
* @Description TODO
* @Author WWW
* @Date 2021/3/26 14:41
* @Version 1.0
*/
public class ModelType {
public static final Integer BASICS = 0;
public static final Integer BUSINESS = 1;
public static final Integer BASICS_EXTENSION = 2;
}
......@@ -91,8 +91,9 @@ public interface ModelService {
/**
* 更新
* 修改
* @param updateTableInfoVO
* @return
*/
@CachePut(cacheNames = "tableInfos")
int updateTable(UpdateTableInfoVO updateTableInfoVO);
......
......@@ -2,14 +2,13 @@ package com.tykj.workflowcore.model_layer.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.workflowcore.base.result.ResultObj;
import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan;
import com.tykj.workflowcore.model_layer.dao.ColumnInfoDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import com.tykj.workflowcore.model_layer.entity.TableInfo;
import com.tykj.workflowcore.model_layer.entity.vo.*;
import com.tykj.workflowcore.model_layer.entity.*;
import com.tykj.workflowcore.model_layer.myEnum.ModelType;
import com.tykj.workflowcore.model_layer.service.ModelService;
import com.tykj.workflowcore.model_layer.utils.CreateTableUtil;
import com.tykj.workflowcore.model_layer.utils.SqlUtil;
......@@ -126,11 +125,11 @@ public class ModelImpl implements ModelService {
Integer modelType = tableVO.getModelType();
String parentTable = null;
//扫描新建类型
if (modelType == 2) {
if (modelType.equals(ModelType.BASICS_EXTENSION)) {
parentTable = tableVO.getParentTable();
tableVO.setModelType(2);
tableVO.setModelType(ModelType.BASICS_EXTENSION);
} else {
tableVO.setModelType(1);
tableVO.setModelType(ModelType.BUSINESS);
}
CreateTableUtil creatTableUtil = new CreateTableUtil();
......@@ -176,8 +175,8 @@ public class ModelImpl implements ModelService {
for (String tableName :
map.keySet()) {
//查找对应的表
Specification spec = (Specification) (root, criteriaQuery, criteriaBuilder) -> {
Predicate equal = null;
Specification spec = (root, criteriaQuery, criteriaBuilder) -> {
Predicate equal;
Path name = root.get("modelName");
equal = criteriaBuilder.equal(name, tableName);
return equal;
......@@ -188,7 +187,7 @@ public class ModelImpl implements ModelService {
tableInfo = (TableInfo) one.get();
}
Integer modelType = tableInfo.getModelType();
if (modelType==1){
if (modelType.equals(ModelType.BUSINESS)){
Object values = map.get(tableName);
if (values instanceof Map) {
//插入数据
......@@ -324,7 +323,7 @@ public class ModelImpl implements ModelService {
tableInfo.setModelName(tableVO.getModelName());
tableInfo.setModelTitle(tableVO.getModelTitle());
tableInfo.setXml(xml);
tableInfo.setModelType(0);
tableInfo.setModelType(ModelType.BASICS);
//判断是否存在
if (checkRepeat(realName)) {
tableInfo = tableInfoDao.save(tableInfo);
......@@ -414,7 +413,7 @@ public class ModelImpl implements ModelService {
Integer dbId = updateTableInfoVO.getDbId();
TableInfo tableInfo = tableInfoDao.findById(dbId).orElseThrow(() -> new RuntimeException("未找到该id的表信息"));
Integer modelType = tableInfo.getModelType();
if (modelType==1){
if (modelType.equals(ModelType.BUSINESS)){
tableInfo.setUpdatedTime(new Date());
tableInfo.setDescription(tableVO.getDescription());
......@@ -557,7 +556,7 @@ public class ModelImpl implements ModelService {
if (byId.isPresent()) {
TableInfo tableInfo = byId.get();
Integer modelType = tableInfo.getModelType();
if (modelType == 1) {
if (modelType.equals(ModelType.BUSINESS) ) {
tableInfoDao.delete(tableInfo);
List<ColumnInfo> allByDbId = columnInfoDao.findAllByDbId(delTableVO.getId());
columnInfoDao.deleteInBatch(allByDbId);
......
......@@ -3,6 +3,7 @@ package com.tykj.workflowcore;
import com.tykj.workflowcore.model_layer.controller.ModelController;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import com.tykj.workflowcore.model_layer.myEnum.ModelType;
import com.tykj.workflowcore.model_layer.service.ModelService;
import org.aspectj.lang.annotation.Before;
import org.junit.jupiter.api.Test;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论