利用枚举类进行json输出key value数据格式


public ResponseData customerType() {

ResponseData res = new ResponseData();
try {
CustomerTypeEnums[] customerTypeEnums = CustomerTypeEnums.values();
List<Map<String,String>> list = new ArrayList<>();
for (CustomerTypeEnums customerType : customerTypeEnums){
Map<String,String> map = new HashMap<>();
map.put("custName",customerType.getCustName());
map.put("custCode",customerType.getCustCode());
list.add(map);
}
return ResponseData.ok(list,"查询成功");
} catch (Exception e) {
log.info("查询失败",e.getMessage());
res = ResponseData.fail("查询失败");
}
return res;
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM