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