Commit 006e4091 authored by 赵啸非's avatar 赵啸非

修改导出动态列

parent 409ce77c
package com.mortals.xhx.module.attendance.web;
import cn.hutool.core.util.ReflectUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
......@@ -38,6 +40,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
......@@ -94,7 +97,17 @@ public class AttendanceRecordController extends BaseCRUDJsonBodyMappingControlle
@Override
public void doExportBefore(Context context, AttendanceRecordEntity query, List<String> properties) throws AppException {
if (!ObjectUtils.isEmpty(query.getProperties())) {
properties.addAll(query.getProperties());
//通过属性转换为注解
List<Field> tempFields = new ArrayList<>();
tempFields.addAll(Arrays.asList(ReflectUtil.getFields(AttendanceRecordEntity.class)));
for (Field field : tempFields) {
if (field.isAnnotationPresent(Excel.class)) {
Excel column = field.getAnnotation(Excel.class);
if (column != null && query.getProperties().contains(field.getName())) {
properties.add(column.name());
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment