| | |
| | | |
| | | public class PrintChina { |
| | | |
| | | public static <T> List<Map<String, String>> printChina(Class<T> tClass) { |
| | | public static <T> List<Map<String, Object>> printChina(Class<T> tClass) { |
| | | //将实体类的属性和注释转换成参数 |
| | | List<Field> fieldList = new ArrayList<>(); |
| | | while (tClass != null){ |
| | |
| | | } |
| | | Field[] fields = new Field[fieldList.size()]; |
| | | fieldList.toArray(fields); |
| | | ArrayList<Map<String, String>> list = new ArrayList<>(); |
| | | ArrayList<Map<String, Object>> list = new ArrayList<>(); |
| | | for (Field field : fields) { |
| | | Map<String, String> soundVo = new HashMap<>(); |
| | | Map<String, Object> soundVo = new HashMap<>(); |
| | | boolean bool = field.isAnnotationPresent(ApiModelProperty.class); |
| | | boolean bool2 = field.isAnnotationPresent(ValueTableShow.class); |
| | | if (bool2) { |
| | | int order = field.getAnnotation(ValueTableShow.class).value(); |
| | | String value = field.getAnnotation(ValueTableShow.class).name(); |
| | | int width = field.getAnnotation(ValueTableShow.class).width(); |
| | | if (bool){ |
| | | value = value.isEmpty() ? field.getAnnotation(ApiModelProperty.class).value() : value; |
| | | } |
| | | soundVo.put("label", field.getName()); |
| | | soundVo.put("value", value); |
| | | soundVo.put("width", width); |
| | | soundVo.put("order", order + ""); |
| | | if(list.size() == 0){ |
| | | list.add(soundVo); |
| | | }else{ |
| | | boolean isAdd = false; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Map<String, String> map = list.get(i); |
| | | if(order < Integer.parseInt(map.get("order"))){ |
| | | Map<String, Object> map = list.get(i); |
| | | if(order < Integer.parseInt(map.get("order").toString())){ |
| | | list.add(i, soundVo); |
| | | isAdd = true; |
| | | break; |