Merge remote-tracking branch 'origin/feature/REQ-3540' into feature/REQ-3540
This commit is contained in:
commit
d1a120e915
@ -6,19 +6,12 @@ package cn.axzo.nanopart.doc.api.domain;
|
||||
*/
|
||||
public interface IndexNodeParentScope {
|
||||
|
||||
default IndexNodeScope nodeScope() {
|
||||
return IndexNodeScope.ANONYMOUS;
|
||||
}
|
||||
IndexNodeScope nodeScope();
|
||||
|
||||
default String parentCode() {
|
||||
return "";
|
||||
}
|
||||
|
||||
IndexNodeParentScope TEMPLATE_DATABASE_ROOT = new IndexNodeParentScope() {
|
||||
@Override
|
||||
public IndexNodeScope nodeScope() {
|
||||
return IndexNodeScope.TEMPLATE_DATABASE;
|
||||
}
|
||||
};
|
||||
IndexNodeParentScope TEMPLATE_DATABASE_ROOT = () -> IndexNodeScope.TEMPLATE_DATABASE;
|
||||
|
||||
}
|
||||
|
||||
@ -9,14 +9,16 @@ import cn.axzo.nanopart.doc.api.enums.IndexNodeContext;
|
||||
*/
|
||||
public interface IndexNodeScope {
|
||||
|
||||
default IndexNodeContext context() {
|
||||
return IndexNodeContext.NONE;
|
||||
}
|
||||
IndexNodeContext context();
|
||||
|
||||
default DatabaseScope scope() {
|
||||
return DatabaseScope.NONE;
|
||||
}
|
||||
|
||||
default String scopeCode() {
|
||||
return "";
|
||||
}
|
||||
|
||||
default boolean isChildrenNameDuplicatable() {
|
||||
switch (context()) {
|
||||
case FILE_TEMPLATE:
|
||||
@ -24,30 +26,12 @@ public interface IndexNodeScope {
|
||||
case FILE_DATABASE:
|
||||
return false;
|
||||
default:
|
||||
return scope().isChildrenNameDuplicatable();
|
||||
return scope().getChildrenNameDuplicatable();
|
||||
}
|
||||
}
|
||||
|
||||
default String scopeCode() {
|
||||
return "";
|
||||
}
|
||||
IndexNodeScope FILE_TEMPLATE = () -> IndexNodeContext.FILE_TEMPLATE;
|
||||
|
||||
// @formatter:off
|
||||
IndexNodeScope ANONYMOUS = new IndexNodeScope() {};
|
||||
// @formatter:on
|
||||
|
||||
IndexNodeScope FILE_TEMPLATE = new IndexNodeScope() {
|
||||
@Override
|
||||
public IndexNodeContext context() {
|
||||
return IndexNodeContext.FILE_TEMPLATE;
|
||||
}
|
||||
};
|
||||
|
||||
IndexNodeScope TEMPLATE_DATABASE = new IndexNodeScope() {
|
||||
@Override
|
||||
public IndexNodeContext context() {
|
||||
return IndexNodeContext.TEMPLATE_DATABASE;
|
||||
}
|
||||
};
|
||||
IndexNodeScope TEMPLATE_DATABASE = () -> IndexNodeContext.TEMPLATE_DATABASE;
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.api.enums;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@ -16,8 +11,8 @@ import lombok.RequiredArgsConstructor;
|
||||
@RequiredArgsConstructor
|
||||
public enum DatabaseScope {
|
||||
|
||||
// 无含义
|
||||
NONE(DatabaseType.NONE, true),
|
||||
// 无含义, 只有系统预定义用途的才能使用这个值
|
||||
NONE(DatabaseType.NONE, null),
|
||||
// 匿名数据库
|
||||
ANONYMOUS(DatabaseType.NONE, true),
|
||||
// 企业数据库
|
||||
@ -28,11 +23,6 @@ public enum DatabaseScope {
|
||||
PERSONAL_FOR_ENT(DatabaseType.CREATED_BY_USER_FOR_ENT, false);
|
||||
|
||||
private final DatabaseType databaseType;
|
||||
private final boolean childrenNameDuplicatable;
|
||||
private final Boolean childrenNameDuplicatable;
|
||||
|
||||
public static List<DatabaseScope> scopesWithDatabaseTypes() {
|
||||
return Arrays.stream(values()) //
|
||||
.filter(scope -> scope.databaseType != DatabaseType.NONE) //
|
||||
.collect(toList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,8 +6,6 @@ package cn.axzo.nanopart.doc.api.enums;
|
||||
*/
|
||||
public enum IndexNodeContext {
|
||||
NONE,
|
||||
// 系统内置
|
||||
SYSTEM,
|
||||
// 文件模版
|
||||
FILE_TEMPLATE,
|
||||
// 模版数据库
|
||||
|
||||
@ -2,12 +2,15 @@
|
||||
package cn.axzo.nanopart.doc.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.util.BizAssertions;
|
||||
import cn.axzo.nanopart.doc.entity.DocLog;
|
||||
import cn.axzo.nanopart.doc.mapper.DocLogMapper;
|
||||
import cn.axzo.nanopart.doc.api.util.BizAssertions;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
@ -15,6 +18,13 @@ import cn.axzo.nanopart.doc.api.util.BizAssertions;
|
||||
@Repository
|
||||
public class DocLogDao extends ServiceImpl<DocLogMapper, DocLog> {
|
||||
|
||||
private final TransactionTemplate newTransaction;
|
||||
|
||||
public DocLogDao(PlatformTransactionManager transactionManager) {
|
||||
newTransaction = new TransactionTemplate(transactionManager);
|
||||
newTransaction.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
}
|
||||
|
||||
public void logRequest(String context, Object subject, Object request) {
|
||||
log(context, subject, "request", request);
|
||||
}
|
||||
@ -35,7 +45,7 @@ public class DocLogDao extends ServiceImpl<DocLogMapper, DocLog> {
|
||||
log.addLogContent((String) logContents[i], logContents[i + 1]);
|
||||
}
|
||||
}
|
||||
save(log);
|
||||
newTransaction.executeWithoutResult(unused -> save(log));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -230,7 +230,6 @@ public class FileDatabaseService {
|
||||
.in(CollectionUtils.isNotEmpty(searchWorkspaceIds), FileDatabase::getWorkspaceId, searchWorkspaceIds)
|
||||
.in(CollectionUtils.isNotEmpty(seachTemplateDatabaseCodes), FileDatabase::getTemplateDatabaseCode, seachTemplateDatabaseCodes) //
|
||||
.in(CollectionUtils.isNotEmpty(seachScopes), FileDatabase::getScope, seachScopes)
|
||||
.in(FileDatabase::getScope, DatabaseScope.scopesWithDatabaseTypes())
|
||||
.orderByDesc(FileDatabase::getId)
|
||||
.page(request.toPage());
|
||||
// @formatter:on
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.file.templatedb;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.enums.DatabaseType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -37,6 +38,7 @@ public class TemplateDatabaseManager {
|
||||
|
||||
@BizTransactional
|
||||
public String createDatabase(TemplateDatabaseCreateDatabaseRequest request) {
|
||||
BizAssertions.assertNotEquals(DatabaseType.NONE, request.getScope().getDatabaseType(), "不能添加数据库类型不能为空的scope");
|
||||
request.setParentCode("");
|
||||
IndexNode indexNode = indexManager.createDatabase(request);
|
||||
TemplateDatabase db = new TemplateDatabase();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user