REQ-3540: oss client
This commit is contained in:
parent
0c283e09f1
commit
a8a03d8f4f
@ -1,8 +1,8 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.api.filetemplate.request;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.util.DefaultIcons;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -13,11 +13,6 @@ import lombok.Setter;
|
||||
@Getter
|
||||
public class FileTemplateCreateDirRequest extends NodeCreateFileTemplate {
|
||||
|
||||
@Override
|
||||
public String icon() {
|
||||
return DefaultIcons.DIR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JSON.toJSONString(this);
|
||||
|
||||
@ -6,7 +6,6 @@ import javax.validation.constraints.NotNull;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.enums.FileFormat;
|
||||
import cn.axzo.nanopart.doc.api.util.DefaultIcons;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -23,11 +22,6 @@ public class FileTemplateCreateFileRequest extends NodeCreateFileTemplate {
|
||||
@NotNull(message = "文件格式不能为空")
|
||||
private FileFormat format;
|
||||
|
||||
@Override
|
||||
public String icon() {
|
||||
return DefaultIcons.defaultFileIcon(format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JSON.toJSONString(this);
|
||||
|
||||
@ -7,7 +7,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.enums.CooperationType;
|
||||
import cn.axzo.nanopart.doc.api.enums.DatabaseScope;
|
||||
import cn.axzo.nanopart.doc.api.util.DefaultIcons;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -31,7 +30,7 @@ public class TemplateDatabaseCreateDatabaseRequest extends TemplateDatabaseCreat
|
||||
private CooperationType coopType;
|
||||
|
||||
public String icon() {
|
||||
return StringUtils.isBlank(getIcon()) ? DefaultIcons.DATABASE : getIcon();
|
||||
return StringUtils.isBlank(getIcon()) ? "" : getIcon();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import javax.validation.constraints.NotBlank;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.domain.IndexNodeAttributes;
|
||||
import cn.axzo.nanopart.doc.api.util.DefaultIcons;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -39,7 +38,7 @@ public class TemplateDatabaseCreateDirRequest extends NodeCreateTemplateDatabase
|
||||
private boolean customIcon;
|
||||
|
||||
public String icon() {
|
||||
return StringUtils.isBlank(icon) ? DefaultIcons.DIR : icon;
|
||||
return StringUtils.isBlank(icon) ? "" : icon;
|
||||
}
|
||||
|
||||
public String bizCode() {
|
||||
|
||||
@ -4,7 +4,6 @@ package cn.axzo.nanopart.doc.api.templatedb.reqeust;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.enums.FileFormat;
|
||||
import cn.axzo.nanopart.doc.api.util.DefaultIcons;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -21,9 +20,4 @@ public class TemplateDatabaseCreateFileRequest extends NodeCreateTemplateDatabas
|
||||
@NotNull(message = "文件格式不能为空")
|
||||
private FileFormat format;
|
||||
|
||||
@Override
|
||||
public String icon() {
|
||||
return DefaultIcons.defaultFileIcon(format);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.api.util;
|
||||
|
||||
import static cn.axzo.nanopart.doc.api.util.BizAssertions.fail;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.enums.FileFormat;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
public class DefaultIcons {
|
||||
|
||||
// TODO(yl): WHAT
|
||||
public static final String DIR = "default_dir_icon";
|
||||
// TODO(yl): WHAT
|
||||
public static final String DATABASE = "default_database_icon";
|
||||
// TODO(yl): WHAT
|
||||
public static final String FILE_EXCEL = "default_excel_icon";
|
||||
// TODO(yl): WHAT
|
||||
public static final String FILE_WORD = "default_word_icon";
|
||||
// TODO(yl): WHAT
|
||||
public static final String FILE_PDF = "default_pdf_icon";
|
||||
|
||||
public static String defaultFileIcon(FileFormat fileFormat) {
|
||||
if (fileFormat == FileFormat.EXCEL)
|
||||
return DefaultIcons.FILE_EXCEL;
|
||||
if (fileFormat == FileFormat.WORD)
|
||||
return DefaultIcons.FILE_WORD;
|
||||
if (fileFormat == FileFormat.PDF)
|
||||
return DefaultIcons.FILE_PDF;
|
||||
throw fail("不支持的文件格式: {}", fileFormat);
|
||||
}
|
||||
|
||||
}
|
||||
@ -27,6 +27,8 @@ public class DocProps {
|
||||
private int indexNodeMaxCopyFileSize = 1000;
|
||||
private String ossAppCode = "ent-workspace-doc";
|
||||
private int asyncTimeoutSeconds = 10;
|
||||
// TODO(yl): WHAT
|
||||
private String defaultIconDatabase = "default_dir_icon";
|
||||
private String defaultIconDir = "default_dir_icon";
|
||||
private String defaultIconExcel = "default_excel_icon";
|
||||
private String defaultIconWord = "default_word_icon";
|
||||
@ -41,4 +43,5 @@ public class DocProps {
|
||||
return createFilePptFileKey;
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,14 +6,18 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import cn.axzo.nanopart.doc.api.domain.FileAttributes;
|
||||
import cn.axzo.nanopart.doc.api.domain.IndexNodeScope;
|
||||
import cn.axzo.nanopart.doc.api.enums.FileFormat;
|
||||
import cn.axzo.nanopart.doc.api.enums.IndexNodeState;
|
||||
import cn.axzo.nanopart.doc.api.enums.IndexNodeType;
|
||||
import cn.axzo.nanopart.doc.api.index.request.IndexNodeSearchRequest;
|
||||
import cn.axzo.nanopart.doc.config.DocProps;
|
||||
import cn.axzo.nanopart.doc.dao.IndexNodeDao;
|
||||
import cn.axzo.nanopart.doc.entity.IndexNode;
|
||||
import cn.azxo.framework.common.model.Page;
|
||||
@ -27,11 +31,17 @@ import lombok.RequiredArgsConstructor;
|
||||
public class IndexQueryService {
|
||||
|
||||
private final IndexNodeDao indexNodeDao;
|
||||
private final DocProps docProps;
|
||||
|
||||
public List<IndexNode> getTree(IndexNodeScope nodeScope) {
|
||||
return indexNodeDao.scopeQuery(nodeScope) //
|
||||
List<IndexNode> nodes = indexNodeDao.scopeQuery(nodeScope) //
|
||||
.eq(IndexNode::getState, IndexNodeState.VALID) //
|
||||
.list();
|
||||
for (IndexNode indexNode : nodes) {
|
||||
if (StringUtils.isBlank(indexNode.getIcon()))
|
||||
indexNode.setIcon(determineIcon(indexNode));
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public Page<IndexNode> search(IndexNodeScope nodeScope, IndexNodeSearchRequest search) {
|
||||
@ -57,4 +67,19 @@ public class IndexQueryService {
|
||||
return indexNodeDao.lambdaQuery().in(IndexNode::getCode, codes).list();
|
||||
}
|
||||
|
||||
private String determineIcon(IndexNode indexNode) {
|
||||
if (indexNode.getNodeType() == IndexNodeType.DATABASE)
|
||||
return docProps.getDefaultIconDatabase();
|
||||
if (indexNode.getNodeType() == IndexNodeType.DIRECTORY)
|
||||
return docProps.getDefaultIconDir();
|
||||
FileFormat fileFormat = indexNode.getOrCreateFileAttributes().getFileFormat();
|
||||
if (fileFormat == FileFormat.EXCEL)
|
||||
indexNode.setIcon(docProps.getDefaultIconExcel());
|
||||
else if (fileFormat == FileFormat.WORD)
|
||||
indexNode.setIcon(docProps.getDefaultIconWord());
|
||||
else if (fileFormat == FileFormat.PDF)
|
||||
indexNode.setIcon(docProps.getDefaultIconPdf());
|
||||
return "no-icon";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user