REQ-3540: 添加校验
This commit is contained in:
parent
af4d4ecaf6
commit
aef96401b3
@ -1,6 +1,14 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.entity.domain;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@ -8,4 +16,12 @@ public interface IndexNodeCodeProvider {
|
||||
|
||||
String indexNodeCode();
|
||||
|
||||
static List<String> collectIndexNodeCodes(List<? extends IndexNodeCodeProvider> nodes) {
|
||||
if (CollectionUtils.isEmpty(nodes))
|
||||
return Collections.emptyList();
|
||||
return nodes.stream() //
|
||||
.map(IndexNodeCodeProvider::indexNodeCode) //
|
||||
.filter(StringUtils::isNotBlank) //
|
||||
.collect(toList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.file.index;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -82,12 +80,7 @@ public class IndexQueryService {
|
||||
}
|
||||
|
||||
public List<IndexNode> get(List<? extends IndexNodeCodeProvider> nodes) {
|
||||
if (CollectionUtils.isEmpty(nodes))
|
||||
return Collections.emptyList();
|
||||
List<String> codes = nodes.stream() //
|
||||
.map(IndexNodeCodeProvider::indexNodeCode) //
|
||||
.filter(StringUtils::isNotBlank) //
|
||||
.collect(toList());
|
||||
List<String> codes = IndexNodeCodeProvider.collectIndexNodeCodes(nodes);
|
||||
if (CollectionUtils.isEmpty(codes))
|
||||
return Collections.emptyList();
|
||||
return indexNodeDao.lambdaQuery().in(IndexNode::getCode, codes).list();
|
||||
|
||||
@ -87,7 +87,8 @@ public class TemplateDatabaseQueryService {
|
||||
.eq(TemplateDatabase::getState, TemplateDatabaseState.VALID) //
|
||||
.in(codes != null, TemplateDatabase::getCode, codes) //
|
||||
.page(request.toPage());
|
||||
return Page.toPage(request.getPage(), page.getSize(), page.getTotal(), toTemplateDatabaseInfo(page.getRecords()));
|
||||
return Page.toPage(request.getPage(), page.getSize(), page.getTotal(),
|
||||
toTemplateDatabaseInfo(page.getRecords()));
|
||||
}
|
||||
|
||||
public List<TemplateDatabaseInfo> toTemplateDatabaseInfo(List<TemplateDatabase> templateDatabases) {
|
||||
@ -106,12 +107,7 @@ public class TemplateDatabaseQueryService {
|
||||
}
|
||||
|
||||
public List<TemplateDatabase> get(List<? extends IndexNodeCodeProvider> nodes) {
|
||||
if (CollectionUtils.isEmpty(nodes))
|
||||
return Collections.emptyList();
|
||||
List<String> codes = nodes.stream() //
|
||||
.map(IndexNodeCodeProvider::indexNodeCode) //
|
||||
.filter(StringUtils::isNotBlank) //
|
||||
.collect(toList());
|
||||
List<String> codes = IndexNodeCodeProvider.collectIndexNodeCodes(nodes);
|
||||
if (CollectionUtils.isEmpty(codes))
|
||||
return Collections.emptyList();
|
||||
return templateDatabaseDao.lambdaQuery() //
|
||||
|
||||
Loading…
Reference in New Issue
Block a user