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

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

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