利用枚舉類進行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