730 lines
28 KiB
Java
730 lines
28 KiB
Java
package com.example.caseData.service;
|
||
|
||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
import com.example.caseData.dao.*;
|
||
import com.example.caseData.exception.BusinessException;
|
||
import com.example.caseData.extend.app.Base;
|
||
import com.example.caseData.extend.app.UserInfo.GetUserInfoResponse;
|
||
import com.example.caseData.extend.app.UserInfo.UserInfo;
|
||
import com.example.caseData.extend.app.UserPoint.UserPoint;
|
||
import com.example.caseData.extend.app.Video.Video;
|
||
import com.example.caseData.model.*;
|
||
import com.example.caseData.model.UserCollectClinicalVideoModel;
|
||
import com.example.caseData.request.CaseClinicalVideoRequest.addClinicalVideoApp;
|
||
import com.example.caseData.request.CaseClinicalVideoRequest.addClinicalVideoComment;
|
||
import com.example.caseData.utils.Replace;
|
||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||
import jakarta.annotation.Resource;
|
||
import jakarta.servlet.http.HttpServletRequest;
|
||
import jakarta.validation.ConstraintViolation;
|
||
import jakarta.validation.Validation;
|
||
import jakarta.validation.Validator;
|
||
import org.apache.commons.io.IOUtils;
|
||
import org.springframework.stereotype.Service;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||
|
||
import java.lang.reflect.Field;
|
||
import java.nio.charset.StandardCharsets;
|
||
import java.time.LocalDateTime;
|
||
import java.util.*;
|
||
|
||
//import static com.baomidou.mybatisplus.extension.toolkit.Db.removeById;
|
||
//import static com.baomidou.mybatisplus.extension.toolkit.Db.save;
|
||
|
||
@Service
|
||
public class CaseClinicalVideoService {
|
||
@Resource
|
||
private UserCollectClinicalVideoDao userCollectClinicalVideoDao;
|
||
|
||
@Resource
|
||
private CaseClinicalVideoDao caseClinicalVideoDao;
|
||
|
||
@Resource
|
||
private CaseClinicalVideoLabelDao caseClinicalVideoLabelDao;
|
||
|
||
@Resource
|
||
private StatsCaseClinicalDao statsCaseClinicalDao;
|
||
|
||
@Resource
|
||
private UserDao userDao;
|
||
|
||
@Resource
|
||
private StatsCaseClinicalHospitalDao statsCaseClinicalHospitalDao;
|
||
|
||
@Resource
|
||
private StatsCaseClinicalDoctorDao statsCaseClinicalDoctorDao;
|
||
|
||
@Resource
|
||
private CaseClinicalVideoAuthorDao caseClinicalVideoAuthorDao;
|
||
|
||
@Resource
|
||
private CaseClinicalDoctorDao caseClinicalDoctorDao;
|
||
|
||
@Resource
|
||
private BasicSensitiveWordService basicSensitiveWordService;
|
||
|
||
@Resource
|
||
private UserCommentClinicalVideoDao userCommentClinicalVideoDao;
|
||
|
||
@Resource
|
||
private CaseClinicalLabelService caseClinicalLabelService;
|
||
|
||
@Resource
|
||
private StatsCaseClinicalLabelDao statsCaseClinicalLabelDao;
|
||
|
||
@Resource
|
||
private Video Video;
|
||
|
||
@Resource
|
||
private UserInfo userInfo;
|
||
|
||
@Resource
|
||
private UserService userService;
|
||
|
||
@Resource
|
||
private CaseClinicalService caseClinicalService;
|
||
|
||
/**
|
||
* 新增收藏-临床病例库-视频
|
||
* @param videoId 视频id
|
||
* @param userId 用户id
|
||
* @return bool
|
||
*/
|
||
@Transactional
|
||
public boolean AddClinicalVideoCollect(String videoId,String userId){
|
||
// 检测用户是否已收藏过
|
||
UserCollectClinicalVideoModel userCollectClinicalVideo = getUserCollectClinicalVideoStatus(videoId,userId);
|
||
if (userCollectClinicalVideo != null) {
|
||
return true;
|
||
}
|
||
|
||
// 新增收藏
|
||
UserCollectClinicalVideoModel userCollectClinicalVideoData = new UserCollectClinicalVideoModel();
|
||
userCollectClinicalVideoData.setUserId(Long.valueOf(userId));
|
||
userCollectClinicalVideoData.setVideoId(Long.valueOf(videoId));
|
||
int res = userCollectClinicalVideoDao.insert(userCollectClinicalVideoData);
|
||
if (res <= 0){
|
||
return false;
|
||
}
|
||
|
||
// 新增统计字段
|
||
boolean r = IncClinicalVideoStats(videoId,2);
|
||
if (!r){
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 取消收藏-临床病例库-视频
|
||
* @param videoId 视频id
|
||
* @param userId 用户id
|
||
* @return bool
|
||
*/
|
||
@Transactional
|
||
public boolean DeleteClinicalVideoCollect(String videoId,String userId){
|
||
// 检测用户是否已收藏过
|
||
UserCollectClinicalVideoModel userCollectClinicalVideo = getUserCollectClinicalVideoStatus(videoId,userId);
|
||
if (userCollectClinicalVideo == null) {
|
||
return true;
|
||
}
|
||
|
||
// 删除收藏
|
||
int res = userCollectClinicalVideoDao.deleteById(userCollectClinicalVideo.getCollectId());
|
||
if (res <= 0){
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return false;
|
||
}
|
||
|
||
// 减少视频的统计字段
|
||
boolean r = DecClinicalVideoStats(videoId,2);
|
||
if (!r){
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 新增评论-临床病例库-视频
|
||
* @param videoId 视频id
|
||
* @param userId 用户id
|
||
* @return bool
|
||
*/
|
||
@Transactional
|
||
public boolean AddClinicalVideoComment(String videoId, String userId, addClinicalVideoComment request){
|
||
// 获取视频数据
|
||
CaseClinicalVideoModel video = caseClinicalVideoDao.selectById(videoId);
|
||
if (video == null) {
|
||
throw new BusinessException("非法视频");
|
||
}
|
||
|
||
if (video.getVideoStatus() != 1){
|
||
throw new BusinessException("非法视频");
|
||
}
|
||
|
||
// 处理评论内容
|
||
BasicSensitiveWordService.FilterResult result = basicSensitiveWordService.filter(request.getContent());
|
||
if (result.hasSensitive == 1){
|
||
throw new BusinessException("存在敏感词,请修改后提交");
|
||
}
|
||
|
||
// 新增评论
|
||
UserCommentClinicalVideoModel userCommentClinicalVideoData = new UserCommentClinicalVideoModel();
|
||
userCommentClinicalVideoData.setUserId(Long.valueOf(userId));
|
||
userCommentClinicalVideoData.setVideoId(Long.valueOf(videoId));
|
||
userCommentClinicalVideoData.setStatus(1);
|
||
userCommentClinicalVideoData.setIsSensitive(0);
|
||
userCommentClinicalVideoData.setContent(request.getContent());
|
||
userCommentClinicalVideoData.setCommentImage(Replace.removeOssDomain(request.getCommentImage()));
|
||
|
||
// 评论根id
|
||
if (request.getRootId() != null) {
|
||
userCommentClinicalVideoData.setRootId(Long.valueOf(request.getRootId()));
|
||
}
|
||
|
||
// 评论父级id
|
||
if (request.getParentId() != null) {
|
||
userCommentClinicalVideoData.setParentId(Long.valueOf(request.getParentId()));
|
||
}
|
||
|
||
int res = userCommentClinicalVideoDao.insert(userCommentClinicalVideoData);
|
||
if (res <= 0){
|
||
return false;
|
||
}
|
||
|
||
// 新增文章的统计字段
|
||
boolean r = IncClinicalVideoStats(videoId,3);
|
||
if (!r){
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 删除评论-临床病例库-视频
|
||
* @param commentId 评论id
|
||
* @param userId 用户id
|
||
* @return bool
|
||
*/
|
||
@Transactional
|
||
public boolean DeleteClinicalVideoComment(String commentId, String userId){
|
||
// 获取评论数据
|
||
UserCommentClinicalVideoModel comment = userCommentClinicalVideoDao.selectById(commentId);
|
||
if (comment == null) {
|
||
return false;
|
||
}
|
||
|
||
// 获取视频数据
|
||
CaseClinicalVideoModel video = caseClinicalVideoDao.selectById(comment.getVideoId());
|
||
if (video == null) {
|
||
return false;
|
||
}
|
||
|
||
if (video.getVideoStatus() != 1){
|
||
return false;
|
||
}
|
||
|
||
// 检测用户是否视频作者
|
||
boolean isAuthor = checkUserIsVideoAuthor(String.valueOf(video.getVideoId()),userId);
|
||
if (!isAuthor) {
|
||
return false;
|
||
}
|
||
|
||
// 删除评论
|
||
int res = userCommentClinicalVideoDao.deleteById(comment.getCommentId());
|
||
if (res <= 0){
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return false;
|
||
}
|
||
|
||
// 减少文章的统计字段
|
||
boolean r = DecClinicalVideoStats(String.valueOf(comment.getVideoId()),2);
|
||
if (!r){
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 置顶评论-临床病例库-视频
|
||
* @param commentId 评论id
|
||
* @param userId 用户id
|
||
* @return bool
|
||
*/
|
||
@Transactional
|
||
public boolean AddTopClinicalVideoComment(String commentId, String userId){
|
||
// 获取评论数据
|
||
UserCommentClinicalVideoModel comment = userCommentClinicalVideoDao.selectById(commentId);
|
||
if (comment == null) {
|
||
return false;
|
||
}
|
||
|
||
// 获取视频数据
|
||
CaseClinicalVideoModel video = caseClinicalVideoDao.selectById(comment.getVideoId());
|
||
if (video == null) {
|
||
return false;
|
||
}
|
||
|
||
if (video.getVideoStatus() != 1){
|
||
return false;
|
||
}
|
||
|
||
// 检测用户是否视频作者
|
||
boolean isAuthor = checkUserIsVideoAuthor(String.valueOf(comment.getVideoId()),userId);
|
||
if (!isAuthor) {
|
||
return false;
|
||
}
|
||
|
||
if (comment.getIsTop() == 1){
|
||
return true;
|
||
}
|
||
|
||
// 置顶评论
|
||
comment.setIsTop(1);
|
||
userCommentClinicalVideoDao.updateById(comment);
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 取消置顶评论-临床病例库-视频
|
||
* @param commentId 评论id
|
||
* @param userId 用户id
|
||
* @return bool
|
||
*/
|
||
@Transactional
|
||
public boolean deleteTopClinicalVideoComment(String commentId, String userId){
|
||
// 获取评论数据
|
||
UserCommentClinicalVideoModel comment = userCommentClinicalVideoDao.selectById(commentId);
|
||
if (comment == null) {
|
||
return false;
|
||
}
|
||
|
||
// 获取视频数据
|
||
CaseClinicalVideoModel video = caseClinicalVideoDao.selectById(comment.getVideoId());
|
||
if (video == null) {
|
||
return false;
|
||
}
|
||
|
||
if (video.getVideoStatus() != 1){
|
||
return false;
|
||
}
|
||
|
||
// 检测用户是否视频作者
|
||
boolean isAuthor = checkUserIsVideoAuthor(String.valueOf(comment.getVideoId()),userId);
|
||
if (!isAuthor) {
|
||
return false;
|
||
}
|
||
|
||
// 取消置顶评论
|
||
if (comment.getIsTop() == 0){
|
||
return true;
|
||
}
|
||
|
||
// 置顶评论
|
||
comment.setIsTop(0);
|
||
userCommentClinicalVideoDao.updateById(comment);
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 检测用户是否视频作者
|
||
* @param videoId 视频id
|
||
* @param userId 用户id
|
||
* @return bool 是否作者
|
||
*/
|
||
public boolean checkUserIsVideoAuthor(String videoId,String userId){
|
||
// 获取当前登录用户数据
|
||
UserModel user = userDao.selectById(Long.valueOf(userId));
|
||
if (user == null) {
|
||
return false;
|
||
}
|
||
|
||
// 当前用户是否是作者之一
|
||
boolean isAuthor = false;
|
||
|
||
// 获取视频作者数据
|
||
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, videoId);
|
||
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
|
||
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
|
||
// 查询医生
|
||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||
if (caseClinicalDoctor == null) {
|
||
return false;
|
||
}
|
||
|
||
if (Objects.equals(caseClinicalDoctor.getDoctorIden(), user.getUserIden())){
|
||
isAuthor = true;
|
||
}
|
||
}
|
||
|
||
return isAuthor;
|
||
}
|
||
|
||
/**
|
||
* 获取用户收藏数据
|
||
* @param videoId 视频id
|
||
* @param userId 用户id
|
||
* @return bool false:未收藏 true:已收藏
|
||
*/
|
||
public UserCollectClinicalVideoModel getUserCollectClinicalVideoStatus(String videoId, String userId){
|
||
// 检测用户是否已收藏过
|
||
LambdaQueryWrapper<UserCollectClinicalVideoModel> mapQueryWrapper = new LambdaQueryWrapper<>();
|
||
mapQueryWrapper.eq(UserCollectClinicalVideoModel::getUserId, userId);
|
||
mapQueryWrapper.eq(UserCollectClinicalVideoModel::getVideoId, videoId);
|
||
|
||
return userCollectClinicalVideoDao.selectOne(mapQueryWrapper);
|
||
}
|
||
|
||
/**
|
||
* 新增视频的统计字段
|
||
* @param videoId 视频id
|
||
* @param type 类型:1:阅读量 2:收藏量 3:评论数 4:文章数
|
||
*/
|
||
@Transactional
|
||
public boolean IncClinicalVideoStats(String videoId,Integer type){
|
||
try {
|
||
String caseClinicalVideoField = ""; // 具体文章
|
||
String statsCaseClinicalField = ""; // 全部文章
|
||
String statsCaseClinicalHospitalField = ""; // 医院
|
||
String statsCaseClinicalDoctorField = ""; // 医生
|
||
String statsCaseClinicalLabelField = ""; // 标签
|
||
|
||
// 阅读
|
||
if (type == 1){
|
||
caseClinicalVideoField = "read_num"; // 具体文章
|
||
statsCaseClinicalField = "video_read_num"; // 全部文章
|
||
statsCaseClinicalHospitalField = "video_read_num"; // 医院
|
||
statsCaseClinicalDoctorField = "video_read_num"; // 医生
|
||
statsCaseClinicalLabelField = "article_read_num"; // 标签
|
||
}
|
||
|
||
// 收藏
|
||
if (type == 2){
|
||
caseClinicalVideoField = "collect_num"; // 具体文章
|
||
statsCaseClinicalField = "video_collect_num"; // 全部文章
|
||
statsCaseClinicalHospitalField = "video_collect_num"; // 医院
|
||
statsCaseClinicalDoctorField = "video_collect_num"; // 医生
|
||
statsCaseClinicalLabelField = "article_collect_num"; // 标签
|
||
}
|
||
|
||
// 评论
|
||
if (type == 3){
|
||
caseClinicalVideoField = "comment_num"; // 具体文章
|
||
statsCaseClinicalField = "video_comment_num"; // 全部文章
|
||
statsCaseClinicalHospitalField = "video_comment_num"; // 医院
|
||
statsCaseClinicalDoctorField = "video_comment_num"; // 医生
|
||
statsCaseClinicalLabelField = "article_comment_num"; // 标签
|
||
}
|
||
|
||
// 文章数
|
||
if (type == 4){
|
||
statsCaseClinicalField = "article_num"; // 全部文章
|
||
statsCaseClinicalHospitalField = "article_num"; // 医院
|
||
statsCaseClinicalDoctorField = "article_num"; // 医生
|
||
statsCaseClinicalLabelField = "article_num"; // 标签
|
||
}
|
||
|
||
if (!caseClinicalVideoField.isEmpty()){
|
||
caseClinicalVideoDao.inc(Long.valueOf(videoId),caseClinicalVideoField,1);
|
||
}
|
||
|
||
statsCaseClinicalDao.inc(1L,statsCaseClinicalField,1);
|
||
|
||
// 获取文章作者
|
||
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, videoId);
|
||
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
|
||
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
|
||
// 查询医生
|
||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||
|
||
// 获取医院统计数据
|
||
statsCaseClinicalHospitalDao.inc(caseClinicalDoctor.getHospitalId(),statsCaseClinicalHospitalField,1);
|
||
statsCaseClinicalDoctorDao.inc(caseClinicalDoctor.getDoctorId(),statsCaseClinicalDoctorField,1);
|
||
}
|
||
|
||
// 获取文章标签数据
|
||
LambdaQueryWrapper<CaseClinicalVideoLabelModel> labelQueryWrapper = new LambdaQueryWrapper<>();
|
||
labelQueryWrapper.eq(CaseClinicalVideoLabelModel::getVideoId, videoId);
|
||
List<CaseClinicalVideoLabelModel> caseClinicalArticleLabels = caseClinicalVideoLabelDao.selectList(labelQueryWrapper);
|
||
for (CaseClinicalVideoLabelModel label : caseClinicalArticleLabels) {
|
||
statsCaseClinicalLabelDao.inc(label.getAppIden(),statsCaseClinicalLabelField,1);
|
||
}
|
||
|
||
return true;
|
||
} catch (Exception e) {
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return false;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 减少视频的统计字段
|
||
* @param videoId 文章id
|
||
* @param type 类型:1:阅读量 2:收藏量 3:评论数 4:文章数
|
||
*/
|
||
@Transactional
|
||
public boolean DecClinicalVideoStats(String videoId,Integer type){
|
||
try {
|
||
String caseClinicalVideoField = ""; // 具体文章
|
||
String statsCaseClinicalField = ""; // 全部文章
|
||
String statsCaseClinicalHospitalField = ""; // 医院
|
||
String statsCaseClinicalDoctorField = ""; // 医生
|
||
String statsCaseClinicalLabelField = ""; // 标签
|
||
|
||
// 阅读
|
||
if (type == 1){
|
||
caseClinicalVideoField = "read_num"; // 具体文章
|
||
statsCaseClinicalField = "video_read_num"; // 全部文章
|
||
statsCaseClinicalHospitalField = "video_read_num"; // 医院
|
||
statsCaseClinicalDoctorField = "video_read_num"; // 医生
|
||
statsCaseClinicalLabelField = "article_read_num"; // 标签
|
||
}
|
||
|
||
// 收藏
|
||
if (type == 2){
|
||
caseClinicalVideoField = "collect_num"; // 具体文章
|
||
statsCaseClinicalField = "video_collect_num"; // 全部文章
|
||
statsCaseClinicalHospitalField = "video_collect_num"; // 医院
|
||
statsCaseClinicalDoctorField = "video_collect_num"; // 医生
|
||
statsCaseClinicalLabelField = "article_collect_num"; // 标签
|
||
}
|
||
|
||
// 评论
|
||
if (type == 3){
|
||
caseClinicalVideoField = "comment_num"; // 具体文章
|
||
statsCaseClinicalField = "video_comment_num"; // 全部文章
|
||
statsCaseClinicalHospitalField = "video_comment_num"; // 医院
|
||
statsCaseClinicalDoctorField = "video_comment_num"; // 医生
|
||
statsCaseClinicalLabelField = "article_comment_num"; // 标签
|
||
}
|
||
|
||
// 文章数
|
||
if (type == 4){
|
||
statsCaseClinicalField = "article_num"; // 全部文章
|
||
statsCaseClinicalHospitalField = "article_num"; // 医院
|
||
statsCaseClinicalDoctorField = "article_num"; // 医生
|
||
statsCaseClinicalLabelField = "article_num"; // 标签
|
||
}
|
||
|
||
if (!caseClinicalVideoField.isEmpty()){
|
||
caseClinicalVideoDao.dec(Long.valueOf(videoId),caseClinicalVideoField,1);
|
||
}
|
||
|
||
statsCaseClinicalDao.dec(1L,statsCaseClinicalField,1);
|
||
|
||
// 获取文章作者
|
||
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, videoId);
|
||
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
|
||
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
|
||
// 查询医生
|
||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||
|
||
// 获取医院统计数据
|
||
statsCaseClinicalHospitalDao.dec(caseClinicalDoctor.getHospitalId(),statsCaseClinicalHospitalField,1);
|
||
statsCaseClinicalDoctorDao.dec(caseClinicalDoctor.getDoctorId(),statsCaseClinicalDoctorField,1);
|
||
}
|
||
|
||
// 获取文章标签数据
|
||
LambdaQueryWrapper<CaseClinicalVideoLabelModel> labelQueryWrapper = new LambdaQueryWrapper<>();
|
||
labelQueryWrapper.eq(CaseClinicalVideoLabelModel::getVideoId, videoId);
|
||
List<CaseClinicalVideoLabelModel> caseClinicalArticleLabels = caseClinicalVideoLabelDao.selectList(labelQueryWrapper);
|
||
for (CaseClinicalVideoLabelModel label : caseClinicalArticleLabels) {
|
||
statsCaseClinicalLabelDao.dec(label.getAppIden(),statsCaseClinicalLabelField,1);
|
||
}
|
||
|
||
return true;
|
||
} catch (Exception e) {
|
||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||
return false;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 检测作品状态
|
||
*/
|
||
public boolean checkClinicalVideoStatus(CaseClinicalVideoModel caseClinicalVideo){
|
||
// 删除状态
|
||
if (caseClinicalVideo.getDeleteStatus() == 1){
|
||
return false;
|
||
}
|
||
|
||
// 状态(1:正常 2:禁用)
|
||
if (caseClinicalVideo.getVideoStatus() == 2){
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 临床病例库-视频-同步app视频
|
||
* @return bool
|
||
*/
|
||
@Transactional
|
||
public boolean AddClinicalVideoApp(HttpServletRequest request){
|
||
try {
|
||
// 1. 手动读取请求体并转为 addClinicalVideoApp 对象
|
||
ObjectMapper objectMapper = new ObjectMapper();
|
||
addClinicalVideoApp r = objectMapper.readValue(request.getInputStream(), addClinicalVideoApp.class);
|
||
|
||
// 2. 自动校验(@Validated)
|
||
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
|
||
Set<ConstraintViolation<addClinicalVideoApp>> violations = validator.validate(r);
|
||
if (!violations.isEmpty()) {
|
||
String errorMessage = violations.iterator().next().getMessage();
|
||
throw new BusinessException("-1", errorMessage);
|
||
}
|
||
|
||
// 检测签名
|
||
Video.checkSign(request,"26e8675f44565b1ed4eaaa0fcf3531d7",r,objectMapper);
|
||
|
||
|
||
// // 获取视频数据
|
||
// LambdaQueryWrapper<CaseClinicalVideoModel> videoQueryWrapper = new LambdaQueryWrapper<>();
|
||
// videoQueryWrapper.eq(CaseClinicalVideoModel::getVideoNo, r.getVideoNo());
|
||
// CaseClinicalVideoModel caseClinicalVideo = caseClinicalVideoDao.selectOne(videoQueryWrapper);
|
||
//
|
||
// // 修改
|
||
// if (Objects.equals(r.getAction(), "update")){
|
||
// if (caseClinicalVideo == null){
|
||
// r.setAction("add");
|
||
// }
|
||
// }
|
||
//
|
||
// // 新增
|
||
// if (Objects.equals(r.getAction(), "add")){
|
||
// if (caseClinicalVideo != null){
|
||
// // 已存在该视频
|
||
// return true;
|
||
// }
|
||
//
|
||
// // 新增视频
|
||
// caseClinicalVideo = new CaseClinicalVideoModel();
|
||
// caseClinicalVideo.setVideoTitle(r.getVideoTitle());
|
||
// caseClinicalVideo.setVideoNo(r.getVideoNo());
|
||
// caseClinicalVideo.setPushDate(LocalDateTime.parse(r.getPushDate()));
|
||
// caseClinicalVideo.setIsLink(r.getIsLink());
|
||
// caseClinicalVideo.setIsLinkUrl(r.getIsLinkUrl());
|
||
// int res = caseClinicalVideoDao.insert(caseClinicalVideo);
|
||
// if (res <= 0){
|
||
// throw new BusinessException("-1", "内部错误,添加视频失败");
|
||
// }
|
||
//
|
||
// // 新增标签
|
||
// for (addClinicalVideoApp.Label label : r.getLabel()){
|
||
// CaseClinicalVideoLabelModel caseClinicalVideoLabel = new CaseClinicalVideoLabelModel();
|
||
// caseClinicalVideoLabel.setVideoId(caseClinicalVideo.getVideoId());
|
||
// caseClinicalVideoLabel.setAppIden(label.getAppIden());
|
||
// caseClinicalVideoLabel.setLabelName(label.getLabelName());
|
||
// res = caseClinicalVideoLabelDao.insert(caseClinicalVideoLabel);
|
||
// if (res <= 0){
|
||
// throw new BusinessException("-1", "内部错误,添加视频标签失败");
|
||
// }
|
||
//
|
||
// // 新增标签统计
|
||
// caseClinicalService.AddStatsCaseClinicalLabel(label.getAppIden(),label.getLabelName());
|
||
// }
|
||
//
|
||
// // 新增作者
|
||
// for (addClinicalVideoApp.Author author : r.getAuthor()){
|
||
// // 获取app用户数据
|
||
// GetUserInfoResponse result = userInfo.getUserInfoByUuid(author.getDoctorIden());
|
||
// CaseClinicalDoctorModel caseClinicalDoctor = userService.GetCaseClinicalDoctor(result);
|
||
//
|
||
// CaseClinicalVideoAuthorModel caseClinicalVideoAuthor = new CaseClinicalVideoAuthorModel();
|
||
// caseClinicalVideoAuthor.setVideoId(caseClinicalVideo.getVideoId());
|
||
// caseClinicalVideoAuthor.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
|
||
// caseClinicalVideoAuthorDao.insert(caseClinicalVideoAuthor);
|
||
//
|
||
// // 新增作者统计
|
||
// caseClinicalService.AddStatsCaseClinicalDoctor(String.valueOf(caseClinicalDoctor.getDoctorId()));
|
||
//
|
||
// // 新增医院统计
|
||
// caseClinicalService.AddStatsCaseClinicalHospital(String.valueOf(caseClinicalDoctor.getHospitalId()));
|
||
// }
|
||
//
|
||
// // 新增统计
|
||
// IncClinicalVideoStats(String.valueOf(caseClinicalVideo.getVideoId()),4);
|
||
// }
|
||
//
|
||
// // 修改
|
||
// if (Objects.equals(r.getAction(), "update")){
|
||
// if (caseClinicalVideo == null){
|
||
// throw new BusinessException("-1", "无法完成此操作");
|
||
// }
|
||
//
|
||
// // 文章主体
|
||
// if (!Objects.equals(caseClinicalVideo.getVideoNo(), r.getVideoNo())){
|
||
// caseClinicalVideo.setVideoNo(r.getVideoNo());
|
||
// }
|
||
//
|
||
// if (!Objects.equals(caseClinicalVideo.getIsLink(), r.getIsLink())){
|
||
// caseClinicalVideo.setIsLink(r.getIsLink());
|
||
//
|
||
// if (!Objects.equals(caseClinicalVideo.getIsLinkUrl(), r.getIsLinkUrl())){
|
||
// caseClinicalVideo.setIsLinkUrl(r.getIsLinkUrl());
|
||
// }
|
||
// }
|
||
//
|
||
// caseClinicalVideoDao.updateById(caseClinicalVideo);
|
||
//
|
||
// // 作者
|
||
// // 获取全部作者
|
||
// LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||
// authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, caseClinicalVideo.getVideoId());
|
||
// List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
|
||
//
|
||
// List<addClinicalVideoApp.Author> addList = new ArrayList<>();
|
||
// List<CaseClinicalVideoAuthorModel> deleteList = new ArrayList<>();
|
||
//
|
||
// // 新增的
|
||
// for (addClinicalVideoApp.Author a : r.getAuthor()){
|
||
// for (CaseClinicalVideoAuthorModel b: caseClinicalVideoAuthors){
|
||
//
|
||
// }
|
||
// }
|
||
//
|
||
// // 删除的
|
||
//
|
||
//
|
||
//// // 获取医生数据
|
||
//// LambdaQueryWrapper<CaseClinicalDoctorModel> doctorQueryWrapper = new LambdaQueryWrapper<>();
|
||
//// doctorQueryWrapper.eq(CaseClinicalDoctorModel::getDoctorId, a.getDoctorId());
|
||
//// CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectOne(doctorQueryWrapper);
|
||
//// if (caseClinicalDoctor == null) {
|
||
//// throw new BusinessException("-1", "无法完成此操作");
|
||
//// }
|
||
//
|
||
// System.out.println(addList);
|
||
// System.out.println(deleteList);
|
||
// }
|
||
//
|
||
// // 删除
|
||
// if (Objects.equals(r.getAction(), "delete")){
|
||
//
|
||
// }
|
||
|
||
|
||
throw new BusinessException("-1", "错误");
|
||
} catch (Exception e) {
|
||
throw new BusinessException("-1", e.getMessage());
|
||
}
|
||
|
||
// return true;
|
||
}
|
||
}
|