|
@ -1,5 +1,8 @@
|
|
|
package com.yihu.wlyy.web.patient.health;
|
|
|
|
|
|
import com.yihu.wlyy.entity.education.HealthEduArticleOpHistory;
|
|
|
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
|
|
|
import com.yihu.wlyy.service.app.health.HealthEduArticlePatientService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
@ -9,6 +12,7 @@ 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 com.yihu.wlyy.entity.education.HealthEduArticlePatient;
|
|
@ -27,7 +31,10 @@ import com.yihu.wlyy.web.BaseController;
|
|
|
public class HealthEduArticleController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private HealthEduArticleService healthEduArticleService;
|
|
|
private HealthEduArticlePatientService healthEduArticlePatientService;
|
|
|
|
|
|
@Autowired
|
|
|
private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
|
|
|
|
|
|
/**
|
|
|
* 查询文章列表
|
|
@ -36,9 +43,9 @@ public class HealthEduArticleController extends BaseController {
|
|
|
*/
|
|
|
@RequestMapping(value = "list")
|
|
|
@ResponseBody
|
|
|
public String list(long id, int pagesize) {
|
|
|
public String list(@RequestParam("id")long id, @RequestParam("pagesize") int pagesize) {
|
|
|
try {
|
|
|
Page<HealthEduArticlePatient> list = healthEduArticleService.findByPatient(getUID(), id, pagesize);
|
|
|
Page<HealthEduArticlePatient> list = healthEduArticlePatientService.findByPatient(getUID(), id, pagesize);
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
if (list != null) {
|
|
|
for (HealthEduArticlePatient article : list) {
|
|
@ -58,6 +65,15 @@ public class HealthEduArticleController extends BaseController {
|
|
|
json.put("read", article.getRead());
|
|
|
// 添加日期
|
|
|
json.put("czrq", DateUtil.dateToStrLong(article.getCzrq()));
|
|
|
int collectionAmount = healthEduArticleOpHistoryService.countCollectionAmount(article.getArticle());
|
|
|
int readAmount = healthEduArticleOpHistoryService.countReadAmount(article.getArticle());
|
|
|
int repeatAmount = healthEduArticleOpHistoryService.countRepeatAmount(article.getArticle());
|
|
|
//阅读量
|
|
|
json.put("readAmount", readAmount);
|
|
|
//收藏量
|
|
|
json.put("collectionAmount", collectionAmount);
|
|
|
//转发量
|
|
|
json.put("repeatAmount", repeatAmount);
|
|
|
jsonArray.put(json);
|
|
|
}
|
|
|
}
|
|
@ -67,7 +83,31 @@ public class HealthEduArticleController extends BaseController {
|
|
|
return invalidUserException(ex, -1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询文章列表
|
|
|
* @param article 数据文章唯一标示article
|
|
|
* @return 列表
|
|
|
*/
|
|
|
@RequestMapping(value = "article")
|
|
|
@ResponseBody
|
|
|
public String article(@RequestParam("article") String article) {
|
|
|
try {
|
|
|
//获取单条文章记录
|
|
|
HealthEduArticlePatient healthEduArticlePatient = healthEduArticlePatientService.findByArticle(article);
|
|
|
int isRead = healthEduArticleOpHistoryService.countByUserStatus(getUID(),HealthEduArticleOpHistory.READ_STATUS);
|
|
|
//插入文章读取状态第一次阅读记录浏览数量
|
|
|
if(isRead==0){
|
|
|
//更新浏览量
|
|
|
healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS,healthEduArticlePatient.getArticle(),healthEduArticlePatient.getTitle(),getUID());
|
|
|
//将文章更新为已读
|
|
|
healthEduArticlePatientService.updateRead(getUID(), article);
|
|
|
}
|
|
|
return write(200, "查询成功", "data", healthEduArticlePatient);
|
|
|
} catch (Exception ex) {
|
|
|
error(ex);
|
|
|
return invalidUserException(ex, -1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 更新文章为已读
|
|
|
* @param article 文章标识
|
|
@ -75,9 +115,9 @@ public class HealthEduArticleController extends BaseController {
|
|
|
*/
|
|
|
@RequestMapping(value = "read")
|
|
|
@ResponseBody
|
|
|
public String read(String article) {
|
|
|
public String read(@RequestParam("article") String article) {
|
|
|
try {
|
|
|
healthEduArticleService.updateRead(getUID(), article);
|
|
|
healthEduArticlePatientService.updateRead(getUID(), article);
|
|
|
return success("操作成功!");
|
|
|
} catch (Exception ex) {
|
|
|
error(ex);
|