|
@ -0,0 +1,199 @@
|
|
|
|
package com.yihu.wlyy.web.third.jkedu.controller.doctor;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
|
import com.yihu.wlyy.service.app.account.DoctorInfoService;
|
|
|
|
import com.yihu.wlyy.web.BaseController;
|
|
|
|
import com.yihu.wlyy.web.third.jkedu.vo.ArticleModel;
|
|
|
|
import com.yihu.wlyy.web.third.jkedu.vo.CategoryModel;
|
|
|
|
import com.yihu.wlyy.web.third.jkedu.vo.base.BaseResultModel;
|
|
|
|
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.apache.commons.lang.StringUtils;
|
|
|
|
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.net.URLEncoder;
|
|
|
|
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;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private DoctorInfoService doctorInfoService;
|
|
|
|
|
|
|
|
@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://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Category.getCategoryList&Param={\"categoryLevel\":\""+categoryLevel+"\"}&AuthInfo={ClientId:\"9000276\"}";
|
|
|
|
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")));
|
|
|
|
|
|
|
|
return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode));
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode)+","+e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "/saveArticleCollection",method = RequestMethod.POST)
|
|
|
|
@ApiOperation("APP端--医生添加收藏文章")
|
|
|
|
@ResponseBody
|
|
|
|
public BaseResultModel saveArticleCollection(
|
|
|
|
@ApiParam(name = "ArticleId",value = "文章id")@RequestParam(value = "ArticleId")String ArticleId,
|
|
|
|
@ApiParam(name = "articleCategoryId",value = "文章类别id")@RequestParam(value = "articleCategoryId")String articleCategoryId,
|
|
|
|
@ApiParam(name = "articleCategoryName", value = "文章类别名称")@RequestParam(value = "articleCategoryName")String articleCategoryName) {
|
|
|
|
|
|
|
|
int errCode = 0;
|
|
|
|
try {
|
|
|
|
//调用福州接口
|
|
|
|
String url = "http://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Behavior.saveArticleCollection&" +
|
|
|
|
"Param={\"userType\":\"1\",\"articleId\":\"" + ArticleId + "\",\"articleCategoryId\":\"" + articleCategoryId + "\",\"articleCategoryName\":\"" + articleCategoryName + "\",";
|
|
|
|
//获取医生的id
|
|
|
|
String userId = getUID();
|
|
|
|
Doctor doctor = doctorInfoService.findDoctorByCode(userId);
|
|
|
|
if(doctor!=null){
|
|
|
|
url+="\"userId\":\"" + doctor.getCode() + "\",\"cName\":\""+doctor.getName()+"\"," +
|
|
|
|
"\"orgName\":\""+doctor.getHospitalName()+"\",\"orgId\":\""+doctor.getHospital()+"\"}&AuthInfo={ClientId:\"9000276\"}";
|
|
|
|
}
|
|
|
|
String jsonStr = HttpUtil.sendPost(url, "");
|
|
|
|
//结果转map
|
|
|
|
if(StringUtils.isNotBlank(jsonStr)){
|
|
|
|
Map<String, Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
|
|
|
|
System.out.println(map);
|
|
|
|
if ("10000".equals(String.valueOf(map.get("Code")))) {
|
|
|
|
return new BaseResultModel(10000,ErrorStateMessage.getMessge(10000));
|
|
|
|
} else {
|
|
|
|
errCode = Integer.valueOf(String.valueOf(map.get("Code")));
|
|
|
|
return new BaseResultModel(errCode, ErrorStateMessage.getMessge(errCode));
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
return new BaseResultModel(0,"远程请求过程出错");
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
return new BaseResultModel(errCode, ErrorStateMessage.getMessge(errCode) + "," + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "/cancelArticleCollection",method = RequestMethod.POST)
|
|
|
|
@ApiOperation("APP端--医生取消收藏文章")
|
|
|
|
@ResponseBody
|
|
|
|
public BaseResultModel cancelArticleCollection(
|
|
|
|
@ApiParam(name = "articleId",value = "文章id")@RequestParam(value = "articleId")String articleId,
|
|
|
|
@ApiParam(name = "userId",value = "用户id")@RequestParam(value = "userId")String userId,
|
|
|
|
@ApiParam(name = "userType",value = "1医生2居民")@RequestParam(value = "userType")String userType) {
|
|
|
|
|
|
|
|
int errCode = 0;
|
|
|
|
try {
|
|
|
|
//调用福州接口
|
|
|
|
String url = "http://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Behavior.cancelArticleCollection&" +
|
|
|
|
"Param={\"articleId\":\"" + articleId + "\",\"userId\":\"" + userId + "\",\"userType\":\"" + userType + "\"}&AuthInfo={ClientId:\"9000276\"}";
|
|
|
|
String jsonStr = HttpUtil.sendPost(url, "");
|
|
|
|
//结果转map
|
|
|
|
Map<String, Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
|
|
|
|
System.out.println(map);
|
|
|
|
if ("10000".equals(String.valueOf(map.get("Code")))) {
|
|
|
|
return new BaseResultModel(10000,"成功!");
|
|
|
|
} else {
|
|
|
|
errCode = Integer.valueOf(String.valueOf(map.get("Code")));
|
|
|
|
if (errCode == -10000) {
|
|
|
|
return new BaseResultModel(-10000, "没有找到相应的数据");
|
|
|
|
}else{
|
|
|
|
return new BaseResultModel(errCode, ErrorStateMessage.getMessge(errCode));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
return new BaseResultModel(errCode, ErrorStateMessage.getMessge(errCode) + "," + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getCollectionArticalList",method = RequestMethod.POST)
|
|
|
|
@ApiOperation("APP端--医生收藏文章列表")
|
|
|
|
@ResponseBody
|
|
|
|
public ResultListModel getCollectionArticalList(
|
|
|
|
@ApiParam(name = "articleTitle",value = "文章标题",required = false)@RequestParam(value = "articleTitle",required = false)String articleTitle,
|
|
|
|
@ApiParam(name = "firstLevelCategoryId",value = "一级类别ID ,多个逗号隔开",required = false)@RequestParam(value = "firstLevelCategoryId",required = false)String firstLevelCategoryId,
|
|
|
|
@ApiParam(name = "pageIndex",value = "起始页数 0开始,默认0",required = false)@RequestParam(value = "pageIndex",required = false)String pageIndex,
|
|
|
|
@ApiParam(name = "userType",value = "1医生2居民")@RequestParam(value = "userType")String userType,
|
|
|
|
@ApiParam(name = "userId",value = "用户id",required = false)@RequestParam(value = "userId",required = false)String userId){
|
|
|
|
|
|
|
|
int errCode =0;
|
|
|
|
int pageNo=0;
|
|
|
|
int pageSize=5;
|
|
|
|
try {
|
|
|
|
//调用福州接口
|
|
|
|
String url ="http://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Article.getCollectionArticalList&Param={\"articleState\":\"1\",\"pageSize\":\""+pageSize+"\",";
|
|
|
|
if(org.apache.commons.lang.StringUtils.isNotBlank(articleTitle)){
|
|
|
|
url += "\"articleTitle\":\""+articleTitle+"\",";
|
|
|
|
}
|
|
|
|
if(org.apache.commons.lang.StringUtils.isNotBlank(firstLevelCategoryId)){
|
|
|
|
url += "\"firstLevelCategoryId\":\""+firstLevelCategoryId+"\",";
|
|
|
|
}
|
|
|
|
if(org.apache.commons.lang.StringUtils.isNotBlank(pageIndex)){
|
|
|
|
pageNo=Integer.valueOf(pageIndex);
|
|
|
|
url += "\"pageIndex\":\""+pageNo+"\",";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(userType) && "2".equals(userType)){
|
|
|
|
url += "\"userType\":\""+userType+",\"userId\":\""+getRepUID()+"\"}&AuthInfo={ClientId:\"9000276\"}";
|
|
|
|
}else if (StringUtils.isNotBlank(userType) && "1".equals(userType)){
|
|
|
|
url += "\"userType\":\""+userType+",\"userId\":\""+getUID()+"\"}&AuthInfo={ClientId:\"9000276\"}";
|
|
|
|
}
|
|
|
|
String jsonStr = HttpUtil.sendPost(url,"");
|
|
|
|
//结果转map
|
|
|
|
Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
|
|
|
|
System.out.println(map);
|
|
|
|
List<ArticleModel> list = new ArrayList<ArticleModel>();
|
|
|
|
if("10000".equals(String.valueOf(map.get("Code")))){
|
|
|
|
String result = String.valueOf(map.get("Result"));
|
|
|
|
String resultStr = String.valueOf(result);
|
|
|
|
JSONArray jsonArray = JSONArray.fromObject(resultStr);
|
|
|
|
list = (List<ArticleModel>) JSONArray.toCollection(jsonArray, ArticleModel.class);//转换成列表
|
|
|
|
return new ResultListModel(list);
|
|
|
|
}else{
|
|
|
|
errCode =Integer.valueOf(String.valueOf(map.get("Code")));
|
|
|
|
return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode));
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode)+","+e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|