98 lines
3.6 KiB
Java
98 lines
3.6 KiB
Java
package com.example.caseData.controller;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.example.caseData.common.Response;
|
|
import com.example.caseData.dao.CaseExchangeDao;
|
|
import com.example.caseData.dao.StatsCaseExchangeDao;
|
|
import com.example.caseData.dao.StatsCaseExchangeUserDao;
|
|
import com.example.caseData.dao.StatsCaseExchangeUserDao;
|
|
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
|
|
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
|
|
import com.example.caseData.dto.statsCaseClinical.StatsCaseClinicalDto;
|
|
import com.example.caseData.dto.statsCaseExchange.StatsCaseExchangeDto;
|
|
import com.example.caseData.dto.statsCaseExchange.StatsCaseExchangeDto;
|
|
import com.example.caseData.dto.statsCaseExchangeUser.StatsCaseExchangeUserDto;
|
|
import com.example.caseData.model.StatsCaseExchangeUserModel;
|
|
import com.example.caseData.model.StatsCaseExchangeModel;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@RequestMapping("/api")
|
|
public class StatsCaseExchangeController extends BaseController {
|
|
@Resource
|
|
private StatsCaseExchangeDao statsCaseExchangeDao;
|
|
|
|
@Resource
|
|
private CaseExchangeDao caseExchangeDao;
|
|
|
|
@Resource
|
|
private StatsCaseExchangeUserDao statsCaseExchangeUserDao;
|
|
|
|
@Resource
|
|
private HttpServletRequest httpServletRequest;
|
|
|
|
/**
|
|
* 病例交流-统计
|
|
*/
|
|
@GetMapping("/exchange/stats")
|
|
public Response<StatsCaseExchangeDto> getClinicalStats(){
|
|
LambdaQueryWrapper<StatsCaseExchangeModel> statsCaseExchangeQueryWrapper = new LambdaQueryWrapper<>();
|
|
StatsCaseExchangeModel statsCaseExchange = statsCaseExchangeDao.selectOne(statsCaseExchangeQueryWrapper);
|
|
|
|
StatsCaseExchangeDto g = StatsCaseExchangeDto.GetDto(statsCaseExchange);
|
|
|
|
if (g == null){
|
|
return Response.success(new StatsCaseExchangeDto());
|
|
}
|
|
|
|
Long totalCommentNum = caseExchangeDao.getTotalCommentNum();
|
|
g.setExchangeCommentNum(Math.toIntExact(totalCommentNum));
|
|
|
|
return Response.success(g);
|
|
}
|
|
|
|
/**
|
|
* 病例交流-用户
|
|
*/
|
|
@GetMapping("/exchange/stats/user")
|
|
public Response<StatsCaseExchangeUserDto> getClinicalStatsUser(){
|
|
String userId = (String) httpServletRequest.getAttribute("userId");
|
|
if (userId == null) {
|
|
return Response.error();
|
|
}
|
|
|
|
LambdaQueryWrapper<StatsCaseExchangeUserModel> queryWrapper = new LambdaQueryWrapper<>();
|
|
queryWrapper.eq(StatsCaseExchangeUserModel::getUserId, userId);
|
|
StatsCaseExchangeUserModel statsCaseExchangeUser = statsCaseExchangeUserDao.selectOne(queryWrapper);
|
|
|
|
StatsCaseExchangeUserDto g = StatsCaseExchangeUserDto.GetDto(statsCaseExchangeUser);
|
|
if (g == null){
|
|
return Response.success(new StatsCaseExchangeUserDto());
|
|
}
|
|
|
|
Integer readNum = 0;
|
|
|
|
// 获取该标签下文章数据
|
|
List<CaseExchangeDto> caseExchanges = caseExchangeDao.getCaseExchangeSearchList(
|
|
"",
|
|
userId,
|
|
null,
|
|
null
|
|
);
|
|
for (CaseExchangeDto caseExchange : caseExchanges){
|
|
readNum += caseExchange.getReadNum();
|
|
}
|
|
|
|
g.setExchangeReadNum(readNum);
|
|
|
|
return Response.success(g);
|
|
}
|
|
}
|