浏览代码

新增宣教--收藏文章列表,新增收藏

zd_123 7 年之前
父节点
当前提交
d97c444a56

+ 0 - 100
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/EduDoctorArticleController.java

@ -1,100 +0,0 @@
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.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.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")));
                return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode));
            }
        }catch (Exception e){
            return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode)+","+e.getMessage());
        }
    }
    @RequestMapping(value = "/cancelArticleCollection",method = RequestMethod.POST)
    @ApiOperation("APP端--医生取消收藏文章")
    @ResponseBody
    public BaseResultModel saveArticleCollection(
            @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://service.yihu.com:8085/WsPlatform/rest?Api=JkEdu.Behavior.cancelArticleCollection&" +
                    "Param={\"articleId\":\"" + articleId + "\",\"userId\":\"" + userId + "\",\"userType\":\"" + userType + "\"}";
            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());
        }
    }
}

+ 199 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/doctor/EduDoctorArticleController.java

@ -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());
        }
    }
}

+ 8 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/patient/EduArticleController.java

@ -26,21 +26,21 @@ import java.util.Map;
/**
/**
 * Created by Administrator on 2017/9/30.
 * Created by zhangdan on 2017/9/30.
 */
 */
@Controller
@Controller
@Api(description = "居民端--健康宣教文章")
@Api(description = "居民端--健康宣教文章")
@RequestMapping(value = "/wlyygc/patient/jkedu",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/wlyygc/patient/jkedu",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class EduArticleController extends BaseController{
public class EduPatientArticleController extends BaseController{
    @Autowired
    @Autowired
    private FamilyContractService familyContractService;
    private FamilyContractService familyContractService;
    @Autowired
    @Autowired
    private com.yihu.wlyy.util.HttpUtil HttpUtil;
    private com.yihu.wlyy.util.HttpUtil HttpUtil;
    @RequestMapping(value = "/getDoctorArticalList",method = RequestMethod.POST)
    @ApiOperation("获取医生主页中的文章列表(获取卫计委认证文章+医生发表未认证文章)")
    @RequestMapping(value = "/getDoctorArticalByUserId",method = RequestMethod.POST)
    @ApiOperation("获取医生主页中的文章列表(医生发表文章接口)")
    @ResponseBody
    @ResponseBody
    public ResultListModel<List<ArticleModel>> getDoctorArticalList(
    public ResultListModel<List<ArticleModel>> getDoctorArticalByUserId(
            @ApiParam(name = "articleTitle",value = "文章标题",required = false)@RequestParam(value = "articleTitle",required = false)String articleTitle,
            @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 = "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 = "pageIndex",value = "起始页数 0开始,默认0",required = false)@RequestParam(value = "pageIndex",required = false)String pageIndex){
@ -49,7 +49,7 @@ public class EduArticleController extends BaseController{
        int pageSize=5;
        int pageSize=5;
        try {
        try {
            //调用福州接口
            //调用福州接口
            String url ="http://service.yihu.com:8085/WsPlatform/rest?Api=JkEdu.Article.getDoctorArticalList&Param={\"articleState\":\"1\",\"pageSize\":\""+pageSize+"\",";
            String url ="http://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Article.getDoctorArticalByUserId&Param={\"articleState\":\"1\",\"pageSize\":\""+pageSize+"\",";
            if(org.apache.commons.lang.StringUtils.isNotBlank(articleTitle)){
            if(org.apache.commons.lang.StringUtils.isNotBlank(articleTitle)){
                url += "\"articleTitle\":\""+articleTitle+"\",";
                url += "\"articleTitle\":\""+articleTitle+"\",";
            }
            }
@ -60,10 +60,8 @@ public class EduArticleController extends BaseController{
                pageNo=Integer.valueOf(pageIndex);
                pageNo=Integer.valueOf(pageIndex);
                url += "\"pageIndex\":\""+pageNo+"\",";
                url += "\"pageIndex\":\""+pageNo+"\",";
            }
            }
            /*if(StringUtils.isEmpty(userId)){
                userId=getRepUID();
            }*/
            url += "\"userId\":\""+getRepUID()+"\"}";
            String doctor = familyContractService.checkPatient(getRepUID());
            url += "\"userId\":\""+doctor+"\"}&AuthInfo={ClientId:\"9000276\"}";
            String jsonStr = HttpUtil.sendPost(url,"");
            String jsonStr = HttpUtil.sendPost(url,"");
            //结果转map
            //结果转map
            Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
            Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
@ -83,7 +81,5 @@ public class EduArticleController extends BaseController{
            e.printStackTrace();
            e.printStackTrace();
            return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode)+","+e.getMessage());
            return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode)+","+e.getMessage());
        }
        }
    }
    }
}
}