fix:文件打标签重构
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package com.sdm.common.entity.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 文件字典标签枚举
|
||||
* 固定配置文件元数据响应中需要填充的字典标签字段映射关系
|
||||
*
|
||||
* 映射关系:
|
||||
* - disciplineTypeDictClass/disciplineDictValue → DISCIPLINE_TYPE
|
||||
* - fileTypeDictClass/fileTypeDictValue → ALL_FILE_TYPE
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum FileDictTagEnum {
|
||||
|
||||
/**
|
||||
* 学科类型标签
|
||||
* 字段: disciplineTypeDictClass, disciplineDictValue
|
||||
* dictClass: DISCIPLINE_TYPE
|
||||
*/
|
||||
DISCIPLINE_TYPE("DISCIPLINE_TYPE", "disciplineTypeDictClass", "disciplineDictValue"),
|
||||
|
||||
/**
|
||||
* 文件类型标签
|
||||
* 字段: fileTypeDictClass, fileTypeDictValue
|
||||
* dictClass: ALL_FILE_TYPE
|
||||
*/
|
||||
FILE_TYPE("ALL_FILE_TYPE", "fileTypeDictClass", "fileTypeDictValue");
|
||||
|
||||
/**
|
||||
* 字典分类(对应数据库中的 dictClass)
|
||||
*/
|
||||
private final String dictClass;
|
||||
|
||||
/**
|
||||
* dictClass 字段名(完整字段名,如 disciplineTypeDictClass)
|
||||
*/
|
||||
private final String dictClassFieldName;
|
||||
|
||||
/**
|
||||
* dictValue 字段名(完整字段名,如 disciplineDictValue)
|
||||
*/
|
||||
private final String dictValueFieldName;
|
||||
|
||||
/**
|
||||
* 根据 dictClass 获取对应的枚举
|
||||
* @param dictClass 字典分类
|
||||
* @return 对应的枚举,如果不存在则返回 null
|
||||
*/
|
||||
public static FileDictTagEnum getByDictClass(String dictClass) {
|
||||
if (dictClass == null) {
|
||||
return null;
|
||||
}
|
||||
for (FileDictTagEnum enumItem : values()) {
|
||||
if (enumItem.getDictClass().equals(dictClass)) {
|
||||
return enumItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为配置的字典分类
|
||||
* @param dictClass 字典分类
|
||||
* @return 是否配置
|
||||
*/
|
||||
public static boolean isConfigured(String dictClass) {
|
||||
return getByDictClass(dictClass) != null;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,9 @@ import java.util.Map;
|
||||
@Data
|
||||
@Schema(description = "字典标签查询请求")
|
||||
public class DictTagReq {
|
||||
@Schema(description = "字典ID", example = "1234")
|
||||
private Integer dictId;
|
||||
|
||||
@Schema(description = "字典类型", example = "file_type")
|
||||
private String dictClass;
|
||||
|
||||
@@ -27,4 +30,11 @@ public class DictTagReq {
|
||||
@Schema(description = "字典标签查询项列表")
|
||||
private List<DictTagReq> items;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Schema(description = "批量查询字典详情请求")
|
||||
public static class BatchDictQueryReq {
|
||||
@Schema(description = "字典标签查询项列表")
|
||||
private List<DictTagReq> items;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sdm.common.entity.resp.data;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
@@ -11,6 +12,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件元数据传输对象(用于接口返回给前端)
|
||||
@@ -61,6 +63,21 @@ public class FileMetadataInfoResp extends BaseResp implements Serializable {
|
||||
@Schema(description= "文件业务类型(1:模型文件 2:仿真报告、3:计算文件、4:曲线文件、5:云图文件,6:网格文件,7:计算过程文件)")
|
||||
private Integer fileType;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// 很重要,用于设置标签
|
||||
@Schema(description = "文件类型字典类")
|
||||
private String fileTypeDictClass;
|
||||
@Schema(description = "文件类型字典值")
|
||||
private String fileTypeDictValue;
|
||||
|
||||
@Schema(description = "学科类型字典类")
|
||||
private String disciplineTypeDictClass;
|
||||
|
||||
@Schema(description = "学科类型字典值")
|
||||
private String disciplineDictValue;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
@Schema(description = "数据类型:1-文件,2-文件夹")
|
||||
private Integer dataType;
|
||||
|
||||
|
||||
@@ -49,4 +49,19 @@ public class SysConfigFeignClientImpl implements ISysConfigFeignClient {
|
||||
return SdmResponse.failed("字典信息未查询");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<List<DataDictionary>> batchQueryDictionaries(DictTagReq.BatchDictQueryReq req) {
|
||||
SdmResponse<List<DataDictionary>> sdmResponse;
|
||||
try {
|
||||
sdmResponse = sysConfigFeignClient.batchQueryDictionaries(req);
|
||||
if(!sdmResponse.isSuccess() ||ObjectUtils.isEmpty(sdmResponse.getData())){
|
||||
return SdmResponse.failed("字典信息未查询");
|
||||
}
|
||||
return sdmResponse;
|
||||
} catch (Exception e) {
|
||||
log.error("字典信息失败", e);
|
||||
return SdmResponse.failed("字典信息未查询");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,12 @@ public interface ISysConfigFeignClient {
|
||||
@PostMapping(value = "/systemData/multiDictionaryIds")
|
||||
SdmResponse<Map<String, Map<String, Integer>>> multiQueryDictionaryIds(@RequestBody DictTagReq.BatchDictIdQueryReq req);
|
||||
|
||||
/**
|
||||
* 批量查询字典详情(根据 dictId 列表)
|
||||
* @param req 包含 dictId 列表的请求
|
||||
* @return 字典详情列表
|
||||
*/
|
||||
@PostMapping(value = "/systemData/batchQueryDictionaries")
|
||||
SdmResponse<List<DataDictionary>> batchQueryDictionaries(@RequestBody DictTagReq.BatchDictQueryReq req);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user