fix: switch nursing info to dedicated /published endpoint
- Use /system/nursing/published instead of /system/user/getAppIndexInfo - Simpler JSON structure: data array directly at root level - Avoid race condition with getAppUserInfo/initDatatwo callbacks - Field mapping: title→content, imageUrl→pic, articleUrl→url, content→articleBody Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -151,7 +151,7 @@ public class HomeFragment extends BaseFragment {
|
||||
* 获取护理资讯
|
||||
*/
|
||||
private void initNursingInfo() {
|
||||
OkGo.<String>get(HttpConstants.URi_system_getAppIndexInfo)
|
||||
OkGo.<String>get(HttpConstants.URi_system_nursing_published)
|
||||
.converter(new StringConvert())
|
||||
.cacheMode(CacheMode.NO_CACHE)
|
||||
.adapt(new ObservableResponse<String>())
|
||||
@@ -177,28 +177,23 @@ public class HomeFragment extends BaseFragment {
|
||||
toast("护理资讯code=" + code);
|
||||
return;
|
||||
}
|
||||
JSONObject data = json.getJSONObject("data");
|
||||
if (data != null) {
|
||||
JSONArray realTimeInfoList = data.getJSONArray("realTimeInfoList");
|
||||
if (realTimeInfoList != null && realTimeInfoList.size() > 0) {
|
||||
List<homeListBean> list = new ArrayList<>();
|
||||
for (int i = 0; i < realTimeInfoList.size(); i++) {
|
||||
JSONObject item = realTimeInfoList.getJSONObject(i);
|
||||
homeListBean bean = new homeListBean();
|
||||
bean.setContent(item.getString("title"));
|
||||
bean.setPic(item.getString("realTimeInfoImage"));
|
||||
bean.setUrl(item.getString("realTimeInfoUrl"));
|
||||
bean.setArticleBody(item.getString("content"));
|
||||
list.add(bean);
|
||||
}
|
||||
robCustomerInfoBean.setNursingInfoList(list);
|
||||
adapter.notifyDataSetChanged();
|
||||
toast("护理资讯加载了" + list.size() + "条");
|
||||
} else {
|
||||
toast("realTimeInfoList为空");
|
||||
JSONArray arr = json.getJSONArray("data");
|
||||
if (arr != null && arr.size() > 0) {
|
||||
List<homeListBean> list = new ArrayList<>();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject item = arr.getJSONObject(i);
|
||||
homeListBean bean = new homeListBean();
|
||||
bean.setContent(item.getString("title"));
|
||||
bean.setPic(item.getString("imageUrl"));
|
||||
bean.setUrl(item.getString("articleUrl"));
|
||||
bean.setArticleBody(item.getString("content"));
|
||||
list.add(bean);
|
||||
}
|
||||
robCustomerInfoBean.setNursingInfoList(list);
|
||||
adapter.notifyDataSetChanged();
|
||||
toast("护理资讯加载了" + list.size() + "条");
|
||||
} else {
|
||||
toast("data字段为null");
|
||||
toast("护理资讯列表为空");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("护理资讯", "解析失败", e);
|
||||
|
||||
@@ -36,6 +36,11 @@ public class HttpConstants {
|
||||
*/
|
||||
public static String URi_system_getAppIndexInfo = URiBase + "/system/user/getAppIndexInfo";
|
||||
|
||||
/**
|
||||
* 护理资讯已发布列表(无需认证)
|
||||
*/
|
||||
public static String URi_system_nursing_published = URiBase + "/system/nursing/published";
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user