From c635d78b479510ebe2556a420948effcd30a0731 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期六, 21 十二月 2024 18:40:43 +0800 Subject: [PATCH] 新建德森项目分支 --- zy-asrs-framework/src/main/java/com/zy/asrs/framework/controller/AbstractBaseController.java | 138 +++++++++++++++++++++++----------------------- 1 files changed, 69 insertions(+), 69 deletions(-) diff --git a/zy-asrs-framework/src/main/java/com/zy/asrs/framework/controller/AbstractBaseController.java b/zy-asrs-framework/src/main/java/com/zy/asrs/framework/controller/AbstractBaseController.java index 282e3ce..eda8187 100644 --- a/zy-asrs-framework/src/main/java/com/zy/asrs/framework/controller/AbstractBaseController.java +++ b/zy-asrs-framework/src/main/java/com/zy/asrs/framework/controller/AbstractBaseController.java @@ -1,69 +1,69 @@ -package com.zy.asrs.framework.controller; - -import com.zy.asrs.framework.common.BaseRes; -import com.zy.asrs.framework.common.Cools; -import com.zy.asrs.framework.exception.CoolException; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Created by vincent on 2019-06-09 - */ -public abstract class AbstractBaseController { - - public <T> List exportSupport(List<T> list, List<String> fields){ - if (Cools.isEmpty(list)){ - throw new CoolException(BaseRes.EMPTY); - } - try { - List<List<Object>> result = new ArrayList<>(); - Method[] methods = list.get(0).getClass().getMethods(); - for (T t : list){ - List<Object> node = new ArrayList<>(); - for (String field : fields){ - for (Method method : methods) { - if (("get" + field).toLowerCase().equals(method.getName().toLowerCase())) { - Object val = method.invoke(t); - node.add(val); - break; - } - } - } - result.add(node); - } - return result; - } catch (Exception e){ - throw new RuntimeException(e); - } - - } - - public static Map<String, Object> excludeTrash(Map<String, Object> map){ - if (Cools.isEmpty(map)){ - return new HashMap<>(); - } - map.entrySet().removeIf(next -> next.getKey().equals("curr") - || next.getKey().equals("limit") - || next.getKey().equals("orderByField") - || next.getKey().equals("orderByType") - || next.getKey().equals("condition") - || Cools.isEmpty(next.getValue())); - return map; - } - - public static String humpToLine(String str) { - Matcher matcher = Pattern.compile("[A-Z]").matcher(str); - StringBuffer sb = new StringBuffer(); - while (matcher.find()) { - matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase()); - } - matcher.appendTail(sb); - return sb.toString(); - } -} +package com.zy.asrs.framework.controller; + +import com.zy.asrs.framework.common.BaseRes; +import com.zy.asrs.framework.common.Cools; +import com.zy.asrs.framework.exception.CoolException; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Created by vincent on 2019-06-09 + */ +public abstract class AbstractBaseController { + + public <T> List exportSupport(List<T> list, List<String> fields){ + if (Cools.isEmpty(list)){ + throw new CoolException(BaseRes.EMPTY); + } + try { + List<List<Object>> result = new ArrayList<>(); + Method[] methods = list.get(0).getClass().getMethods(); + for (T t : list){ + List<Object> node = new ArrayList<>(); + for (String field : fields){ + for (Method method : methods) { + if (("get" + field).toLowerCase().equals(method.getName().toLowerCase())) { + Object val = method.invoke(t); + node.add(val); + break; + } + } + } + result.add(node); + } + return result; + } catch (Exception e){ + throw new RuntimeException(e); + } + + } + + public static Map<String, Object> excludeTrash(Map<String, Object> map){ + if (Cools.isEmpty(map)){ + return new HashMap<>(); + } + map.entrySet().removeIf(next -> next.getKey().equals("curr") + || next.getKey().equals("limit") + || next.getKey().equals("orderByField") + || next.getKey().equals("orderByType") + || next.getKey().equals("condition") + || Cools.isEmpty(next.getValue())); + return map; + } + + public static String humpToLine(String str) { + Matcher matcher = Pattern.compile("[A-Z]").matcher(str); + StringBuffer sb = new StringBuffer(); + while (matcher.find()) { + matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase()); + } + matcher.appendTail(sb); + return sb.toString(); + } +} -- Gitblit v1.9.1