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

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

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