zoukankan      html  css  js  c++  java
  • 查询枚举类型的示例接口

    @RestController
    public class EnumTableController {
    
        private HashMap unflat(Object[] list) {
            HashMap<String, Object> ret = new HashMap<>();
            for (int i = 0 ; i < list.length; i += 2) { // 每次步进2,装载key-value
                ret.put((String)list[i], list[i + 1]);
            }
            return ret;
        }
    
        @ApiOperation(value = "查询全部枚举类型", notes = "")
        @GetMapping("/public/enum/table")
        public Map listEnumTable() {
            HashMap<String, Object> ret = new HashMap<>();  //拼接成HashMap<String,List<Map>>
            ret.put("RepositoryFeature", Arrays.stream(Constants.RepositoryFeature.values())
                    .map(x -> unflat(new Object[]{"name", x.name(), "code", x.getCode(), "desc", x.getName()})));
            ret.put("UserTitleEnum", Arrays.stream(Constants.UserTitleEnum.values())
                    .map(x -> unflat(new Object[]{"name", x.name(), "desc", x.getDesc()})));
            ret.put("VisitType", Arrays.stream(Constants.VisitType.values())
                    .map(x -> unflat(new Object[]{"name", x.name(), "desc", x.getDesc()})));
            ret.put("AdminLogType", Arrays.stream(Constants.AdminLogType.values())
                    .map(x -> unflat(new Object[]{"name", x.name(), "desc", x.getDesc()})));
            ret.put("RepoStatus", Arrays.stream(Constants.RepoStatus.values())
                    .map(x -> unflat(new Object[]{"name", x.name(), "desc", x.getDesc()})));
            return ret;
        }
    
    }
    
  • 相关阅读:
    HDU 5919 分块做法
    HDU 3333 分块求区间不同数和
    CF 333E 计算几何+bitset优化
    hdu 1043 八数码--打表
    hdu 1043 八数码问题-A*搜索
    hdu 5919 主席树
    hiho1388 FFT/NTT
    HDU 5869区间CGD不同种类数---树状数组+map统计区间不同种类数(离线)
    HDU 5875 二分+st表
    HDU 5898 基础数位DP
  • 原文地址:https://www.cnblogs.com/brxHqs/p/11288904.html
Copyright © 2011-2022 走看看