|
@ -0,0 +1,70 @@
|
|
|
package com.yihu.wlyy.web.third.jkedu.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.yihu.wlyy.web.BaseController;
|
|
|
import com.yihu.wlyy.web.third.jkedu.vo.CategoryModel;
|
|
|
import com.yihu.wlyy.web.third.jkedu.vo.state.ErrorStateMessage;
|
|
|
import com.yihu.wlyy.web.third.jkedu.vo.base.ResultListModel;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import net.sf.json.JSONArray;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by Zhang Dan on 2017/9/29.
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/wlyygc/doctor/jkedu",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@Api(description = "App端医生--健康教育")
|
|
|
public class EduDoctorArticleController extends BaseController{
|
|
|
|
|
|
@Autowired
|
|
|
private com.yihu.wlyy.util.HttpUtil HttpUtil;
|
|
|
|
|
|
@RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
|
|
|
@ApiOperation("获取文章类别")
|
|
|
@ResponseBody
|
|
|
public ResultListModel<List<CategoryModel>> getCategoryList(
|
|
|
@ApiParam(name = "categoryLevel",value = "获取类别:1、一级类别 2、二级类别",required = false)@RequestParam(value = "categoryLevel")String categoryLevel){
|
|
|
|
|
|
int errCode =0;
|
|
|
try {
|
|
|
//调用福州接口
|
|
|
String url ="http://service.yihu.com:8085/WsPlatform/rest?Api=JkEdu.Category.getCategoryList&Param={\"categoryLevel\":\""+categoryLevel+"\"}";
|
|
|
String jsonStr = HttpUtil.sendPost(url,"");
|
|
|
//结果转map
|
|
|
Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
|
|
|
System.out.println(map);
|
|
|
List<CategoryModel> list = new ArrayList<CategoryModel>();
|
|
|
if("10000".equals(String.valueOf(map.get("Code")))){
|
|
|
String result = String.valueOf(map.get("Result"));
|
|
|
Map<String,Object> resultMap = JSON.parseObject(result);
|
|
|
String resultStr = String.valueOf(resultMap.get("result"));
|
|
|
JSONArray jsonArray = JSONArray.fromObject(resultStr);
|
|
|
list = (List<CategoryModel>) JSONArray.toCollection(jsonArray, CategoryModel.class);//转换成列表
|
|
|
return new ResultListModel(list);
|
|
|
}else{
|
|
|
errCode =Integer.valueOf(String.valueOf(map.get("Code")));
|
|
|
if(errCode<0){
|
|
|
errCode=-10000;
|
|
|
}
|
|
|
return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode));
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode)+","+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|