|
@ -0,0 +1,95 @@
|
|
|
package com.yihu.wlyy.web.third.zysoft;
|
|
|
|
|
|
import com.yihu.wlyy.entity.education.HealthEduArticle;
|
|
|
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.web.BaseController;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 提供给智业调用的健康教育文章相关的接口:
|
|
|
* @author huangwenjie
|
|
|
* @date 2017/10/17 09:05
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/wlyygc/zy/healthedu/article/")
|
|
|
public class ZyHealthEduArticleController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private HealthEduArticleService healthEduArticleService;
|
|
|
|
|
|
/**
|
|
|
* 查询健康教育文章列表
|
|
|
* @param titlefilter 文章标题搜索条件
|
|
|
* @param keywordfilter 关键字搜索条件
|
|
|
* @param contentfilter 文章内容搜索条件
|
|
|
* @param page 第几页(第一页传0)
|
|
|
* @param pagesize 分页大小
|
|
|
* @return 列表
|
|
|
*/
|
|
|
@ApiOperation("基卫查询健康教育文章列表")
|
|
|
@RequestMapping(value = "list",method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
public String list(@RequestParam(value = "page", required = true) int page,
|
|
|
@RequestParam(value = "pagesize", required = true) int pagesize,
|
|
|
@RequestParam(value = "titlefilter", required = false) String titlefilter,
|
|
|
@RequestParam(value = "keywordfilter", required = false) String keywordfilter,
|
|
|
@RequestParam(value = "contentfilter", required = false) String contentfilter) {
|
|
|
try {
|
|
|
List<Map<String, Object>> list = healthEduArticleService.zyfindAll(page, pagesize, titlefilter, keywordfilter, contentfilter);
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
if (list != null) {
|
|
|
for (Map<String, Object> map : list) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", map.get("id"));
|
|
|
// 文章标识
|
|
|
json.put("code", map.get("code"));
|
|
|
// 文章标题
|
|
|
json.put("title", map.get("title"));
|
|
|
// 文章配图URL
|
|
|
json.put("url", map.get("url"));
|
|
|
// 文章简介
|
|
|
json.put("content", String.valueOf(map.get("content"))==null?"":map.get("content"));
|
|
|
// 添加日期
|
|
|
json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
|
|
|
// 关键字
|
|
|
json.put("keyword", map.get("keyword") == null ? "" : map.get("keyword"));
|
|
|
// 阅读量
|
|
|
json.put("readAmount", map.get("readAmount"));
|
|
|
// 收藏量
|
|
|
json.put("collectionAmount", map.get("collectionAmount"));
|
|
|
// 转发量
|
|
|
json.put("repeatAmount", map.get("repeatAmount"));
|
|
|
|
|
|
jsonArray.put(json);
|
|
|
}
|
|
|
}
|
|
|
return write(200, "查询成功", "list", jsonArray);
|
|
|
} catch (Exception ex) {
|
|
|
error(ex);
|
|
|
return invalidUserException(ex, -1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "getArticalByCode",method = RequestMethod.GET)
|
|
|
@ApiOperation("获取健康教育文章详情")
|
|
|
public String getArticalById(@ApiParam(name = "articleCode", value = "教育文章Code",defaultValue = "1")
|
|
|
@RequestParam(value = "articleCode", required = true) String articleCode){
|
|
|
try {
|
|
|
HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(articleCode);
|
|
|
return write(200,"查询成功!","data",healthEduArticle);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"查询失败!");
|
|
|
}
|
|
|
}
|
|
|
}
|