提交 c15a42a5 作者: 925993793@qq.com

调试、接口补充

上级 1d03540e
...@@ -57,7 +57,19 @@ public class ReportDataController { ...@@ -57,7 +57,19 @@ public class ReportDataController {
*/ */
@GetMapping("/searchFieldList") @GetMapping("/searchFieldList")
public Result<?> fieldList(){ public Result<?> fieldList(){
List<Map<String, Object>> fieldDetails = FieldUtil.fieldDetails(SearchCondition.class); List<Map<String, Object>> fieldDetails = FieldUtil.requestFieldDetails(SearchCondition.class);
return Result.OK(fieldDetails);
}
/**
* 响应字段集合
*
* @author lkg
* @date 2025/4/9
*/
@GetMapping("/responseFieldList")
public Result<?> responseFieldList(){
List<Map<String, Object>> fieldDetails = FieldUtil.responseFieldDetails(ReportDataVO.class);
return Result.OK(fieldDetails); return Result.OK(fieldDetails);
} }
......
...@@ -12,37 +12,54 @@ import lombok.Data; ...@@ -12,37 +12,54 @@ import lombok.Data;
public class ReportDataVO { public class ReportDataVO {
//信息id //信息id
@FieldDescription(value = "资讯id")
private String id; private String id;
//标题 //标题
@FieldDescription(value = "标题")
private String title; private String title;
//摘要 //摘要
@FieldDescription(value = "摘要")
private String summary; private String summary;
//正文 //正文
@FieldDescription(value = "正文")
private String content; private String content;
//带标签正文 //带标签正文
@FieldDescription(value = "正文带标签")
private String contentWithTag; private String contentWithTag;
//语言 //语言
@FieldDescription(value = "语言")
private String lang; private String lang;
//来源(信息来源) //来源(信息来源)
@FieldDescription(value = "来源")
private String origin; private String origin;
//发布时间 //发布时间
@FieldDescription(value = "发布时间")
private String publishDate; private String publishDate;
//发布地址 //发布地址
@FieldDescription(value = "原文连接")
private String sourceAddress; private String sourceAddress;
//得分 //得分
@FieldDescription(value = "得分")
private Double score; private Double score;
//专题库类型(0: 其它 1:政策;2:领导讲话;3:专家观点;4:企业案例) //专题库类型(0: 其它 1:政策;2:领导讲话;3:专家观点;4:企业案例)
@FieldDescription(value = "专题库类型")
private Integer classificationType; private Integer classificationType;
//删除标记(1:删除;0:保留) //删除标记(1:删除;0:保留)
@FieldDescription(value = "删除标记")
private Integer deleteFlag; private Integer deleteFlag;
//专题id //专题id
@FieldDescription(value = "专题id")
private String subjectId; private String subjectId;
//专题名称 //专题名称
@FieldDescription(value = "专题名称")
private String subjectName; private String subjectName;
//审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0) //审核操作(0:未审核 1:审核通过 2:审核未通过 3:暂定 默认值为0)
@FieldDescription(value = "审核状态")
private Integer checkStatus; private Integer checkStatus;
/**原创性*/ /**原创性*/
@FieldDescription(value = "原创性")
private String originality; private String originality;
//入库时间 //入库时间
@FieldDescription(value = "采集时间")
private String createDate; private String createDate;
} }
...@@ -16,7 +16,7 @@ import java.util.TreeMap; ...@@ -16,7 +16,7 @@ import java.util.TreeMap;
*/ */
public class FieldUtil { public class FieldUtil {
public static List<Map<String, Object>> fieldDetails(Class<?> clazz) { public static List<Map<String, Object>> requestFieldDetails(Class<?> clazz) {
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
Field[] fields = clazz.getDeclaredFields(); Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
...@@ -33,7 +33,7 @@ public class FieldUtil { ...@@ -33,7 +33,7 @@ public class FieldUtil {
} else if (elementType.isAssignableFrom(String.class )) { } else if (elementType.isAssignableFrom(String.class )) {
fieldMap.put("fieldType", field.getType().getSimpleName() + "<String>"); fieldMap.put("fieldType", field.getType().getSimpleName() + "<String>");
} else { } else {
List<Map<String, Object>> children = fieldDetails(elementType); List<Map<String, Object>> children = requestFieldDetails(elementType);
fieldMap.put("children", children); fieldMap.put("children", children);
} }
} }
...@@ -43,6 +43,22 @@ public class FieldUtil { ...@@ -43,6 +43,22 @@ public class FieldUtil {
return list; return list;
} }
public static List<Map<String, Object>> responseFieldDetails(Class<?> clazz) {
List<Map<String, Object>> list = new ArrayList<>();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
Map<String, Object> fieldMap = new TreeMap<>();
FieldDescription fieldAnnotation = field.getAnnotation(FieldDescription.class);
if (fieldAnnotation != null && fieldAnnotation.valid()) {
fieldMap.put("fieldName", field.getName());
fieldMap.put("fieldType", field.getType().getSimpleName());
fieldMap.put("fieldDescription", fieldAnnotation.value());
list.add(fieldMap);
}
}
return list;
}
private static Class<?> getCollectionElementType(java.lang.reflect.Type collectionType) { private static Class<?> getCollectionElementType(java.lang.reflect.Type collectionType) {
if (collectionType instanceof java.lang.reflect.ParameterizedType) { if (collectionType instanceof java.lang.reflect.ParameterizedType) {
java.lang.reflect.ParameterizedType aType = (java.lang.reflect.ParameterizedType) collectionType; java.lang.reflect.ParameterizedType aType = (java.lang.reflect.ParameterizedType) collectionType;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论