新增了评论
This commit is contained in:
parent
c106bce7e2
commit
f719a1d347
@ -1,127 +0,0 @@
|
||||
package com.example.caseData.controller;
|
||||
|
||||
import com.example.caseData.common.Response;
|
||||
import com.example.caseData.dao.*;
|
||||
import com.example.caseData.dto.T;
|
||||
import com.example.caseData.exception.BusinessException;
|
||||
import com.example.caseData.request.CaseClinicalArticleCommentRequest.addClinicalArticleComment;
|
||||
import com.example.caseData.service.CaseClinicalArticleCommentService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class CaseClinicalArticleCommentController {
|
||||
@Resource
|
||||
private CaseClinicalArticleDao caseClinicalArticleDao;
|
||||
|
||||
@Resource
|
||||
private CaseClinicalArticleAuthorDao caseClinicalArticleAuthorDao;
|
||||
|
||||
@Resource
|
||||
private StatsCaseClinicalDoctorDao statsCaseClinicalDoctorDao;
|
||||
|
||||
@Resource
|
||||
private CaseClinicalDoctorDao caseClinicalDoctorDao;
|
||||
|
||||
@Resource
|
||||
private BasicHospitalDao basicHospitalDao;
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Resource
|
||||
private CaseClinicalArticleCommentService caseClinicalArticleCommentService;
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-评论
|
||||
*/
|
||||
@PostMapping("/clinical/article/comment/{article_id}")
|
||||
public Response<T> AddClinicalArticleComment(
|
||||
@PathVariable("article_id") String articleId,
|
||||
@Validated()
|
||||
@RequestBody addClinicalArticleComment request
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalArticleCommentService.AddClinicalArticleComment(articleId,userId,request);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-评论-删除
|
||||
*/
|
||||
@DeleteMapping("/clinical/article/comment/{comment_id}")
|
||||
public Response<T> DeleteClinicalArticleComment(
|
||||
@PathVariable("comment_id") String commentId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalArticleCommentService.DeleteClinicalArticleComment(commentId,userId);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-评论-置顶
|
||||
*/
|
||||
@PutMapping("/clinical/article/comment/top/{article_id}")
|
||||
public Response<T> AddTopClinicalArticleComment(
|
||||
@PathVariable("article_id") String articleId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-评论-取消置顶
|
||||
*/
|
||||
@DeleteMapping("/clinical/article/comment/top/{article_id}")
|
||||
public Response<T> deleteTopClinicalArticleComment(
|
||||
@PathVariable("article_id") String articleId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
// 临床病例库-文章-评论-列表
|
||||
}
|
||||
@ -1,17 +1,29 @@
|
||||
package com.example.caseData.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.caseData.common.Response;
|
||||
import com.example.caseData.dao.*;
|
||||
import com.example.caseData.dto.T;
|
||||
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
|
||||
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
|
||||
import com.example.caseData.exception.BusinessException;
|
||||
import com.example.caseData.model.*;
|
||||
import com.example.caseData.request.CaseClinicalArticleRequest.addClinicalArticleComment;
|
||||
import com.example.caseData.request.CaseClinicalArticleRequest.getClinicalArticleCommentPage;
|
||||
import com.example.caseData.request.clinicalRequest.getClinicalArticleSearchPage;
|
||||
import com.example.caseData.service.CaseClinicalArticleService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
@ -32,7 +44,7 @@ public class CaseClinicalArticleController {
|
||||
private BasicHospitalDao basicHospitalDao;
|
||||
|
||||
@Resource
|
||||
private UserCollectClinicalArticleDao userCollectClinicalArticleDao;
|
||||
private UserCommentClinicalArticleDao userCommentClinicalArticleDao;
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
@ -40,6 +52,9 @@ public class CaseClinicalArticleController {
|
||||
@Resource
|
||||
private CaseClinicalArticleService caseClinicalArticleService;
|
||||
|
||||
@Resource
|
||||
private UserDao userDao;
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-详情
|
||||
*/
|
||||
@ -129,4 +144,193 @@ public class CaseClinicalArticleController {
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-新增评论
|
||||
*/
|
||||
@PostMapping("/clinical/article/comment/{article_id}")
|
||||
public Response<T> AddClinicalArticleComment(
|
||||
@PathVariable("article_id") String articleId,
|
||||
@Validated()
|
||||
@RequestBody addClinicalArticleComment request
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalArticleService.AddClinicalArticleComment(articleId,userId,request);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-评论-删除
|
||||
*/
|
||||
@DeleteMapping("/clinical/article/comment/{comment_id}")
|
||||
public Response<T> DeleteClinicalArticleComment(
|
||||
@PathVariable("comment_id") String commentId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalArticleService.DeleteClinicalArticleComment(commentId,userId);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-评论-置顶
|
||||
*/
|
||||
@PutMapping("/clinical/article/comment/top/{comment_id}")
|
||||
public Response<T> AddTopClinicalArticleComment(
|
||||
@PathVariable("comment_id") String commentId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalArticleService.AddTopClinicalArticleComment(commentId,userId);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-评论-取消置顶
|
||||
*/
|
||||
@DeleteMapping("/clinical/article/comment/top/{comment_id}")
|
||||
public Response<T> deleteTopClinicalArticleComment(
|
||||
@PathVariable("comment_id") String commentId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalArticleService.deleteTopClinicalArticleComment(commentId,userId);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-评论-列表
|
||||
*/
|
||||
@PostMapping("/clinical/article/comment/page")
|
||||
public Response<Map<String, Object>> getClinicalArticleCommentPage(
|
||||
@Validated()
|
||||
@RequestBody getClinicalArticleCommentPage request
|
||||
) {
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
// 获取当前登录用户数据
|
||||
UserModel user = userDao.selectById(Long.valueOf(userId));
|
||||
if (user == null) {
|
||||
return Response.error();
|
||||
}
|
||||
|
||||
request.validateForPage();
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
Page<UserCommentClinicalArticleDto> page = new Page<>(request.getPage(), request.getPageSize());
|
||||
|
||||
// 获取文章评论数据
|
||||
IPage<UserCommentClinicalArticleDto> resultPage = userCommentClinicalArticleDao.getClinicalArticleCommentPage(
|
||||
page,
|
||||
request.getArticleId(),
|
||||
request.getRootId()
|
||||
);
|
||||
|
||||
// 获取文章数据
|
||||
CaseClinicalArticleModel article = caseClinicalArticleDao.selectById(request.getArticleId());
|
||||
if (article == null) {
|
||||
return Response.error();
|
||||
}
|
||||
|
||||
if (article.getArticleStatus() != 1){
|
||||
return Response.error();
|
||||
}
|
||||
|
||||
// 获取文章作者数据
|
||||
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, request.getArticleId());
|
||||
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
|
||||
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
|
||||
// 查询医生
|
||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||
if (caseClinicalDoctor == null) {
|
||||
return Response.error();
|
||||
}
|
||||
|
||||
// 处理是否本人评论
|
||||
for (UserCommentClinicalArticleDto dto : resultPage.getRecords()) {
|
||||
if (Objects.equals(dto.getUserIden(), caseClinicalDoctor.getDoctorIden())){
|
||||
dto.setIsAuthor(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
for (UserCommentClinicalArticleDto dto : resultPage.getRecords()) {
|
||||
// 去除用户唯一标识
|
||||
dto.setUserIden(null);
|
||||
|
||||
// 获取次级评论
|
||||
if (dto.getRootId() == null){
|
||||
List<UserCommentClinicalArticleDto> subComments = userCommentClinicalArticleDao.getClinicalArticleCommentList(
|
||||
dto.getArticleId(),
|
||||
dto.getCommentId(),
|
||||
5
|
||||
);
|
||||
|
||||
dto.setSubComment(subComments);
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("page", resultPage.getCurrent());
|
||||
resultMap.put("pageSize", resultPage.getSize());
|
||||
resultMap.put("total", resultPage.getTotal());
|
||||
resultMap.put("data", resultPage.getRecords());
|
||||
return Response.success(resultMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,18 +1,28 @@
|
||||
package com.example.caseData.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.caseData.common.Response;
|
||||
import com.example.caseData.dao.*;
|
||||
import com.example.caseData.dto.T;
|
||||
import com.example.caseData.dto.caseClinicalVideo.CaseClinicalVideoDto;
|
||||
import com.example.caseData.dto.userCommentClinicalVideo.UserCommentClinicalVideoDto;
|
||||
import com.example.caseData.exception.BusinessException;
|
||||
import com.example.caseData.model.*;
|
||||
import com.example.caseData.service.CaseClinicalArticleService;
|
||||
import com.example.caseData.request.CaseClinicalVideoRequest.addClinicalVideoComment;
|
||||
import com.example.caseData.request.CaseClinicalVideoRequest.getClinicalVideoCommentPage;
|
||||
import com.example.caseData.service.CaseClinicalVideoService;
|
||||
import com.example.caseData.service.CaseClinicalVideoService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
@ -38,6 +48,12 @@ public class CaseClinicalVideoController {
|
||||
@Resource
|
||||
private CaseClinicalVideoService caseClinicalVideoService;
|
||||
|
||||
@Resource
|
||||
private UserDao userDao;
|
||||
|
||||
@Resource
|
||||
private UserCommentClinicalVideoDao userCommentClinicalVideoDao;
|
||||
|
||||
/**
|
||||
* 临床病例库-视频-详情
|
||||
*/
|
||||
@ -46,14 +62,14 @@ public class CaseClinicalVideoController {
|
||||
@PathVariable("video_id") String videoId
|
||||
) {
|
||||
// 获取视频数据
|
||||
CaseClinicalVideoModel article = caseClinicalVideoDao.selectById(videoId);
|
||||
if (article == null) {
|
||||
CaseClinicalVideoModel video = caseClinicalVideoDao.selectById(videoId);
|
||||
if (video == null) {
|
||||
return Response.error("非法视频");
|
||||
}
|
||||
|
||||
// 查找作者
|
||||
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, article.getVideoId());
|
||||
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, video.getVideoId());
|
||||
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
|
||||
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
|
||||
// 查询医生
|
||||
@ -66,9 +82,9 @@ public class CaseClinicalVideoController {
|
||||
author.setCaseClinicalDoctor(caseClinicalDoctor);
|
||||
}
|
||||
|
||||
article.setAuthor(caseClinicalVideoAuthors);
|
||||
video.setAuthor(caseClinicalVideoAuthors);
|
||||
|
||||
CaseClinicalVideoDto g = CaseClinicalVideoDto.GetDto(article);
|
||||
CaseClinicalVideoDto g = CaseClinicalVideoDto.GetDto(video);
|
||||
|
||||
// 是否已收藏
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
@ -84,11 +100,11 @@ public class CaseClinicalVideoController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-收藏
|
||||
* 临床病例库-视频-收藏
|
||||
*/
|
||||
@PostMapping("/clinical/video/collect/{video_id}")
|
||||
public Response<T> AddClinicalVideoCollect(
|
||||
@PathVariable("video_id") String articleId
|
||||
@PathVariable("video_id") String videoId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
@ -97,7 +113,7 @@ public class CaseClinicalVideoController {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
boolean res = caseClinicalVideoService.AddClinicalVideoCollect(articleId,userId);
|
||||
boolean res = caseClinicalVideoService.AddClinicalVideoCollect(videoId,userId);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
@ -106,7 +122,7 @@ public class CaseClinicalVideoController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-取消收藏
|
||||
* 临床病例库-视频-取消收藏
|
||||
*/
|
||||
@DeleteMapping("/clinical/video/collect/{video_id}")
|
||||
public Response<T> DeleteClinicalVideoCollect(
|
||||
@ -126,4 +142,192 @@ public class CaseClinicalVideoController {
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-视频-新增评论
|
||||
*/
|
||||
@PostMapping("/clinical/video/comment/{video_id}")
|
||||
public Response<T> AddClinicalVideoComment(
|
||||
@PathVariable("video_id") String videoId,
|
||||
@Validated()
|
||||
@RequestBody addClinicalVideoComment request
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalVideoService.AddClinicalVideoComment(videoId,userId,request);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-视频-评论-删除
|
||||
*/
|
||||
@DeleteMapping("/clinical/video/comment/{comment_id}")
|
||||
public Response<T> DeleteClinicalVideoComment(
|
||||
@PathVariable("comment_id") String commentId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalVideoService.DeleteClinicalVideoComment(commentId,userId);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-视频-评论-置顶
|
||||
*/
|
||||
@PutMapping("/clinical/video/comment/top/{comment_id}")
|
||||
public Response<T> AddTopClinicalVideoComment(
|
||||
@PathVariable("comment_id") String commentId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalVideoService.AddTopClinicalVideoComment(commentId,userId);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-视频-评论-取消置顶
|
||||
*/
|
||||
@DeleteMapping("/clinical/video/comment/top/{comment_id}")
|
||||
public Response<T> deleteTopClinicalVideoComment(
|
||||
@PathVariable("comment_id") String commentId
|
||||
) {
|
||||
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
if (userId == null) {
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
|
||||
try {
|
||||
boolean res = caseClinicalVideoService.deleteTopClinicalVideoComment(commentId,userId);
|
||||
if (!res){
|
||||
return Response.error("操作失败");
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return Response.error(e.getMessage());
|
||||
}
|
||||
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-视频-评论-列表
|
||||
*/
|
||||
@PostMapping("/clinical/video/comment/page")
|
||||
public Response<Map<String, Object>> getClinicalVideoCommentPage(
|
||||
@Validated()
|
||||
@RequestBody getClinicalVideoCommentPage request
|
||||
) {
|
||||
String userId = (String) httpServletRequest.getAttribute("userId");
|
||||
|
||||
// 获取当前登录用户数据
|
||||
UserModel user = userDao.selectById(Long.valueOf(userId));
|
||||
if (user == null) {
|
||||
return Response.error();
|
||||
}
|
||||
|
||||
request.validateForPage();
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
Page<UserCommentClinicalVideoDto> page = new Page<>(request.getPage(), request.getPageSize());
|
||||
|
||||
// 获取视频评论数据
|
||||
IPage<UserCommentClinicalVideoDto> resultPage = userCommentClinicalVideoDao.getClinicalVideoCommentPage(
|
||||
page,
|
||||
request.getVideoId(),
|
||||
request.getRootId()
|
||||
);
|
||||
|
||||
// 获取视频数据
|
||||
CaseClinicalVideoModel video = caseClinicalVideoDao.selectById(request.getVideoId());
|
||||
if (video == null) {
|
||||
return Response.error();
|
||||
}
|
||||
|
||||
if (video.getVideoStatus() != 1){
|
||||
return Response.error();
|
||||
}
|
||||
|
||||
// 获取视频作者数据
|
||||
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, request.getVideoId());
|
||||
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
|
||||
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
|
||||
// 查询医生
|
||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||
if (caseClinicalDoctor == null) {
|
||||
return Response.error();
|
||||
}
|
||||
|
||||
// 处理是否本人评论
|
||||
for (UserCommentClinicalVideoDto dto : resultPage.getRecords()) {
|
||||
if (Objects.equals(dto.getUserIden(), caseClinicalDoctor.getDoctorIden())){
|
||||
dto.setIsAuthor(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
for (UserCommentClinicalVideoDto dto : resultPage.getRecords()) {
|
||||
// 去除用户唯一标识
|
||||
dto.setUserIden(null);
|
||||
|
||||
// 获取次级评论
|
||||
if (dto.getRootId() == null){
|
||||
List<UserCommentClinicalVideoDto> subComments = userCommentClinicalVideoDao.getClinicalVideoCommentList(
|
||||
dto.getVideoId(),
|
||||
dto.getCommentId(),
|
||||
5
|
||||
);
|
||||
|
||||
dto.setSubComment(subComments);
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("page", resultPage.getCurrent());
|
||||
resultMap.put("pageSize", resultPage.getSize());
|
||||
resultMap.put("total", resultPage.getTotal());
|
||||
resultMap.put("data", resultPage.getRecords());
|
||||
return Response.success(resultMap);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,33 @@
|
||||
package com.example.caseData.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
|
||||
import com.example.caseData.model.UserCommentClinicalArticleModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserCommentClinicalArticleDao extends BaseMapper<UserCommentClinicalArticleModel> {
|
||||
/**
|
||||
* 临床病例库--评论-分页
|
||||
* @param page 分页数据
|
||||
*/
|
||||
IPage<UserCommentClinicalArticleDto> getClinicalArticleCommentPage(
|
||||
Page<?> page,
|
||||
@Param("articleId") String articleId,
|
||||
@Param("rootId") String rootId
|
||||
);
|
||||
|
||||
/**
|
||||
* 临床病例库--评论-分页
|
||||
*/
|
||||
List<UserCommentClinicalArticleDto> getClinicalArticleCommentList(
|
||||
@Param("articleId") String articleId,
|
||||
@Param("rootId") String rootId,
|
||||
@Param("limit") int limit
|
||||
);
|
||||
}
|
||||
@ -1,7 +1,32 @@
|
||||
package com.example.caseData.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
|
||||
import com.example.caseData.dto.userCommentClinicalVideo.UserCommentClinicalVideoDto;
|
||||
import com.example.caseData.model.UserCommentClinicalVideoModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserCommentClinicalVideoDao extends BaseMapper<UserCommentClinicalVideoModel> {
|
||||
/**
|
||||
* 临床病例库--评论-分页
|
||||
* @param page 分页数据
|
||||
*/
|
||||
IPage<UserCommentClinicalVideoDto> getClinicalVideoCommentPage(
|
||||
Page<?> page,
|
||||
@Param("videoId") String videoId,
|
||||
@Param("rootId") String rootId
|
||||
);
|
||||
|
||||
/**
|
||||
* 临床病例库--评论-分页
|
||||
*/
|
||||
List<UserCommentClinicalVideoDto> getClinicalVideoCommentList(
|
||||
@Param("videoId") String videoId,
|
||||
@Param("rootId") String rootId,
|
||||
@Param("limit") int limit
|
||||
);
|
||||
}
|
||||
@ -34,7 +34,7 @@ public class CaseClinicalArticleAuthorDto {
|
||||
private String doctorId;
|
||||
|
||||
/**
|
||||
* 医院名称
|
||||
* 医生名称
|
||||
*/
|
||||
@JsonProperty("doctor_name")
|
||||
private String doctorName;
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package com.example.caseData.dto.userCommentClinicalArticle;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserCommentClinicalArticleDto {
|
||||
@ -10,31 +13,31 @@ public class UserCommentClinicalArticleDto {
|
||||
* 主键id
|
||||
*/
|
||||
@JsonProperty("comment_id")
|
||||
private Long commentId;
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@JsonProperty("user_id")
|
||||
private Long userId;
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 临床文章id
|
||||
*/
|
||||
@JsonProperty("article_id")
|
||||
private Long articleId;
|
||||
private String articleId;
|
||||
|
||||
/**
|
||||
* 父级id,一级评论为null
|
||||
*/
|
||||
@JsonProperty("parent_id")
|
||||
private Long parentId;
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 根评论id,一级评论时为null。其余为一级评论id
|
||||
*/
|
||||
@JsonProperty("root_id")
|
||||
private Long rootId;
|
||||
private String rootId;
|
||||
|
||||
/**
|
||||
* 评论状态(0:禁用 1:正常)
|
||||
@ -49,10 +52,10 @@ public class UserCommentClinicalArticleDto {
|
||||
private Integer isSensitive;
|
||||
|
||||
/**
|
||||
* 是否优质留言(0:否 1:是)
|
||||
* 是否置顶(0:否 1:是)
|
||||
*/
|
||||
@JsonProperty("is_high_quality")
|
||||
private Integer isHighQuality;
|
||||
@JsonProperty("is_top")
|
||||
private Integer isTop;
|
||||
|
||||
/**
|
||||
* 点赞数量
|
||||
@ -76,11 +79,37 @@ public class UserCommentClinicalArticleDto {
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonProperty("created_at")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonProperty("updated_at")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@JsonProperty("user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户唯一标识
|
||||
*/
|
||||
@JsonProperty("user_iden")
|
||||
private String userIden;
|
||||
|
||||
/**
|
||||
* 是否作者(0:否 1:是)
|
||||
*/
|
||||
@JsonProperty("is_author")
|
||||
private Integer isAuthor;
|
||||
|
||||
/**
|
||||
* 次级评论
|
||||
*/
|
||||
@JsonProperty("sub_comment")
|
||||
private List<UserCommentClinicalArticleDto> subComment;
|
||||
}
|
||||
@ -1,8 +1,12 @@
|
||||
package com.example.caseData.dto.userCommentClinicalVideo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserCommentClinicalVideoDto {
|
||||
@ -10,31 +14,31 @@ public class UserCommentClinicalVideoDto {
|
||||
* 主键id
|
||||
*/
|
||||
@JsonProperty("comment_id")
|
||||
private Long commentId;
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@JsonProperty("user_id")
|
||||
private Long userId;
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 临床视频id
|
||||
*/
|
||||
@JsonProperty("video_id")
|
||||
private Long videoId;
|
||||
private String videoId;
|
||||
|
||||
/**
|
||||
* 父级id,一级评论为null
|
||||
*/
|
||||
@JsonProperty("parent_id")
|
||||
private Long parentId;
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 根评论id,一级评论时为null。其余为一级评论id
|
||||
*/
|
||||
@JsonProperty("root_id")
|
||||
private Long rootId;
|
||||
private String rootId;
|
||||
|
||||
/**
|
||||
* 评论状态(0:禁用 1:正常)
|
||||
@ -76,11 +80,37 @@ public class UserCommentClinicalVideoDto {
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonProperty("created_at")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonProperty("updated_at")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@JsonProperty("user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户唯一标识
|
||||
*/
|
||||
@JsonProperty("user_iden")
|
||||
private String userIden;
|
||||
|
||||
/**
|
||||
* 是否作者(0:否 1:是)
|
||||
*/
|
||||
@JsonProperty("is_author")
|
||||
private Integer isAuthor;
|
||||
|
||||
/**
|
||||
* 次级评论
|
||||
*/
|
||||
@JsonProperty("sub_comment")
|
||||
private List<UserCommentClinicalVideoDto> subComment;
|
||||
}
|
||||
@ -62,6 +62,12 @@ public class UserCommentClinicalArticleModel {
|
||||
@TableField("like_num")
|
||||
private Integer likeNum;
|
||||
|
||||
/**
|
||||
* 是否作者评论(0:否 1:是)
|
||||
*/
|
||||
@TableField("is_author")
|
||||
private Integer isAuthor;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.example.caseData.request.CaseClinicalArticleCommentRequest;
|
||||
package com.example.caseData.request.CaseClinicalArticleRequest;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
@ -0,0 +1,43 @@
|
||||
package com.example.caseData.request.CaseClinicalArticleRequest;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class getClinicalArticleCommentPage {
|
||||
// ✅ 分页参数
|
||||
@Min(value = 1,message = "页码最小为 1")
|
||||
private Integer page = 1;
|
||||
|
||||
@JsonProperty("page_size")
|
||||
@Min(value = 1, message = "每页个数最小为 1")
|
||||
private Integer pageSize = 20;
|
||||
|
||||
// 文章id
|
||||
@NotEmpty(message = "错误")
|
||||
@JsonProperty("article_id")
|
||||
private String articleId;
|
||||
|
||||
// 根评论id
|
||||
@JsonProperty("root_id")
|
||||
private String rootId;
|
||||
|
||||
// ✅ 校验分页参数
|
||||
public void validateForPage() {
|
||||
// 如果 page 为空,设为默认值 1
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
if (pageSize == null) {
|
||||
pageSize = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.example.caseData.request.CaseClinicalVideoRequest;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class addClinicalVideoComment {
|
||||
// 父级 次级评论此字段必须存在
|
||||
@JsonProperty("parent_id")
|
||||
private String parentId;
|
||||
|
||||
// 根评论标识 次级评论此字段必须存在
|
||||
@JsonProperty("root_id")
|
||||
private String rootId;
|
||||
|
||||
// 评论内容
|
||||
@JsonProperty("content")
|
||||
@NotEmpty(message = "请输入评论内容")
|
||||
private String content;
|
||||
|
||||
// 评论图片
|
||||
@JsonProperty("comment_image")
|
||||
private String commentImage;
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.example.caseData.request.CaseClinicalVideoRequest;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class getClinicalVideoCommentPage {
|
||||
// ✅ 分页参数
|
||||
@Min(value = 1,message = "页码最小为 1")
|
||||
private Integer page = 1;
|
||||
|
||||
@JsonProperty("page_size")
|
||||
@Min(value = 1, message = "每页个数最小为 1")
|
||||
private Integer pageSize = 20;
|
||||
|
||||
// 文章id
|
||||
@NotEmpty(message = "错误")
|
||||
@JsonProperty("video_id")
|
||||
private String videoId;
|
||||
|
||||
// 根评论id
|
||||
@JsonProperty("root_id")
|
||||
private String rootId;
|
||||
|
||||
// ✅ 校验分页参数
|
||||
public void validateForPage() {
|
||||
// 如果 page 为空,设为默认值 1
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
if (pageSize == null) {
|
||||
pageSize = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,160 +0,0 @@
|
||||
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.model.*;
|
||||
import com.example.caseData.request.CaseClinicalArticleCommentRequest.addClinicalArticleComment;
|
||||
import com.example.caseData.utils.Replace;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@Service
|
||||
public class CaseClinicalArticleCommentService {
|
||||
@Resource
|
||||
private UserCollectClinicalArticleDao userCollectClinicalArticleDao;
|
||||
|
||||
@Resource
|
||||
private CaseClinicalArticleDao caseClinicalArticleDao;
|
||||
|
||||
@Resource
|
||||
private StatsCaseClinicalDao statsCaseClinicalDao;
|
||||
|
||||
@Resource
|
||||
private StatsCaseClinicalHospitalDao statsCaseClinicalHospitalDao;
|
||||
|
||||
@Resource
|
||||
private StatsCaseClinicalDoctorDao statsCaseClinicalDoctorDao;
|
||||
|
||||
@Resource
|
||||
private CaseClinicalArticleAuthorDao caseClinicalArticleAuthorDao;
|
||||
|
||||
@Resource
|
||||
private CaseClinicalDoctorDao caseClinicalDoctorDao;
|
||||
|
||||
@Resource
|
||||
private BasicSensitiveWordService basicSensitiveWordService;
|
||||
|
||||
@Resource
|
||||
private UserCommentClinicalArticleDao userCommentClinicalArticleDao;
|
||||
|
||||
@Resource
|
||||
private UserDao userDao;
|
||||
|
||||
/**
|
||||
* 新增评论-临床病例库-文章
|
||||
* @param articleId 文章id
|
||||
* @param userId 用户id
|
||||
* @return bool
|
||||
*/
|
||||
@Transactional
|
||||
public boolean AddClinicalArticleComment(String articleId, String userId, addClinicalArticleComment request){
|
||||
// 获取文章数据
|
||||
CaseClinicalArticleModel article = caseClinicalArticleDao.selectById(articleId);
|
||||
if (article == null) {
|
||||
throw new BusinessException("非法文章");
|
||||
}
|
||||
|
||||
if (article.getArticleStatus() != 1){
|
||||
throw new BusinessException("非法文章");
|
||||
}
|
||||
|
||||
// 处理评论内容
|
||||
BasicSensitiveWordService.FilterResult result = basicSensitiveWordService.filter(request.getContent());
|
||||
|
||||
// 新增评论
|
||||
UserCommentClinicalArticleModel userCommentClinicalArticleData = new UserCommentClinicalArticleModel();
|
||||
userCommentClinicalArticleData.setUserId(Long.valueOf(userId));
|
||||
userCommentClinicalArticleData.setArticleId(Long.valueOf(articleId));
|
||||
userCommentClinicalArticleData.setStatus(1);
|
||||
userCommentClinicalArticleData.setIsSensitive(result.hasSensitive);
|
||||
userCommentClinicalArticleData.setContent(result.comment);
|
||||
userCommentClinicalArticleData.setCommentImage(Replace.addOssDomain(request.getCommentImage()));
|
||||
if (result.hasSensitive == 1){
|
||||
userCommentClinicalArticleData.setContentWord(request.getContent());
|
||||
}
|
||||
|
||||
// 评论根id
|
||||
if (request.getRootId() != null) {
|
||||
userCommentClinicalArticleData.setRootId(Long.valueOf(request.getRootId()));
|
||||
}
|
||||
|
||||
// 评论父级id
|
||||
if (request.getParentId() != null) {
|
||||
userCommentClinicalArticleData.setParentId(Long.valueOf(request.getParentId()));
|
||||
}
|
||||
|
||||
int res = userCommentClinicalArticleDao.insert(userCommentClinicalArticleData);
|
||||
return res > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论-临床病例库-文章
|
||||
* @param commentId 评论id
|
||||
* @param userId 用户id
|
||||
* @return bool
|
||||
*/
|
||||
@Transactional
|
||||
public boolean DeleteClinicalArticleComment(String commentId, String userId){
|
||||
// 获取评论数据
|
||||
UserCommentClinicalArticleModel comment = userCommentClinicalArticleDao.selectById(commentId);
|
||||
if (comment == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 获取当前登录用户数据
|
||||
UserModel user = userDao.selectById(Long.valueOf(userId));
|
||||
if (user == null) {
|
||||
throw new BusinessException("错误");
|
||||
}
|
||||
|
||||
|
||||
// 获取文章数据
|
||||
CaseClinicalArticleModel article = caseClinicalArticleDao.selectById(comment.getArticleId());
|
||||
if (article == null) {
|
||||
throw new BusinessException("删除失败");
|
||||
}
|
||||
|
||||
if (article.getArticleStatus() != 1){
|
||||
throw new BusinessException("删除失败");
|
||||
}
|
||||
|
||||
// 当前用户是否是作者之一
|
||||
boolean isAuthor = false;
|
||||
|
||||
// 获取文章作者数据
|
||||
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, article.getArticleId());
|
||||
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
|
||||
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
|
||||
// 查询医生
|
||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||
if (caseClinicalDoctor == null) {
|
||||
throw new BusinessException("错误");
|
||||
}
|
||||
|
||||
if (Objects.equals(caseClinicalDoctor.getDoctorIden(), user.getUserIden())){
|
||||
isAuthor = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAuthor) {
|
||||
throw new BusinessException("不可删除");
|
||||
}
|
||||
|
||||
// 删除评论
|
||||
int res = userCommentClinicalArticleDao.deleteById(comment.getCommentId());
|
||||
if (res <= 0){
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.example.caseData.dao.*;
|
||||
import com.example.caseData.exception.BusinessException;
|
||||
import com.example.caseData.model.*;
|
||||
import com.example.caseData.request.CaseClinicalArticleCommentRequest.addClinicalArticleComment;
|
||||
import com.example.caseData.request.CaseClinicalArticleRequest.addClinicalArticleComment;
|
||||
import com.example.caseData.utils.Replace;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -13,6 +13,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
//import static com.baomidou.mybatisplus.extension.toolkit.Db.removeById;
|
||||
//import static com.baomidou.mybatisplus.extension.toolkit.Db.save;
|
||||
@ -46,6 +47,8 @@ public class CaseClinicalArticleService {
|
||||
@Resource
|
||||
private UserCommentClinicalArticleDao userCommentClinicalArticleDao;
|
||||
|
||||
@Resource
|
||||
private UserDao userDao;
|
||||
|
||||
/**
|
||||
* 新增收藏-临床病例库-文章
|
||||
@ -145,6 +148,176 @@ public class CaseClinicalArticleService {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增评论-临床病例库-文章
|
||||
* @param articleId 文章id
|
||||
* @param userId 用户id
|
||||
* @return bool
|
||||
*/
|
||||
@Transactional
|
||||
public boolean AddClinicalArticleComment(String articleId, String userId, addClinicalArticleComment request){
|
||||
// 获取文章数据
|
||||
CaseClinicalArticleModel article = caseClinicalArticleDao.selectById(articleId);
|
||||
if (article == null) {
|
||||
throw new BusinessException("非法文章");
|
||||
}
|
||||
|
||||
if (article.getArticleStatus() != 1){
|
||||
throw new BusinessException("非法文章");
|
||||
}
|
||||
|
||||
// 处理评论内容
|
||||
BasicSensitiveWordService.FilterResult result = basicSensitiveWordService.filter(request.getContent());
|
||||
if (result.hasSensitive == 1){
|
||||
throw new BusinessException("存在敏感词,请修改后提交");
|
||||
}
|
||||
|
||||
// 新增评论
|
||||
UserCommentClinicalArticleModel userCommentClinicalArticleData = new UserCommentClinicalArticleModel();
|
||||
userCommentClinicalArticleData.setUserId(Long.valueOf(userId));
|
||||
userCommentClinicalArticleData.setArticleId(Long.valueOf(articleId));
|
||||
userCommentClinicalArticleData.setStatus(1);
|
||||
userCommentClinicalArticleData.setIsSensitive(0);
|
||||
userCommentClinicalArticleData.setContent(request.getContent());
|
||||
userCommentClinicalArticleData.setCommentImage(Replace.addOssDomain(request.getCommentImage()));
|
||||
|
||||
// 评论根id
|
||||
if (request.getRootId() != null) {
|
||||
userCommentClinicalArticleData.setRootId(Long.valueOf(request.getRootId()));
|
||||
}
|
||||
|
||||
// 评论父级id
|
||||
if (request.getParentId() != null) {
|
||||
userCommentClinicalArticleData.setParentId(Long.valueOf(request.getParentId()));
|
||||
}
|
||||
|
||||
int res = userCommentClinicalArticleDao.insert(userCommentClinicalArticleData);
|
||||
return res > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论-临床病例库-文章
|
||||
* @param commentId 评论id
|
||||
* @param userId 用户id
|
||||
* @return bool
|
||||
*/
|
||||
@Transactional
|
||||
public boolean DeleteClinicalArticleComment(String commentId, String userId){
|
||||
// 获取评论数据
|
||||
UserCommentClinicalArticleModel comment = userCommentClinicalArticleDao.selectById(commentId);
|
||||
if (comment == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取文章数据
|
||||
CaseClinicalArticleModel article = caseClinicalArticleDao.selectById(comment.getArticleId());
|
||||
if (article == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (article.getArticleStatus() != 1){
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检测用户是否文章作者
|
||||
boolean isAuthor = checkUserIsArticleAuthor(String.valueOf(article.getArticleId()),userId);
|
||||
if (!isAuthor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 删除评论
|
||||
int res = userCommentClinicalArticleDao.deleteById(comment.getCommentId());
|
||||
if (res <= 0){
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置顶评论-临床病例库-文章
|
||||
* @param commentId 评论id
|
||||
* @param userId 用户id
|
||||
* @return bool
|
||||
*/
|
||||
@Transactional
|
||||
public boolean AddTopClinicalArticleComment(String commentId, String userId){
|
||||
// 获取评论数据
|
||||
UserCommentClinicalArticleModel comment = userCommentClinicalArticleDao.selectById(commentId);
|
||||
if (comment == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取文章数据
|
||||
CaseClinicalArticleModel article = caseClinicalArticleDao.selectById(comment.getArticleId());
|
||||
if (article == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (article.getArticleStatus() != 1){
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检测用户是否文章作者
|
||||
boolean isAuthor = checkUserIsArticleAuthor(String.valueOf(comment.getArticleId()),userId);
|
||||
if (!isAuthor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (comment.getIsTop() == 1){
|
||||
return true;
|
||||
}
|
||||
|
||||
// 置顶评论
|
||||
comment.setIsTop(1);
|
||||
userCommentClinicalArticleDao.updateById(comment);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消置顶评论-临床病例库-文章
|
||||
* @param commentId 评论id
|
||||
* @param userId 用户id
|
||||
* @return bool
|
||||
*/
|
||||
@Transactional
|
||||
public boolean deleteTopClinicalArticleComment(String commentId, String userId){
|
||||
// 获取评论数据
|
||||
UserCommentClinicalArticleModel comment = userCommentClinicalArticleDao.selectById(commentId);
|
||||
if (comment == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取文章数据
|
||||
CaseClinicalArticleModel article = caseClinicalArticleDao.selectById(comment.getArticleId());
|
||||
if (article == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (article.getArticleStatus() != 1){
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检测用户是否文章作者
|
||||
boolean isAuthor = checkUserIsArticleAuthor(String.valueOf(comment.getArticleId()),userId);
|
||||
if (!isAuthor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 取消置顶评论
|
||||
if (comment.getIsTop() == 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
// 置顶评论
|
||||
comment.setIsTop(0);
|
||||
userCommentClinicalArticleDao.updateById(comment);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户收藏数据
|
||||
* @param articleId 文章id
|
||||
@ -159,4 +332,39 @@ public class CaseClinicalArticleService {
|
||||
|
||||
return userCollectClinicalArticleDao.selectOne(mapQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测用户是否文章作者
|
||||
* @param articleId 文章id
|
||||
* @param userId 用户id
|
||||
* @return bool 是否作者
|
||||
*/
|
||||
public boolean checkUserIsArticleAuthor(String articleId,String userId){
|
||||
// 获取当前登录用户数据
|
||||
UserModel user = userDao.selectById(Long.valueOf(userId));
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 当前用户是否是作者之一
|
||||
boolean isAuthor = false;
|
||||
|
||||
// 获取文章作者数据
|
||||
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, articleId);
|
||||
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
|
||||
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
|
||||
// 查询医生
|
||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||
if (caseClinicalDoctor == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Objects.equals(caseClinicalDoctor.getDoctorIden(), user.getUserIden())){
|
||||
isAuthor = true;
|
||||
}
|
||||
}
|
||||
|
||||
return isAuthor;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,14 +2,18 @@ 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.model.*;
|
||||
import com.example.caseData.model.UserCollectClinicalVideoModel;
|
||||
import com.example.caseData.request.CaseClinicalVideoRequest.addClinicalVideoComment;
|
||||
import com.example.caseData.utils.Replace;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
//import static com.baomidou.mybatisplus.extension.toolkit.Db.removeById;
|
||||
//import static com.baomidou.mybatisplus.extension.toolkit.Db.save;
|
||||
@ -40,6 +44,11 @@ public class CaseClinicalVideoService {
|
||||
@Resource
|
||||
private CaseClinicalDoctorDao caseClinicalDoctorDao;
|
||||
|
||||
@Resource
|
||||
private BasicSensitiveWordService basicSensitiveWordService;
|
||||
|
||||
@Resource
|
||||
private UserCommentClinicalVideoDao userCommentClinicalVideoDao;
|
||||
|
||||
/**
|
||||
* 新增收藏-临床病例库-视频
|
||||
@ -68,7 +77,7 @@ public class CaseClinicalVideoService {
|
||||
caseClinicalVideoDao.inc(Long.valueOf(videoId),"collect_num",1);
|
||||
|
||||
// 增加视频总收藏数
|
||||
statsCaseClinicalDao.inc(1L,"article_collect_num",1);
|
||||
statsCaseClinicalDao.inc(1L,"video_collect_num",1);
|
||||
|
||||
// 获取视频作者
|
||||
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@ -79,10 +88,10 @@ public class CaseClinicalVideoService {
|
||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||
|
||||
// 增加医院视频收藏数
|
||||
statsCaseClinicalHospitalDao.inc(caseClinicalDoctor.getHospitalId(),"article_collect_num",1);
|
||||
statsCaseClinicalHospitalDao.inc(caseClinicalDoctor.getHospitalId(),"video_collect_num",1);
|
||||
|
||||
// 增加医生视频收藏数
|
||||
statsCaseClinicalDoctorDao.inc(caseClinicalDoctor.getDoctorId(),"article_collect_num",1);
|
||||
statsCaseClinicalDoctorDao.inc(caseClinicalDoctor.getDoctorId(),"video_collect_num",1);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -113,7 +122,7 @@ public class CaseClinicalVideoService {
|
||||
caseClinicalVideoDao.dec(Long.valueOf(videoId),"collect_num",1);
|
||||
|
||||
// 减少视频总收藏数
|
||||
statsCaseClinicalDao.dec(1L,"article_collect_num",1);
|
||||
statsCaseClinicalDao.dec(1L,"video_collect_num",1);
|
||||
|
||||
// 获取视频作者
|
||||
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@ -124,15 +133,220 @@ public class CaseClinicalVideoService {
|
||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||
|
||||
// 减少医院视频收藏数
|
||||
statsCaseClinicalHospitalDao.dec(caseClinicalDoctor.getHospitalId(),"article_collect_num",1);
|
||||
statsCaseClinicalHospitalDao.dec(caseClinicalDoctor.getHospitalId(),"video_collect_num",1);
|
||||
|
||||
// 减少医生视频收藏数
|
||||
statsCaseClinicalDoctorDao.dec(caseClinicalDoctor.getDoctorId(),"article_collect_num",1);
|
||||
statsCaseClinicalDoctorDao.dec(caseClinicalDoctor.getDoctorId(),"video_collect_num",1);
|
||||
}
|
||||
|
||||
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.addOssDomain(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);
|
||||
return res > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论-临床病例库-视频
|
||||
* @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;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@ -1,5 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.example.caseData.dao.UserCommentClinicalArticleDao">
|
||||
<!-- <resultMap id="Result" type="com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto">-->
|
||||
<!-- <result column="comment_id" property="commentId"/>-->
|
||||
<!-- <result column="user_id" property="userId"/>-->
|
||||
<!-- <result column="article_id" property="articleId"/>-->
|
||||
<!-- <result column="parent_id" property="parentId"/>-->
|
||||
<!-- <result column="root_id" property="rootId"/>-->
|
||||
<!-- <result column="status" property="status"/>-->
|
||||
<!-- <result column="is_sensitive" property="isSensitive"/>-->
|
||||
<!-- <result column="is_top" property="isTop"/>-->
|
||||
<!-- <result column="like_num" property="likeNum"/>-->
|
||||
<!-- <result column="content" property="content"/>-->
|
||||
<!-- <result column="content_word" property="contentWord"/>-->
|
||||
<!-- <result column="created_at" property="createdAt"/>-->
|
||||
<!-- <result column="updated_at" property="updatedAt"/>-->
|
||||
<!-- <result column="user_name" property="userName"/>-->
|
||||
<!-- <result column="user_iden" property="userIden"/>-->
|
||||
<!-- </resultMap>-->
|
||||
|
||||
<select id="getClinicalArticleCommentPage" resultType="com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto">
|
||||
SELECT
|
||||
a.*,
|
||||
b.user_name,
|
||||
b.user_iden
|
||||
FROM user_comment_clinical_article a
|
||||
LEFT JOIN user b ON a.user_id = b.user_id
|
||||
WHERE a.status = 1
|
||||
<choose>
|
||||
<when test="rootId != null and rootId != ''">
|
||||
AND a.root_id = #{rootId}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND a.root_id IS NULL
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
ORDER BY a.is_top desc , a.created_at DESC
|
||||
</select>
|
||||
|
||||
<select id="getClinicalArticleCommentList"
|
||||
resultType="com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto">
|
||||
SELECT
|
||||
a.*,
|
||||
b.user_name,
|
||||
b.user_iden
|
||||
FROM user_comment_clinical_article a
|
||||
LEFT JOIN user b ON a.user_id = b.user_id
|
||||
WHERE a.status = 1
|
||||
AND a.root_id = #{rootId}
|
||||
ORDER BY a.is_top desc , a.created_at DESC
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -1,5 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.example.caseData.dao.UserCommentClinicalVideoDao">
|
||||
<select id="getClinicalVideoCommentPage" resultType="com.example.caseData.dto.userCommentClinicalVideo.UserCommentClinicalVideoDto">
|
||||
SELECT
|
||||
a.*,
|
||||
b.user_name,
|
||||
b.user_iden
|
||||
FROM user_comment_clinical_video a
|
||||
LEFT JOIN user b ON a.user_id = b.user_id
|
||||
WHERE a.status = 1
|
||||
<choose>
|
||||
<when test="rootId != null and rootId != ''">
|
||||
AND a.root_id = #{rootId}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND a.root_id IS NULL
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
ORDER BY a.is_top desc , a.created_at DESC
|
||||
</select>
|
||||
|
||||
<select id="getClinicalVideoCommentList"
|
||||
resultType="com.example.caseData.dto.userCommentClinicalVideo.UserCommentClinicalVideoDto">
|
||||
SELECT
|
||||
a.*,
|
||||
b.user_name,
|
||||
b.user_iden
|
||||
FROM user_comment_clinical_video a
|
||||
LEFT JOIN user b ON a.user_id = b.user_id
|
||||
WHERE a.status = 1
|
||||
AND a.root_id = #{rootId}
|
||||
ORDER BY a.is_top desc , a.created_at DESC
|
||||
limit #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user