|
@@ -1,17 +1,26 @@
|
|
|
package com.fjhx.account.service.cost.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.account.entity.cost.dto.CostControlDto;
|
|
|
import com.fjhx.account.entity.cost.dto.CostControlSelectDto;
|
|
|
import com.fjhx.account.entity.cost.po.CostControl;
|
|
|
+import com.fjhx.account.entity.cost.vo.CostControlDetailVo;
|
|
|
import com.fjhx.account.entity.cost.vo.CostControlVo;
|
|
|
import com.fjhx.account.mapper.cost.CostControlMapper;
|
|
|
import com.fjhx.account.service.cost.CostControlService;
|
|
|
+import com.fjhx.common.controller.Label;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -54,4 +63,42 @@ public class CostControlServiceImpl extends ServiceImpl<CostControlMapper, CostC
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public JSONObject getFieldInfo() {
|
|
|
+
|
|
|
+
|
|
|
+ List<JSONObject> infoField = getField(CostControlVo.class);
|
|
|
+ List<JSONObject> detailField = getField(CostControlDetailVo.class);
|
|
|
+
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("infoField", infoField);
|
|
|
+ json.put("detailField", detailField);
|
|
|
+
|
|
|
+
|
|
|
+ return json;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<JSONObject> getField(Class cl) {
|
|
|
+ //获取所有字段
|
|
|
+ List<Field> fieldList = new ArrayList<>();
|
|
|
+ Collections.addAll(fieldList, cl.getDeclaredFields());
|
|
|
+ Class<? super CostControlVo> superclass = cl.getSuperclass();
|
|
|
+ if (ObjectUtil.isNotEmpty(superclass)) {
|
|
|
+ Collections.addAll(fieldList, superclass.getDeclaredFields());
|
|
|
+ }
|
|
|
+
|
|
|
+ //遍历处理
|
|
|
+ List<JSONObject> arr = new ArrayList<>();
|
|
|
+ for (Field field : fieldList) {
|
|
|
+ Label labelAnnotation = field.getAnnotation(Label.class);
|
|
|
+ if (labelAnnotation != null) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("key", field.getName());
|
|
|
+ jsonObject.put("val", labelAnnotation.value());
|
|
|
+ arr.add(jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ }
|
|
|
+
|
|
|
}
|