77777
This commit is contained in:
parent
88ee5ad694
commit
55f9b8f634
@ -229,7 +229,7 @@ public class CaseExchangeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 新增统计字段
|
// 新增统计字段
|
||||||
boolean r = IncCaseExchangeStats(exchangeId,userId,2);
|
boolean r = IncCaseExchangeStats(exchangeId,2);
|
||||||
if (!r){
|
if (!r){
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
return false;
|
return false;
|
||||||
@ -260,7 +260,7 @@ public class CaseExchangeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 减少文章的统计字段
|
// 减少文章的统计字段
|
||||||
boolean r = DecCaseExchangeStats(exchangeId,userId,2);
|
boolean r = DecCaseExchangeStats(exchangeId,2);
|
||||||
if (!r){
|
if (!r){
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
return false;
|
return false;
|
||||||
@ -318,7 +318,7 @@ public class CaseExchangeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 新增统计字段
|
// 新增统计字段
|
||||||
boolean r = IncCaseExchangeStats(exchangeId,userId,2);
|
boolean r = IncCaseExchangeStats(exchangeId,2);
|
||||||
if (!r){
|
if (!r){
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
return false;
|
return false;
|
||||||
@ -364,7 +364,7 @@ public class CaseExchangeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 减少统计字段
|
// 减少统计字段
|
||||||
boolean r = DecCaseExchangeStats(String.valueOf(comment.getExchangeId()),userId,2);
|
boolean r = DecCaseExchangeStats(String.valueOf(comment.getExchangeId()),2);
|
||||||
if (!r){
|
if (!r){
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
return false;
|
return false;
|
||||||
@ -537,20 +537,38 @@ public class CaseExchangeService {
|
|||||||
|
|
||||||
// 阅读量
|
// 阅读量
|
||||||
if (type == 1){
|
if (type == 1){
|
||||||
|
// 总
|
||||||
statsCaseExchangeDao.inc(1L,"exchange_read_num",1);
|
statsCaseExchangeDao.inc(1L,"exchange_read_num",1);
|
||||||
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getStatsId(),"exchange_read_num",1);
|
|
||||||
|
// 单
|
||||||
|
caseExchangeDao.inc(Long.valueOf(exchangeId),"read_num",1);
|
||||||
|
|
||||||
|
// 用户-此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
||||||
|
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getUserId(),"exchange_read_num",1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收藏量
|
// 收藏量
|
||||||
if (type == 2){
|
if (type == 2){
|
||||||
|
// 总
|
||||||
statsCaseExchangeDao.inc(1L,"exchange_collect_num",1);
|
statsCaseExchangeDao.inc(1L,"exchange_collect_num",1);
|
||||||
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getStatsId(),"exchange_collect_num",1);
|
|
||||||
|
// 单
|
||||||
|
caseExchangeDao.inc(Long.valueOf(exchangeId),"collect_num",1);
|
||||||
|
|
||||||
|
// 用户-此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
||||||
|
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getUserId(),"exchange_collect_num",1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 评论数
|
// 评论数
|
||||||
if (type == 3){
|
if (type == 3){
|
||||||
statsCaseExchangeDao.inc(1L,"exchange_collect_num",1);
|
// 总
|
||||||
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getStatsId(),"exchange_collect_num",1);
|
statsCaseExchangeDao.inc(1L,"exchange_comment_num",1);
|
||||||
|
|
||||||
|
// 单
|
||||||
|
caseExchangeDao.inc(Long.valueOf(exchangeId),"comment_num",1);
|
||||||
|
|
||||||
|
// 用户-此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
||||||
|
statsCaseExchangeUserDao.inc(statsCaseExchangeUser.getUserId(),"exchange_comment_num",1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -559,6 +577,68 @@ public class CaseExchangeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 减少病例交流统计字段
|
||||||
|
* @param exchangeId 病例id
|
||||||
|
* @param type 类型:1:阅读量 2:收藏量 3:评论数
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
public boolean DecCaseExchangeStats(String exchangeId,Integer type){
|
||||||
|
try {
|
||||||
|
// 获取病例数据
|
||||||
|
CaseExchangeModel caseExchange = caseExchangeDao.selectById(exchangeId);
|
||||||
|
if (caseExchange == null){
|
||||||
|
throw new BusinessException("操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<StatsCaseExchangeUserModel> mapQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
mapQueryWrapper.eq(StatsCaseExchangeUserModel::getUserId, caseExchange.getUserId());
|
||||||
|
StatsCaseExchangeUserModel statsCaseExchangeUser = statsCaseExchangeUserDao.selectOne(mapQueryWrapper);
|
||||||
|
if (statsCaseExchangeUser == null){
|
||||||
|
throw new BusinessException("操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 阅读量
|
||||||
|
if (type == 1){
|
||||||
|
// 总
|
||||||
|
statsCaseExchangeDao.dec(1L,"exchange_read_num",1);
|
||||||
|
|
||||||
|
// 单
|
||||||
|
caseExchangeDao.dec(Long.valueOf(exchangeId),"read_num",1);
|
||||||
|
|
||||||
|
// 用户
|
||||||
|
statsCaseExchangeUserDao.dec(statsCaseExchangeUser.getUserId(),"exchange_read_num",1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收藏量
|
||||||
|
if (type == 2){
|
||||||
|
// 总
|
||||||
|
statsCaseExchangeDao.dec(1L,"exchange_collect_num",1);
|
||||||
|
|
||||||
|
// 单
|
||||||
|
caseExchangeDao.dec(Long.valueOf(exchangeId),"collect_num",1);
|
||||||
|
|
||||||
|
// 用户
|
||||||
|
statsCaseExchangeUserDao.dec(statsCaseExchangeUser.getUserId(),"exchange_collect_num",1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 评论数
|
||||||
|
if (type == 3){
|
||||||
|
// 总
|
||||||
|
statsCaseExchangeDao.dec(1L,"exchange_comment_num",1);
|
||||||
|
|
||||||
|
// 单
|
||||||
|
caseExchangeDao.dec(Long.valueOf(exchangeId),"comment_num",1);
|
||||||
|
|
||||||
|
// 用户
|
||||||
|
statsCaseExchangeUserDao.dec(statsCaseExchangeUser.getUserId(),"exchange_comment_num",1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增投票-病例交流
|
* 新增投票-病例交流
|
||||||
@ -618,87 +698,96 @@ public class CaseExchangeService {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 新增病例交流的统计字段
|
// * 新增病例交流的统计字段
|
||||||
* @param exchangeId id
|
// * @param exchangeId id
|
||||||
* @param type 类型:1:阅读量 2:收藏量 3:评论数
|
// * @param type 类型:1:阅读量 2:收藏量 3:评论数
|
||||||
*/
|
// */
|
||||||
@Transactional
|
// @Transactional
|
||||||
public boolean IncCaseExchangeStats(String exchangeId,String userId,Integer type){
|
// public boolean IncCaseExchangeStats(String exchangeId,String userId,Integer type){
|
||||||
try {
|
// try {
|
||||||
// 阅读量
|
// // 阅读量
|
||||||
if (type == 1){
|
// if (type == 1){
|
||||||
caseExchangeDao.inc(Long.valueOf(exchangeId),"read_num",1);
|
// // 单
|
||||||
statsCaseExchangeDao.inc(1L,"exchange_read_num",1);
|
// caseExchangeDao.inc(Long.valueOf(exchangeId),"read_num",1);
|
||||||
|
//
|
||||||
// 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
// // 总
|
||||||
statsCaseExchangeUserDao.inc(Long.valueOf(userId),"exchange_read_num",1);
|
// statsCaseExchangeDao.inc(1L,"exchange_read_num",1);
|
||||||
}
|
//
|
||||||
|
// // 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
||||||
// 收藏量
|
// statsCaseExchangeUserDao.inc(Long.valueOf(userId),"exchange_read_num",1);
|
||||||
if (type == 2){
|
// }
|
||||||
caseExchangeDao.inc(Long.valueOf(exchangeId),"collect_num",1);
|
//
|
||||||
statsCaseExchangeDao.inc(1L,"exchange_collect_num",1);
|
// // 收藏量
|
||||||
|
// if (type == 2){
|
||||||
// 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
// // 单
|
||||||
statsCaseExchangeUserDao.inc(Long.valueOf(userId),"exchange_collect_num",1);
|
// caseExchangeDao.inc(Long.valueOf(exchangeId),"collect_num",1);
|
||||||
}
|
//
|
||||||
|
// // 总
|
||||||
// 评论数
|
// statsCaseExchangeDao.inc(1L,"exchange_collect_num",1);
|
||||||
if (type == 3){
|
//
|
||||||
caseExchangeDao.inc(Long.valueOf(exchangeId),"comment_num",1);
|
// // 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
||||||
statsCaseExchangeDao.inc(1L,"exchange_comment_num",1);
|
// statsCaseExchangeUserDao.inc(Long.valueOf(userId),"exchange_collect_num",1);
|
||||||
|
// }
|
||||||
// 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
//
|
||||||
statsCaseExchangeUserDao.inc(Long.valueOf(userId),"exchange_comment_num",1);
|
// // 评论数
|
||||||
}
|
// if (type == 3){
|
||||||
|
// // 单
|
||||||
return true;
|
// caseExchangeDao.inc(Long.valueOf(exchangeId),"comment_num",1);
|
||||||
} catch (Exception e) {
|
//
|
||||||
return false;
|
// // 总
|
||||||
}
|
// statsCaseExchangeDao.inc(1L,"exchange_comment_num",1);
|
||||||
}
|
//
|
||||||
|
// // 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
||||||
/**
|
// statsCaseExchangeUserDao.inc(Long.valueOf(userId),"exchange_comment_num",1);
|
||||||
* 减少文章的统计字段
|
// }
|
||||||
* @param exchangeId id
|
//
|
||||||
* @param type 类型:1:阅读量 2:收藏量 3:评论数
|
// return true;
|
||||||
*/
|
// } catch (Exception e) {
|
||||||
@Transactional
|
// return false;
|
||||||
public boolean DecCaseExchangeStats(String exchangeId,String userId,Integer type){
|
// }
|
||||||
try {
|
// }
|
||||||
// 阅读量
|
//
|
||||||
if (type == 1){
|
// /**
|
||||||
caseExchangeDao.dec(Long.valueOf(exchangeId),"read_num",1);
|
// * 减少文章的统计字段
|
||||||
statsCaseExchangeDao.dec(1L,"exchange_read_num",1);
|
// * @param exchangeId id
|
||||||
|
// * @param type 类型:1:阅读量 2:收藏量 3:评论数
|
||||||
// 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
// */
|
||||||
statsCaseExchangeUserDao.dec(Long.valueOf(userId),"exchange_read_num",1);
|
// @Transactional
|
||||||
}
|
// public boolean DecCaseExchangeStats(String exchangeId,String userId,Integer type){
|
||||||
|
// try {
|
||||||
// 收藏量
|
// // 阅读量
|
||||||
if (type == 2){
|
// if (type == 1){
|
||||||
caseExchangeDao.inc(Long.valueOf(exchangeId),"collect_num",1);
|
// caseExchangeDao.dec(Long.valueOf(exchangeId),"read_num",1);
|
||||||
statsCaseExchangeDao.dec(1L,"exchange_collect_num",1);
|
// statsCaseExchangeDao.dec(1L,"exchange_read_num",1);
|
||||||
|
//
|
||||||
// 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
// // 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
||||||
statsCaseExchangeUserDao.dec(Long.valueOf(userId),"exchange_collect_num",1);
|
// statsCaseExchangeUserDao.dec(Long.valueOf(userId),"exchange_read_num",1);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 评论数
|
// // 收藏量
|
||||||
if (type == 3){
|
// if (type == 2){
|
||||||
caseExchangeDao.inc(Long.valueOf(exchangeId),"comment_num",1);
|
// caseExchangeDao.inc(Long.valueOf(exchangeId),"collect_num",1);
|
||||||
statsCaseExchangeDao.dec(1L,"exchange_comment_num",1);
|
// statsCaseExchangeDao.dec(1L,"exchange_collect_num",1);
|
||||||
|
//
|
||||||
// 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
// // 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
||||||
statsCaseExchangeUserDao.dec(Long.valueOf(userId),"exchange_comment_num",1);
|
// statsCaseExchangeUserDao.dec(Long.valueOf(userId),"exchange_collect_num",1);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return true;
|
// // 评论数
|
||||||
} catch (Exception e) {
|
// if (type == 3){
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
// caseExchangeDao.inc(Long.valueOf(exchangeId),"comment_num",1);
|
||||||
return false;
|
// statsCaseExchangeDao.dec(1L,"exchange_comment_num",1);
|
||||||
}
|
//
|
||||||
}
|
// // 此处无需担心stats_case_exchange_user无数据,发布病例时会新增
|
||||||
|
// statsCaseExchangeUserDao.dec(Long.valueOf(userId),"exchange_comment_num",1);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return true;
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user