|
@ -7,6 +7,10 @@ import com.yihu.wlyy.service.app.health.*;
|
|
|
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.htmlparser.Parser;
|
|
|
import org.htmlparser.beans.StringBean;
|
|
|
import org.htmlparser.util.ParserException;
|
|
|
import org.htmlparser.visitors.TextExtractingVisitor;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@ -18,7 +22,6 @@ 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 com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
@ -75,26 +78,29 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
json.put("title", article.getTitle());
|
|
|
// 文章查看URL
|
|
|
json.put("url", article.getUrl());
|
|
|
|
|
|
// 文章简介
|
|
|
json.put("content", article.getContent());
|
|
|
json.put("content", parsrHtml(article.getContent()));
|
|
|
// 添加日期
|
|
|
json.put("czrq", DateUtil.dateToStrLong(article.getCzrq()));
|
|
|
|
|
|
json.put("keyword", article.getKeyword());
|
|
|
json.put("keyword", StringUtils.isNotBlank(article.getKeyword())?article.getKeyword():"");
|
|
|
int collectionAmount = healthEduArticleOpHistoryService.countCollectionAmount(article.getCode());
|
|
|
int readAmount = healthEduArticleOpHistoryService.countReadAmount(article.getCode());
|
|
|
int repeatAmount = healthEduArticleOpHistoryService.countRepeatAmount(article.getCode());
|
|
|
HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(article.getCode(), getUID());
|
|
|
//阅读量
|
|
|
json.put("readAmount", readAmount);
|
|
|
//收藏量
|
|
|
json.put("collectionAmount", collectionAmount);
|
|
|
|
|
|
|
|
|
//转发量
|
|
|
json.put("repeatAmount", repeatAmount);
|
|
|
//是否收藏
|
|
|
json.put("collection",1);
|
|
|
|
|
|
if(healthEduArticleDoctor!=null){
|
|
|
json.put("collection",1);
|
|
|
}else{
|
|
|
json.put("collection",0);
|
|
|
}
|
|
|
jsonArray.put(json);
|
|
|
}
|
|
|
}
|
|
@ -115,7 +121,43 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
public String listDoctor(@RequestParam(value = "page",required = true)int page, @RequestParam(value = "pagesize",required = true)int pagesize,@RequestParam(value = "filter",required = false)String filter) {
|
|
|
try {
|
|
|
List<Object> list = healthEduArticleDoctorService.list(page, pagesize,filter,getUID());
|
|
|
return write(200, "查询成功", "list", list);
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
for(Object obj:list){
|
|
|
HealthEduArticle healthEduArticle= (HealthEduArticle)obj;
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", healthEduArticle.getId());
|
|
|
// 文章标识
|
|
|
json.put("code", healthEduArticle.getCode());
|
|
|
// 文章标题
|
|
|
json.put("title", healthEduArticle.getTitle());
|
|
|
// 文章查看URL
|
|
|
json.put("url", healthEduArticle.getUrl());
|
|
|
|
|
|
// 文章简介
|
|
|
json.put("content", parsrHtml(healthEduArticle.getContent()));
|
|
|
// 添加日期
|
|
|
json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
|
|
|
|
|
|
json.put("keyword", StringUtils.isNotBlank(healthEduArticle.getKeyword())?healthEduArticle.getKeyword():"");
|
|
|
int collectionAmount = healthEduArticleOpHistoryService.countCollectionAmount(healthEduArticle.getCode());
|
|
|
int readAmount = healthEduArticleOpHistoryService.countReadAmount(healthEduArticle.getCode());
|
|
|
int repeatAmount = healthEduArticleOpHistoryService.countRepeatAmount(healthEduArticle.getCode());
|
|
|
HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(healthEduArticle.getCode(), getUID());
|
|
|
//阅读量
|
|
|
json.put("readAmount", readAmount);
|
|
|
//收藏量
|
|
|
json.put("collectionAmount", collectionAmount);
|
|
|
//转发量
|
|
|
json.put("repeatAmount", repeatAmount);
|
|
|
//是否收藏
|
|
|
if(healthEduArticleDoctor!=null){
|
|
|
json.put("collection",1);
|
|
|
}else{
|
|
|
json.put("collection",0);
|
|
|
}
|
|
|
jsonArray.put(json);
|
|
|
}
|
|
|
return write(200, "查询成功", "list", jsonArray);
|
|
|
} catch (Exception ex) {
|
|
|
error(ex);
|
|
|
return invalidUserException(ex, -1, "查询失败!");
|
|
@ -162,13 +204,20 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
json.put("code", healthEduArticle.getCode());
|
|
|
// 文章标题
|
|
|
json.put("title", healthEduArticle.getTitle());
|
|
|
|
|
|
json.put("url", healthEduArticle.getUrl());
|
|
|
// 文章内容
|
|
|
json.put("content", healthEduArticle.getContent());
|
|
|
// 添加日期
|
|
|
json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
|
|
|
int readAmount = healthEduArticleOpHistoryService.countReadAmount(code);
|
|
|
json.put("readAmount",readAmount);
|
|
|
json.put("collection",1);
|
|
|
HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(healthEduArticle.getCode(), getUID());
|
|
|
if(healthEduArticleDoctor==null){
|
|
|
json.put("collection",0);
|
|
|
}else{
|
|
|
json.put("collection",1);
|
|
|
}
|
|
|
return write(200, "查询成功", "data", json);
|
|
|
} catch (Exception ex) {
|
|
|
error(ex);
|
|
@ -324,6 +373,7 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
public String uncollectionArticle(@RequestParam(value = "article",required = true)String article){
|
|
|
try{
|
|
|
healthEduArticleDoctorService.delete(article,getUID());
|
|
|
|
|
|
return success("取消收藏成功!");
|
|
|
}catch (Exception e){
|
|
|
error(e);
|
|
@ -331,4 +381,15 @@ public class DoctorHealthEduArticleController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private String parsrHtml(String html) throws ParserException{
|
|
|
Parser parser = null;
|
|
|
try{
|
|
|
parser = new Parser(html);
|
|
|
}catch (ParserException e){
|
|
|
return html;//纯文本内容会转换失败,直接返回文本内容
|
|
|
}
|
|
|
TextExtractingVisitor visitor = new TextExtractingVisitor();
|
|
|
parser.visitAllNodesWith(visitor);
|
|
|
return StringUtils.isNotBlank(visitor.getExtractedText())?visitor.getExtractedText():"内容为图集,请点击查看";
|
|
|
}
|
|
|
}
|