新增我参与的评论
This commit is contained in:
parent
8fc7084b31
commit
003c4eea74
@ -8,22 +8,25 @@ 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.userCommentCaseExchange.GetUserCaseExchangeCommentPageDto;
|
||||
import com.example.caseData.dto.userCommentCaseExchange.UserCommentCaseExchangeDto;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.GetUserClinicalArticleCommentPageDto;
|
||||
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.CaseClinicalArticleRequest.getUserClinicalArticleCommentPage;
|
||||
import com.example.caseData.request.caseExchangeRequest.getUserCaseExchangeCommentPage;
|
||||
import com.example.caseData.request.clinicalRequest.getClinicalArticleSearchPage;
|
||||
import com.example.caseData.service.CaseClinicalArticleService;
|
||||
import com.example.caseData.utils.IntToString;
|
||||
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;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
@ -335,4 +338,59 @@ public class CaseClinicalArticleController {
|
||||
return Response.success(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-文章-评论-分页-用户
|
||||
*/
|
||||
@PostMapping("/clinical/article/user/comment/page")
|
||||
public Response<Map<String, Object>> getUserClinicalArticleCommentPage(
|
||||
@Validated()
|
||||
@RequestBody getUserClinicalArticleCommentPage 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<GetUserClinicalArticleCommentPageDto> resultPage = userCommentClinicalArticleDao.getUserClinicalArticleCommentPage(
|
||||
page,
|
||||
userId
|
||||
);
|
||||
|
||||
for (GetUserClinicalArticleCommentPageDto dto : resultPage.getRecords()){
|
||||
dto.setAuthor(new ArrayList<>());
|
||||
|
||||
// 获取文章作者数据
|
||||
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, dto.getArticleId());
|
||||
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
|
||||
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
|
||||
GetUserClinicalArticleCommentPageDto.CaseClinicalArticleAuthorDto authorDto = new GetUserClinicalArticleCommentPageDto.CaseClinicalArticleAuthorDto();
|
||||
|
||||
// 查询医生
|
||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||
if (caseClinicalDoctor == null) {
|
||||
return Response.error();
|
||||
}
|
||||
authorDto.setDoctorName(caseClinicalDoctor.getDoctorName());
|
||||
dto.getAuthor().add(authorDto);
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("page", resultPage.getCurrent());
|
||||
resultMap.put("pageSize", resultPage.getSize());
|
||||
resultMap.put("total", resultPage.getTotal());
|
||||
resultMap.put("data", resultPage.getRecords());
|
||||
return Response.success(resultMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,10 +7,13 @@ 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.userCommentClinicalArticle.GetUserClinicalArticleCommentPageDto;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
|
||||
import com.example.caseData.dto.userCommentClinicalVideo.GetUserClinicalVideoCommentPageDto;
|
||||
import com.example.caseData.dto.userCommentClinicalVideo.UserCommentClinicalVideoDto;
|
||||
import com.example.caseData.exception.BusinessException;
|
||||
import com.example.caseData.model.*;
|
||||
import com.example.caseData.request.CaseClinicalArticleRequest.getUserClinicalArticleCommentPage;
|
||||
import com.example.caseData.request.CaseClinicalVideoRequest.addClinicalVideoComment;
|
||||
import com.example.caseData.request.CaseClinicalVideoRequest.getClinicalVideoCommentPage;
|
||||
import com.example.caseData.service.CaseClinicalVideoService;
|
||||
@ -20,10 +23,7 @@ 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;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
@ -333,4 +333,59 @@ public class CaseClinicalVideoController {
|
||||
resultMap.put("data", resultPage.getRecords());
|
||||
return Response.success(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 临床病例库-视频-评论-分页-用户
|
||||
*/
|
||||
@PostMapping("/clinical/video/user/comment/page")
|
||||
public Response<Map<String, Object>> getUserClinicalVideoCommentPage(
|
||||
@Validated()
|
||||
@RequestBody getUserClinicalArticleCommentPage 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<GetUserClinicalVideoCommentPageDto> resultPage = userCommentClinicalVideoDao.getUserClinicalVideoCommentPage(
|
||||
page,
|
||||
userId
|
||||
);
|
||||
|
||||
for (GetUserClinicalVideoCommentPageDto dto : resultPage.getRecords()){
|
||||
dto.setAuthor(new ArrayList<>());
|
||||
|
||||
// 获取文章作者数据
|
||||
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, dto.getVideoId());
|
||||
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
|
||||
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
|
||||
GetUserClinicalVideoCommentPageDto.CaseClinicalVideoAuthorDto authorDto = new GetUserClinicalVideoCommentPageDto.CaseClinicalVideoAuthorDto();
|
||||
|
||||
// 查询医生
|
||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||
if (caseClinicalDoctor == null) {
|
||||
return Response.error();
|
||||
}
|
||||
authorDto.setDoctorName(caseClinicalDoctor.getDoctorName());
|
||||
dto.getAuthor().add(authorDto);
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("page", resultPage.getCurrent());
|
||||
resultMap.put("pageSize", resultPage.getSize());
|
||||
resultMap.put("total", resultPage.getTotal());
|
||||
resultMap.put("data", resultPage.getRecords());
|
||||
return Response.success(resultMap);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,14 +9,13 @@ import com.example.caseData.dto.T;
|
||||
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
|
||||
import com.example.caseData.dto.caseExchangeVote.CaseExchangeVoteDto;
|
||||
import com.example.caseData.dto.caseExchangeVoteOption.CaseExchangeVoteOptionDto;
|
||||
import com.example.caseData.dto.userCommentCaseExchange.GetUserCaseExchangeCommentPageDto;
|
||||
import com.example.caseData.dto.userCommentCaseExchange.UserCommentCaseExchangeDto;
|
||||
import com.example.caseData.exception.BusinessException;
|
||||
import com.example.caseData.model.*;
|
||||
import com.example.caseData.request.caseExchangeRequest.addCaseExchange;
|
||||
import com.example.caseData.request.caseExchangeRequest.addCaseExchangeComment;
|
||||
import com.example.caseData.request.caseExchangeRequest.getCaseExchangeCommentPage;
|
||||
import com.example.caseData.request.caseExchangeRequest.getCaseExchangeSearchPage;
|
||||
import com.example.caseData.request.caseExchangeRequest.*;
|
||||
import com.example.caseData.service.CaseExchangeService;
|
||||
import com.example.caseData.utils.IntToString;
|
||||
import com.example.caseData.utils.Replace;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@ -502,7 +501,7 @@ public class CaseExchangeController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 病例交流-评论-列表
|
||||
* 病例交流-评论-分页
|
||||
*/
|
||||
@PostMapping("/exchange/comment/page")
|
||||
public Response<Map<String, Object>> getCaseExchangeCommentPage(
|
||||
@ -562,4 +561,46 @@ public class CaseExchangeController {
|
||||
resultMap.put("data", resultPage.getRecords());
|
||||
return Response.success(resultMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 病例交流-评论-分页-用户
|
||||
*/
|
||||
@PostMapping("/exchange/user/comment/page")
|
||||
public Response<Map<String, Object>> getUserCaseExchangeCommentPage(
|
||||
@Validated()
|
||||
@RequestBody getUserCaseExchangeCommentPage 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<UserCommentCaseExchangeDto> page = new Page<>(request.getPage(), request.getPageSize());
|
||||
|
||||
// 获取评论数据
|
||||
IPage<GetUserCaseExchangeCommentPageDto> resultPage = userCommentExchangeDao.getUserCaseExchangeCommentPage(
|
||||
page,
|
||||
userId
|
||||
);
|
||||
|
||||
// 处理返回值
|
||||
for (GetUserCaseExchangeCommentPageDto dto : resultPage.getRecords()) {
|
||||
if (dto.getAuthorTitleInt() != null) {
|
||||
dto.setAuthorTitle(IntToString.DoctorTitleToString(dto.getAuthorTitleInt()));
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("page", resultPage.getCurrent());
|
||||
resultMap.put("pageSize", resultPage.getSize());
|
||||
resultMap.put("total", resultPage.getTotal());
|
||||
resultMap.put("data", resultPage.getRecords());
|
||||
return Response.success(resultMap);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,5 +106,10 @@ public class UserController extends BaseController {
|
||||
return Response.success(g);
|
||||
}
|
||||
|
||||
// 用户参与-病例交流
|
||||
|
||||
// 用户参与-文章病例库
|
||||
// 用户参与-视频病例库
|
||||
// 收藏搜索-分页
|
||||
// 浏览列表-分页
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ 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.GetUserClinicalArticleCommentPageDto;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
|
||||
import com.example.caseData.model.UserCommentClinicalArticleModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -30,4 +31,13 @@ public interface UserCommentClinicalArticleDao extends BaseMapper<UserCommentCli
|
||||
@Param("rootId") String rootId,
|
||||
@Param("limit") int limit
|
||||
);
|
||||
|
||||
/**
|
||||
* 临床病例库--评论-分页
|
||||
* @param page 分页数据
|
||||
*/
|
||||
IPage<GetUserClinicalArticleCommentPageDto> getUserClinicalArticleCommentPage(
|
||||
Page<?> page,
|
||||
@Param("userId") String userId
|
||||
);
|
||||
}
|
||||
@ -3,7 +3,9 @@ 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.GetUserClinicalArticleCommentPageDto;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
|
||||
import com.example.caseData.dto.userCommentClinicalVideo.GetUserClinicalVideoCommentPageDto;
|
||||
import com.example.caseData.dto.userCommentClinicalVideo.UserCommentClinicalVideoDto;
|
||||
import com.example.caseData.model.UserCommentClinicalVideoModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -29,4 +31,13 @@ public interface UserCommentClinicalVideoDao extends BaseMapper<UserCommentClini
|
||||
@Param("rootId") String rootId,
|
||||
@Param("limit") int limit
|
||||
);
|
||||
|
||||
/**
|
||||
* 临床病例库--评论-分页
|
||||
* @param page 分页数据
|
||||
*/
|
||||
IPage<GetUserClinicalVideoCommentPageDto> getUserClinicalVideoCommentPage(
|
||||
Page<?> page,
|
||||
@Param("userId") String userId
|
||||
);
|
||||
}
|
||||
@ -4,6 +4,7 @@ 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.caseExchange.CaseExchangeDto;
|
||||
import com.example.caseData.dto.userCommentCaseExchange.GetUserCaseExchangeCommentPageDto;
|
||||
import com.example.caseData.dto.userCommentCaseExchange.UserCommentCaseExchangeDto;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
|
||||
import com.example.caseData.model.CaseExchangeModel;
|
||||
@ -35,4 +36,13 @@ public interface UserCommentExchangeDao extends BaseMapper<UserCommentExchangeMo
|
||||
@Param("rootId") String rootId,
|
||||
@Param("limit") int limit
|
||||
);
|
||||
|
||||
/**
|
||||
* 临床病例库--评论-分页
|
||||
* @param page 分页数据
|
||||
*/
|
||||
IPage<GetUserCaseExchangeCommentPageDto> getUserCaseExchangeCommentPage(
|
||||
Page<?> page,
|
||||
@Param("userId") String userId
|
||||
);
|
||||
}
|
||||
|
||||
@ -0,0 +1,98 @@
|
||||
package com.example.caseData.dto.userCommentCaseExchange;
|
||||
|
||||
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 GetUserCaseExchangeCommentPageDto {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@JsonProperty("comment_id")
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 病例交流id
|
||||
*/
|
||||
@JsonProperty("exchange_id")
|
||||
private String exchangeId;
|
||||
|
||||
/**
|
||||
* 点赞数量
|
||||
*/
|
||||
@JsonProperty("like_num")
|
||||
private Integer likeNum;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
@JsonProperty("content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 评论内容(原版)
|
||||
*/
|
||||
@JsonProperty("content_word")
|
||||
private String contentWord;
|
||||
|
||||
/**
|
||||
* 评论图片
|
||||
*/
|
||||
@JsonProperty("comment_image")
|
||||
private String commentImage;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonProperty("created_at")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonProperty("updated_at")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@JsonProperty("exchange_title")
|
||||
private String exchangeTitle;
|
||||
|
||||
/**
|
||||
* 作者名称
|
||||
*/
|
||||
@JsonProperty("author_name")
|
||||
private String authorName;
|
||||
|
||||
/**
|
||||
* 作者医院id
|
||||
*/
|
||||
@JsonProperty("author_hospital_id")
|
||||
private String authorHospitalId;
|
||||
|
||||
/**
|
||||
* 作者医院
|
||||
*/
|
||||
@JsonProperty("author_hospital_name")
|
||||
private String authorHospitalName;
|
||||
|
||||
/**
|
||||
* 作者职称
|
||||
*/
|
||||
@JsonProperty("author_title_int")
|
||||
private Integer authorTitleInt;
|
||||
|
||||
/**
|
||||
* 作者职称
|
||||
*/
|
||||
@JsonProperty("author_title")
|
||||
private String authorTitle;
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.example.caseData.dto.userCommentClinicalArticle;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class GetUserClinicalArticleCommentPageDto {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@JsonProperty("comment_id")
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@JsonProperty("user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 文章id
|
||||
*/
|
||||
@JsonProperty("article_id")
|
||||
private String articleId;
|
||||
|
||||
/**
|
||||
* 点赞数量
|
||||
*/
|
||||
@JsonProperty("like_num")
|
||||
private Integer likeNum;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
@JsonProperty("content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 评论内容(原版)
|
||||
*/
|
||||
@JsonProperty("content_word")
|
||||
private String contentWord;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonProperty("created_at")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonProperty("updated_at")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
@JsonProperty("author")
|
||||
private List<CaseClinicalArticleAuthorDto> author;
|
||||
|
||||
@Data
|
||||
public static class CaseClinicalArticleAuthorDto {
|
||||
/**
|
||||
* 医生名称
|
||||
*/
|
||||
@JsonProperty("doctor_name")
|
||||
private String doctorName;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.example.caseData.dto.userCommentClinicalVideo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.example.caseData.dto.caseClinicalVideoAuthor.CaseClinicalVideoAuthorDto;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class GetUserClinicalVideoCommentPageDto {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@JsonProperty("comment_id")
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@JsonProperty("user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 视频id
|
||||
*/
|
||||
@JsonProperty("video_id")
|
||||
private String videoId;
|
||||
|
||||
/**
|
||||
* 点赞数量
|
||||
*/
|
||||
@JsonProperty("like_num")
|
||||
private Integer likeNum;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
@JsonProperty("content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 评论内容(原版)
|
||||
*/
|
||||
@JsonProperty("content_word")
|
||||
private String contentWord;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonProperty("created_at")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonProperty("updated_at")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
@JsonProperty("author")
|
||||
private List<CaseClinicalVideoAuthorDto> author;
|
||||
|
||||
@Data
|
||||
public static class CaseClinicalVideoAuthorDto {
|
||||
/**
|
||||
* 医生名称
|
||||
*/
|
||||
@JsonProperty("doctor_name")
|
||||
private String doctorName;
|
||||
}
|
||||
}
|
||||
97
src/main/java/com/example/caseData/extend/aliyun/Oss.java
Normal file
97
src/main/java/com/example/caseData/extend/aliyun/Oss.java
Normal file
@ -0,0 +1,97 @@
|
||||
package com.example.caseData.extend.aliyun;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
public class Oss {
|
||||
private static final String ENDPOINT = "your-endpoint";
|
||||
private static final String ACCESS_KEY_ID = "your-access-key-id";
|
||||
private static final String ACCESS_KEY_SECRET = "your-access-key-secret";
|
||||
private static final String BUCKET_NAME = "your-bucket";
|
||||
private static final String CALLBACK_URL = "your-callback-url";
|
||||
private static final String HOST = "https://your-bucket.your-endpoint";
|
||||
|
||||
public static OSS createClient() {
|
||||
return new OSSClientBuilder().build(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
|
||||
}
|
||||
|
||||
public static boolean putObject(String fileName, byte[] content) {
|
||||
OSS client = createClient();
|
||||
try (InputStream input = new ByteArrayInputStream(content)) {
|
||||
client.putObject(BUCKET_NAME, fileName, input);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getObjectToString(String fileName) {
|
||||
OSS client = createClient();
|
||||
try {
|
||||
OSSObject ossObject = client.getObject(BUCKET_NAME, fileName);
|
||||
InputStream content = ossObject.getObjectContent();
|
||||
return new String(content.readAllBytes());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean downloadObjectToFile(String fileName, String localPath) {
|
||||
OSS client = createClient();
|
||||
try {
|
||||
client.getObject(new GetObjectRequest(BUCKET_NAME, fileName), new java.io.File(localPath));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Object> getOssSign(String dir) {
|
||||
long expireTime = 30;
|
||||
long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
|
||||
Date expiration = new Date(expireEndTime);
|
||||
|
||||
PolicyConditions conditions = new PolicyConditions();
|
||||
conditions.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, 1048576000);
|
||||
conditions.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, dir);
|
||||
|
||||
OSS client = createClient();
|
||||
try {
|
||||
String postPolicy = client.generatePostPolicy(expiration, conditions);
|
||||
byte[] binaryData = postPolicy.getBytes("utf-8");
|
||||
String encodedPolicy = Base64.getEncoder().encodeToString(binaryData);
|
||||
String signature = client.calculatePostSignature(postPolicy);
|
||||
|
||||
Map<String, Object> respMap = new HashMap<>();
|
||||
respMap.put("access_id", ACCESS_KEY_ID);
|
||||
respMap.put("policy", encodedPolicy);
|
||||
respMap.put("signature", signature);
|
||||
respMap.put("dir", dir);
|
||||
respMap.put("host", HOST);
|
||||
respMap.put("expire", expireEndTime / 1000);
|
||||
respMap.put("callback", CALLBACK_URL);
|
||||
return respMap;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
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;
|
||||
|
||||
@Data
|
||||
public class getUserClinicalArticleCommentPage {
|
||||
// ✅ 分页参数
|
||||
@Min(value = 1,message = "页码最小为 1")
|
||||
private Integer page = 1;
|
||||
|
||||
@JsonProperty("page_size")
|
||||
@Min(value = 1, message = "每页个数最小为 1")
|
||||
private Integer pageSize = 20;
|
||||
|
||||
// ✅ 校验分页参数
|
||||
public void validateForPage() {
|
||||
// 如果 page 为空,设为默认值 1
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
if (pageSize == null) {
|
||||
pageSize = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.example.caseData.request.CaseClinicalVideoRequest;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class getUserClinicalVideoCommentPage {
|
||||
// ✅ 分页参数
|
||||
@Min(value = 1,message = "页码最小为 1")
|
||||
private Integer page = 1;
|
||||
|
||||
@JsonProperty("page_size")
|
||||
@Min(value = 1, message = "每页个数最小为 1")
|
||||
private Integer pageSize = 20;
|
||||
|
||||
// ✅ 校验分页参数
|
||||
public void validateForPage() {
|
||||
// 如果 page 为空,设为默认值 1
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
if (pageSize == null) {
|
||||
pageSize = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,7 @@ public class getCaseExchangeCommentPage {
|
||||
@Min(value = 1, message = "每页个数最小为 1")
|
||||
private Integer pageSize = 20;
|
||||
|
||||
// 文章id
|
||||
// 病例交流id
|
||||
@NotEmpty(message = "错误")
|
||||
@JsonProperty("exchange_id")
|
||||
private String exchangeId;
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package com.example.caseData.request.caseExchangeRequest;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class getUserCaseExchangeCommentPage {
|
||||
// ✅ 分页参数
|
||||
@Min(value = 1,message = "页码最小为 1")
|
||||
private Integer page = 1;
|
||||
|
||||
@JsonProperty("page_size")
|
||||
@Min(value = 1, message = "每页个数最小为 1")
|
||||
private Integer pageSize = 20;
|
||||
|
||||
// ✅ 校验分页参数
|
||||
public void validateForPage() {
|
||||
// 如果 page 为空,设为默认值 1
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
if (pageSize == null) {
|
||||
pageSize = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -53,4 +53,23 @@
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
<select id="getUserClinicalArticleCommentPage" resultType="com.example.caseData.dto.userCommentClinicalArticle.GetUserClinicalArticleCommentPageDto">
|
||||
SELECT
|
||||
a.comment_id,
|
||||
a.article_id,
|
||||
a.status,
|
||||
a.like_num,
|
||||
a.content,
|
||||
a.content_word,
|
||||
a.comment_image,
|
||||
a.created_at,
|
||||
b.article_title
|
||||
FROM user_comment_clinical_article a
|
||||
LEFT JOIN case_clinical_article b ON a.article_id = b.article_id
|
||||
WHERE a.status = 1
|
||||
AND b.article_status = 1
|
||||
|
||||
ORDER BY a.created_at DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -34,4 +34,23 @@
|
||||
ORDER BY a.is_top desc , a.created_at DESC
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
<select id="getUserClinicalVideoCommentPage" resultType="com.example.caseData.dto.userCommentClinicalVideo.GetUserClinicalVideoCommentPageDto">
|
||||
SELECT
|
||||
a.comment_id,
|
||||
a.video_id,
|
||||
a.status,
|
||||
a.like_num,
|
||||
a.content,
|
||||
a.content_word,
|
||||
a.comment_image,
|
||||
a.created_at,
|
||||
b.video_title
|
||||
FROM user_comment_clinical_video a
|
||||
LEFT JOIN case_clinical_video b ON a.video_id = b.video_id
|
||||
WHERE a.status = 1
|
||||
AND b.video_status = 1
|
||||
|
||||
ORDER BY a.created_at DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@ -36,4 +36,30 @@
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
<select id="getUserCaseExchangeCommentPage"
|
||||
resultType="com.example.caseData.dto.userCommentCaseExchange.GetUserCaseExchangeCommentPageDto">
|
||||
SELECT
|
||||
a.comment_id,
|
||||
a.exchange_id,
|
||||
a.status,
|
||||
a.like_num,
|
||||
a.content,
|
||||
a.content_word,
|
||||
a.comment_image,
|
||||
a.created_at,
|
||||
b.user_name as author_name,
|
||||
b.title as author_title_int,
|
||||
b.hospital_id as author_hospital_id,
|
||||
c.hospital_name as author_hospital_name,
|
||||
d.exchange_title
|
||||
FROM user_comment_exchange a
|
||||
LEFT JOIN user b ON a.user_id = b.user_id
|
||||
LEFT JOIN basic_hospital c ON b.hospital_id = c.hospital_id
|
||||
LEFT JOIN case_exchange d ON a.exchange_id = d.exchange_id
|
||||
WHERE a.status = 1
|
||||
AND a.user_id = #{userId}
|
||||
AND d.exchange_status = 1
|
||||
ORDER BY a.created_at DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user