我有一个后端REST API,我将其转换为Springboot Rest API。 我的springboot java模型未加载后端API值。 MemberSummaryModel没有填充API值。所有值都为空。 我想知道如何处理其中带有body标签的后端APi。
来自后端API的示例响应如下
Sample Response:
{
"body": {
"pcp": "KASSAM, Far",
"er12M": "0",
"ipAdmits12M": "0",
"ipReAdmits12M": "0",
"rx12M": "0",
"pastMedicalHistory": " ",
"erCost12M": "0.0"
}
}
SpringBoot应用程序代码如下:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;
import org.springframework.web.client.RestTemplate;
import com.mc.membersphere.model.MemberSummaryModel;
import com.mc.membersphere.utility.PropertyUtil;
@Repository("memberSphereDAOImpl")
public class MemberSphereDAOImpl implements IMemberSphereDAO{
private final Logger logger =
org.apache.log4j.Logger.getLogger(this.getClass());
private static Properties prop = PropertyUtil.getProperties();
@Override
public List<MemberSummaryModel> getMemberSummary(String mySearch, String state) {
logger.info("Entering Service method getMemberSummary");
RestTemplate restTemplate = new RestTemplate();
List<MemberSummaryModel> memberList = new ArrayList<MemberSummaryModel>();
try {
String getMVPSummaryUrl = prop.getProperty("getmvpmembersummary.url");
String url = getMVPSummaryUrl+mySearch+"/"+state;
logger.info("getMemberSummary"+url);
MemberSummaryModel members = restTemplate.getForObject(url, MemberSummaryModel.class);
memberList = Arrays.asList(members);
} catch(Exception e) {
logger.error("Exception",e);
}
logger.info("Exiting Service method getMemberSummary");
logger.info("Number of Members retrieved"+memberList.size());
return memberList;
}
}