This commit is contained in:
wucongxing8150 2025-07-18 13:28:55 +08:00
parent f53e5b5d65
commit 579c81e553
2 changed files with 59 additions and 3 deletions

View File

@ -187,12 +187,19 @@ public class CaseExchangeService {
} }
// 新增病例交流统计 // 新增病例交流统计
if (!handleStatsCaseExchange()){ StatsCaseExchangeModel statsCaseExchangeData = new StatsCaseExchangeModel();
statsCaseExchangeData.setExchangeNum(1);
res = statsCaseExchangeDao.insert(statsCaseExchangeData);
if (res <= 0){
throw new BusinessException("操作失败"); throw new BusinessException("操作失败");
} }
// 新增病例交流统计-用户 // 新增病例交流统计-用户
if (!handleStatsCaseExchangeUser(userId,"exchange_num")){ StatsCaseExchangeUserModel statsCaseExchangeUserData = new StatsCaseExchangeUserModel();
statsCaseExchangeUserData.setUserId(Long.valueOf(userId));
statsCaseExchangeUserData.setExchangeNum(1);
res = statsCaseExchangeUserDao.insert(statsCaseExchangeUserData);
if (res <= 0){
throw new BusinessException("操作失败"); throw new BusinessException("操作失败");
} }
@ -513,6 +520,52 @@ public class CaseExchangeService {
return true; return true;
} }
/**
* 新增病例交流统计
* @param userId 用户id
* @param type 类型1:阅读量 2收藏量 3:评论数 4:数量
*/
@Transactional
public boolean IncClinicalVideoStats(String userId,Integer type){
try {
LambdaQueryWrapper<StatsCaseExchangeUserModel> mapQueryWrapper = new LambdaQueryWrapper<>();
mapQueryWrapper.eq(StatsCaseExchangeUserModel::getUserId, userId);
StatsCaseExchangeUserModel statsCaseExchangeUser = statsCaseExchangeUserDao.selectOne(mapQueryWrapper);
if (statsCaseExchangeUser == null){
throw new BusinessException("操作失败");
}
// 阅读量
if (type == 1){
statsCaseExchangeDao.inc(1L,"exchange_read_num",1);
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getStatsId(),"exchange_read_num",1);
}
// 收藏量
if (type == 2){
statsCaseExchangeDao.inc(1L,"exchange_collect_num",1);
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getStatsId(),"exchange_collect_num",1);
}
// 评论数
if (type == 3){
statsCaseExchangeDao.inc(1L,"exchange_collect_num",1);
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getStatsId(),"exchange_collect_num",1);
}
// 文章数量-只加个人的
if (type == 3){
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getStatsId(),"exchange_num",1);
}
return true;
} catch (Exception e) {
return false;
}
}
/** /**
* 新增投票-病例交流 * 新增投票-病例交流
* @param exchangeId 病例交流id * @param exchangeId 病例交流id

View File

@ -42,6 +42,9 @@ public class UserCaseReadService {
@Resource @Resource
private CaseClinicalVideoService caseClinicalVideoService; private CaseClinicalVideoService caseClinicalVideoService;
@Resource
private CaseExchangeService caseExchangeService;
/** /**
* 浏览记录-新增 * 浏览记录-新增
* @return bool * @return bool
@ -90,7 +93,7 @@ public class UserCaseReadService {
// 病例交流 // 病例交流
if (request.getType() == 3){ if (request.getType() == 3){
caseExchangeDao.inc(Long.valueOf(request.getId()),"read_num",1); caseExchangeService.IncClinicalVideoStats(userId,1);
} }
return true; return true;