提交 6186bd96 authored 作者: 黄承天's avatar 黄承天

[模型模块]根据processKey查询接口 添加了Column属性

上级 450de053
......@@ -31,7 +31,7 @@ public class TableInfoExController {
@ApiOperation(value = "修改聚合模型")
@PutMapping
public ResponseEntity update(@RequestBody TableInfoEx tableInfoEx) {
tableInfoExService.update(tableInfoEx);
tableInfoExService. update(tableInfoEx);
return ResponseEntity.ok(ImmutableMap.of("message","修改成功"));
}
......
......@@ -36,13 +36,17 @@ public class Bind {
@ApiModelProperty(value = "是否为复数 true/false", position = 5)
private Boolean isComplex;
@ApiModelProperty(value = "字段信息", readOnly = true, position = 7)
@Transient
private List<ColumnInfo> columnInfos;
@JsonIgnore
private Integer tableInfoExId;
@JsonIgnore
private Integer parentId;
@ApiModelProperty(value = "下级基础对象的绑定信息", position = 4)
@ApiModelProperty(value = "下级基础对象的绑定信息", position = 8)
@Transient
private List<Bind> children;
......
......@@ -3,6 +3,7 @@ package com.tykj.workflowcore.model.repository;
import com.tykj.workflowcore.model.entity.Bind;
import org.springframework.data.jpa.repository.JpaRepository;
import javax.transaction.Transactional;
import java.util.List;
public interface BindRepository extends JpaRepository<Bind, Integer> {
......@@ -13,5 +14,9 @@ public interface BindRepository extends JpaRepository<Bind, Integer> {
List<Bind> findByName(String name);
void deleteByTableInfoExId(Integer tableInfoExId);
@Transactional
void deleteAllByTableInfoExId(Integer tableInfoExId);
boolean existsByName(String name);
}
......@@ -3,12 +3,14 @@ package com.tykj.workflowcore.model.repository;
import com.tykj.workflowcore.model.entity.ColumnInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import javax.transaction.Transactional;
import java.util.List;
public interface ColumnInfoRepository extends JpaRepository<ColumnInfo, Integer> {
List<ColumnInfo> findByTableInfoId(Integer tableInfoId);
@Transactional
void deleteAllByTableInfoId(Integer tableInfoId);
}
......@@ -3,12 +3,14 @@ package com.tykj.workflowcore.model.repository;
import com.tykj.workflowcore.model.entity.Quote;
import org.springframework.data.jpa.repository.JpaRepository;
import javax.transaction.Transactional;
import java.util.List;
public interface QuoteRepository extends JpaRepository<Quote, Integer> {
List<Quote> findByColumnInfoId(Integer columnInfoId);
@Transactional
void deleteAllByColumnInfoId(Integer columnInfoId);
}
......@@ -34,6 +34,7 @@ public class TableInfoExService {
TableInfoService tableInfoService;
@Autowired
FormPageService formPageService;
public void save(TableInfoEx tableInfoEx) {
//数据检查
boolean exists = tableInfoExRepository.existsByName(tableInfoEx.getName());
......@@ -94,7 +95,7 @@ public class TableInfoExService {
List<TableInfoEx> tableInfoExes = tableInfoExRepository.findByName(name);
for (TableInfoEx tableInfoEx : tableInfoExes) {
Integer tableInfoExId = tableInfoEx.getId();
bindRepository.deleteByTableInfoExId(tableInfoExId);
bindRepository.deleteAllByTableInfoExId(tableInfoExId);
tableInfoExRepository.deleteById(tableInfoExId);
}
}
......@@ -206,15 +207,20 @@ public class TableInfoExService {
private TableInfoEx getBinds(TableInfoEx tableInfoEx) {
List<Bind> binds = bindRepository.findByTableInfoExIdAndParentId(tableInfoEx.getId(), null).stream()
.map(this::getChildren)
.map(bind -> bind.setColumnInfos(tableInfoService.findLastVersion(bind.getName()).getColumnInfos()))
.collect(Collectors.toList());
tableInfoEx.setBinds(binds);
return tableInfoEx;
}
private Bind getChildren(Bind bind) {
List<Bind> children = bindRepository.findByTableInfoExIdAndParentId(bind.getTableInfoExId(), bind.getId()).stream()
.map(child -> child.setChildren(Collections.emptyList()))
.collect(Collectors.toList());
List<Bind> children = bindRepository.findByTableInfoExIdAndParentId(bind.getTableInfoExId(), bind.getId());
if (!children.isEmpty()) {
children = children.stream()
.map(this::getChildren)
.map(child -> child.setColumnInfos(tableInfoService.findLastVersion(child.getName()).getColumnInfos()))
.collect(Collectors.toList());
}
bind.setChildren(children);
return bind;
}
......
......@@ -4,6 +4,7 @@ import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.model.entity.ColumnInfo;
import com.tykj.workflowcore.model.entity.Quote;
import com.tykj.workflowcore.model.entity.TableInfo;
import com.tykj.workflowcore.model.repository.BindRepository;
import com.tykj.workflowcore.model.repository.ColumnInfoRepository;
import com.tykj.workflowcore.model.repository.QuoteRepository;
import com.tykj.workflowcore.model.repository.TableInfoRepository;
......@@ -37,6 +38,8 @@ public class TableInfoService {
private QuoteRepository quoteRepository;
@Autowired
private FormPageService formPageService;
@Autowired
private BindRepository bindRepository;
public void save(TableInfo tableInfo) {
//数据检查
......@@ -102,11 +105,14 @@ public class TableInfoService {
.map(TableInfo::getName)
.distinct()
.map(this::findLastVersion)
.map(this::getColumnInfos)
.collect(Collectors.toList());
}
public void deleteByName(String name) {
boolean hasBind = bindRepository.existsByName(name);
if (hasBind){
throw new RuntimeException("该模型已在聚合模型中绑定");
}
List<TableInfo> tableInfos = tableInfoRepository.findByName(name);
for (TableInfo tableInfo : tableInfos) {
Integer tableInfoId = tableInfo.getId();
......@@ -120,6 +126,13 @@ public class TableInfoService {
}
}
public TableInfo findLastVersion(String name) {
return tableInfoRepository.findByName(name).stream()
.max(Comparator.comparingInt(TableInfo::getVersion))
.map(this::getColumnInfos)
.orElseThrow(() -> new RuntimeException("查询失败"));
}
//-----------------------------------------------------------------------------//
private void saveColumnInfo(ColumnInfo columnInfo, Integer tableInfoId) {
......@@ -143,12 +156,6 @@ public class TableInfoService {
return tableInfo;
}
private TableInfo findLastVersion(String name) {
return tableInfoRepository.findByName(name).stream()
.max(Comparator.comparingInt(TableInfo::getVersion))
.orElseThrow(() -> new RuntimeException("查询失败"));
}
private ColumnInfo getQuotes(ColumnInfo columnInfo) {
List<Quote> quotes = quoteRepository.findByColumnInfoId(columnInfo.getId());
columnInfo.setQuotes(quotes);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论