Merge remote-tracking branch 'origin/feature/REQ-3540' into feature/REQ-3540
This commit is contained in:
commit
72f6ded30a
@ -0,0 +1,27 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.api.anonymous;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.anonymous.request.AnonymousCreateFileRequest;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@FeignClient(name = "nanopart", url = "${axzo.service.nanopart:http://nanopart:8080}")
|
||||
public interface DocAnonymousDatabaseApi {
|
||||
|
||||
/**
|
||||
* 创建文件
|
||||
*
|
||||
* @return 文件编码, 需要由业务存储
|
||||
*/
|
||||
@PostMapping("/api/anonymous/createFile")
|
||||
CommonResponse<String> createFile(@RequestBody @Valid AnonymousCreateFileRequest request);
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package cn.axzo.nanopart.doc.api.anonymous.request;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.enums.FileFormat;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class AnonymousCreateFileRequest extends NodeCreateAnonymous {
|
||||
|
||||
/**
|
||||
* 文件格式. EXCEL, WORD, PDF
|
||||
*/
|
||||
@NotNull(message = "文件格式不能为空")
|
||||
private FileFormat format;
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.api.anonymous.request;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.domain.IndexNodeScope;
|
||||
import cn.axzo.nanopart.doc.api.domain.NodeCreate;
|
||||
import cn.axzo.nanopart.doc.api.enums.DatabaseScope;
|
||||
import cn.axzo.nanopart.doc.api.enums.IndexNodeContext;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
abstract class NodeCreateAnonymous implements NodeCreate, IndexNodeScope {
|
||||
|
||||
/**
|
||||
* 父节点code
|
||||
*/
|
||||
private String parentCode;
|
||||
|
||||
/**
|
||||
* 节点(文件名/文件夹), 不含后缀
|
||||
*/
|
||||
@NotBlank(message = "name不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 业务(场景)
|
||||
*/
|
||||
@NotBlank(message = "biz不能为空")
|
||||
private String biz;
|
||||
|
||||
/**
|
||||
* 业务编码
|
||||
*/
|
||||
private String bizCode;
|
||||
|
||||
/**
|
||||
* 创建人personId
|
||||
*/
|
||||
private Long operatorId;
|
||||
|
||||
@Override
|
||||
public String biz() {
|
||||
return biz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String bizCode() {
|
||||
return bizCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long operatorId() {
|
||||
return operatorId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IndexNodeScope nodeScope() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IndexNodeContext context() {
|
||||
return IndexNodeContext.FILE_DATABASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DatabaseScope scope() {
|
||||
return DatabaseScope.ANONYMOUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String parentCode() {
|
||||
return IndexNodeScope.TREE_ROOT_NODE_CODE;
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ public interface IndexNodeParentScope {
|
||||
IndexNodeScope nodeScope();
|
||||
|
||||
default String parentCode() {
|
||||
return "";
|
||||
return IndexNodeScope.TREE_ROOT_NODE_CODE;
|
||||
}
|
||||
|
||||
IndexNodeParentScope TEMPLATE_DATABASE_ROOT = () -> IndexNodeScope.TEMPLATE_DATABASE;
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.file.anonymous;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.anonymous.DocAnonymousDatabaseApi;
|
||||
import cn.axzo.nanopart.doc.api.anonymous.request.AnonymousCreateFileRequest;
|
||||
import cn.axzo.nanopart.doc.api.domain.OssFile;
|
||||
import cn.axzo.nanopart.doc.entity.IndexNode;
|
||||
import cn.axzo.nanopart.doc.file.index.IndexManager;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class DocAnonymousDatabaseApiController implements DocAnonymousDatabaseApi {
|
||||
|
||||
private final IndexManager indexManager;
|
||||
|
||||
@Override
|
||||
public CommonResponse<String> createFile(AnonymousCreateFileRequest request) {
|
||||
OssFile ossFile = indexManager.prepareEmptyOssFile(request, request.getFormat());
|
||||
IndexNode fileNode = indexManager.createFile(request, ossFile);
|
||||
return CommonResponse.success(fileNode.getCode());
|
||||
}
|
||||
|
||||
}
|
||||
@ -64,8 +64,8 @@ class IndexSupport {
|
||||
child.setParentCode(parent == null ? IndexNodeScope.TREE_ROOT_NODE_CODE : parent.getCode());
|
||||
child.setRootCode(parent == null ? child.getCode() : parent.getRootCode());
|
||||
child.setName(create.name());
|
||||
child.setBiz(create.biz());
|
||||
child.setBizCode(create.bizCode());
|
||||
child.setBiz(create.biz() == null ? "" : create.biz());
|
||||
child.setBizCode(create.bizCode() == null ? "" : create.bizCode());
|
||||
child.setDescription(create.description());
|
||||
child.setIcon(create.icon());
|
||||
child.setState(IndexNodeState.VALID);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user