提交 bd6db46d authored 作者: ww1xhqc's avatar ww1xhqc

[数据模型] 优化细节,增加一个方法

上级 195dab58
...@@ -5,6 +5,8 @@ import com.tykj.workflowcore.model_layer.entity.ColumnInfo; ...@@ -5,6 +5,8 @@ import com.tykj.workflowcore.model_layer.entity.ColumnInfo;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/** /**
* @ClassName ColumnInfoDao * @ClassName ColumnInfoDao
* @Description TODO * @Description TODO
...@@ -12,5 +14,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; ...@@ -12,5 +14,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @Date 2021/2/24 11:22 * @Date 2021/2/24 11:22
* @Version 1.0 * @Version 1.0
*/ */
public interface ColumnInfoDao extends JpaRepository<ColumnInfo,Integer>, JpaSpecificationExecutor<ColumnInfo> { public interface ColumnInfoDao extends JpaRepository<ColumnInfo, Integer>, JpaSpecificationExecutor<ColumnInfo> {
/**
* 根据dbId查询所有
* @param id
* @return
*/
List<ColumnInfo> findAllByDbId(int id);
} }
...@@ -23,7 +23,6 @@ import java.io.Serializable; ...@@ -23,7 +23,6 @@ import java.io.Serializable;
*/ */
@WorkFlowCoreNoScan @WorkFlowCoreNoScan
@Data @Data
@AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Entity @Entity
...@@ -40,9 +39,6 @@ public class ColumnInfo extends BaseEntity { ...@@ -40,9 +39,6 @@ public class ColumnInfo extends BaseEntity {
@ApiModelProperty("列名") @ApiModelProperty("列名")
private String fieldName; private String fieldName;
@ApiModelProperty("修改后的新列名")
private String newFieldName;
@ApiModelProperty("列名中文描述") @ApiModelProperty("列名中文描述")
private String fieldTitle; private String fieldTitle;
@ApiModelProperty("列类型") @ApiModelProperty("列类型")
......
...@@ -238,16 +238,12 @@ public class ModelImpl implements ModelService { ...@@ -238,16 +238,12 @@ public class ModelImpl implements ModelService {
map.put(propertyNames[i], value); map.put(propertyNames[i], value);
} }
} }
// newSession.save(tableName,map); newSession.save(tableName,map);
newSession.merge(tableName, map);
// newSession.flush();
newSession.close(); newSession.close();
} }
/** /**
* 扫描表 * 扫描表
*
* @param classList * @param classList
*/ */
@Override @Override
...@@ -400,10 +396,14 @@ public class ModelImpl implements ModelService { ...@@ -400,10 +396,14 @@ public class ModelImpl implements ModelService {
public void updateTable(UpdateTableInfoVO updateTableInfoVO) { public void updateTable(UpdateTableInfoVO updateTableInfoVO) {
//tableInfo和columnInfo变化 //tableInfo和columnInfo变化
//查询到TableInfo和ColumnInfo //查询到TableInfo和ColumnInfo
TableVO tableVO = updateTableInfoVO.getTableVO();
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的表信息"));
tableInfo.setUpdatedTime(new Date()); tableInfo.setUpdatedTime(new Date());
TableVO tableVO = updateTableInfoVO.getTableVO();
tableInfo.setDescription(tableVO.getDescription());
tableInfo.setModelTitle(tableVO.getModelTitle());
tableInfo.setModelType(tableVO.getModelType());
String xml = createTable(tableVO); String xml = createTable(tableVO);
//重新存xml //重新存xml
tableInfo.setXml(xml); tableInfo.setXml(xml);
...@@ -455,6 +455,7 @@ public class ModelImpl implements ModelService { ...@@ -455,6 +455,7 @@ public class ModelImpl implements ModelService {
columnInfo.setFieldLength(columnVO.getFieldLength()); columnInfo.setFieldLength(columnVO.getFieldLength());
columnInfo.setFieldTitle(columnVO.getFieldTitle()); columnInfo.setFieldTitle(columnVO.getFieldTitle());
columnInfo.setFieldLength(columnVO.getFieldLength()); columnInfo.setFieldLength(columnVO.getFieldLength());
columnInfo.setDescription(columnVO.getDescription());
columnInfo.setDbId(dbId); columnInfo.setDbId(dbId);
columnInfo.setDbName(dbName); columnInfo.setDbName(dbName);
return columnInfo; return columnInfo;
...@@ -539,6 +540,7 @@ public class ModelImpl implements ModelService { ...@@ -539,6 +540,7 @@ public class ModelImpl implements ModelService {
tableInfoDao.delete(byId.get()); tableInfoDao.delete(byId.get());
List<ColumnInfo> allByDbId = columnInfoDao.findAllByDbId(delTableVO.getId()); List<ColumnInfo> allByDbId = columnInfoDao.findAllByDbId(delTableVO.getId());
columnInfoDao.deleteInBatch(allByDbId); columnInfoDao.deleteInBatch(allByDbId);
jdbcTemplate.execute("truncate table " + delTableVO.getDbName()); jdbcTemplate.execute("truncate table " + delTableVO.getDbName());
} else { } else {
new RuntimeException("未找到该id的表信息"); new RuntimeException("未找到该id的表信息");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论