package com.glxp.api.res.alihealth; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import lombok.Data; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import java.util.Objects; @Data public class AlihealthKytGetentinfoResponse extends AlihealthKytCommonParametersResponse{ private String ent_id; private String network_type; private String ref_ent_id; public AlihealthKytGetentinfoResponse(String json) { // 初始化请求的值 cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(json); JSONObject jsonObjectResult = null; for (String s : jsonObject.keySet()) { jsonObjectResult = jsonObject.getJSONObject(s).getJSONObject("result"); } AlihealthKytCommonParametersResponse alihealthKytCommonParametersResponse = JSONUtil.toBean(jsonObjectResult.toString(), AlihealthKytCommonParametersResponse.class); BeanUtils.copyProperties(alihealthKytCommonParametersResponse,this); if(StringUtils.isNotEmpty(this.getMsg_info()) && this.getMsg_info().equals("调用成功") ){ this.disposeResult(jsonObjectResult); } } public void disposeResult(JSONObject jsonObjectResult){ JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); if (!Objects.isNull(jsonObjectModel)) { this.setEnt_id(jsonObjectModel.getStr("ent_id")); this.setNetwork_type(jsonObjectModel.getStr("network_type")); this.setRef_ent_id(jsonObjectModel.getStr("ref_ent_id")); } } }