新增了病例交流

This commit is contained in:
wucongxing8150 2025-05-29 14:43:39 +08:00
parent d3c30c0eee
commit 257b08d28e
47 changed files with 1877 additions and 25 deletions

View File

@ -59,7 +59,7 @@ public class CaseClinicalArticleController {
* 临床病例库-文章-详情
*/
@GetMapping("/clinical/article/{article_id}")
public Response<CaseClinicalArticleDto> getClinicalHospitalSearchPage(
public Response<CaseClinicalArticleDto> getClinicalArticle(
@PathVariable("article_id") String articleId
) {

View File

@ -0,0 +1,309 @@
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.caseClinicalArticle.CaseClinicalArticleDto;
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.model.*;
import com.example.caseData.request.caseExchangeRequest.getCaseExchangeSearchPage;
import com.example.caseData.service.CaseExchangeService;
import com.example.caseData.utils.Replace;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api")
public class CaseExchangeController {
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private CaseExchangeDao caseExchangeDao;
@Resource
private UserDao userDao;
@Resource
private BasicHospitalDao basicHospitalDao;
@Resource
private CaseExchangeService caseExchangeService;
@Resource
private CaseExchangeVoteDao caseExchangeVoteDao;
@Resource
private CaseExchangeVoteOptionDao caseExchangeVoteOptionDao;
@Resource
private UserVoteExchangeDao userVoteExchangeDao;
/**
* 临床病例库-病例交流-搜索
*/
@PostMapping("/exchange/search")
public Response<Map<String, Object>> getCaseExchangeSearchPage(
@Validated()
@RequestBody getCaseExchangeSearchPage request
) {
UserModel user = new UserModel();
BasicHospitalModel basicHospital = new BasicHospitalModel();
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId != null) {
user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
// 获取当前用户所属医院
basicHospital = basicHospitalDao.selectById(user.getHospitalId());
if (basicHospital == null) {
return Response.error();
}
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<CaseExchangeDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章数据
IPage<CaseExchangeDto> resultPage = caseExchangeDao.getCaseExchangeSearchPage(
page,
request.getKeyword(),
request.getUserId(),
request.handleOrder()
);
for (CaseExchangeDto dto : resultPage.getRecords()) {
// 查找用户所属医院
if (userId != null){
if (!userId.equals(dto.getUserId())){
user = userDao.selectById(dto.getUserId());
if (user == null) {
return Response.error();
}
// 获取当前用户所属医院
basicHospital = basicHospitalDao.selectById(user.getHospitalId());
if (basicHospital == null) {
return Response.error();
}
}
}else{
user = userDao.selectById(dto.getUserId());
if (user == null) {
return Response.error();
}
// 获取当前用户所属医院
basicHospital = basicHospitalDao.selectById(user.getHospitalId());
if (basicHospital == null) {
return Response.error();
}
}
dto.setAvatar(Replace.addOssDomain(user.getAvatar()));
dto.setUserName(user.getUserName());
dto.setHospitalName(basicHospital.getHospitalName());
// 获取用户收藏状态
if (userId != null) {
// 检测用户是否已收藏过
UserCollectExchangeModel userCollectExchangeModel = caseExchangeService.getUserCollectExchangeStatus(dto.getExchangeId(),userId);
if (userCollectExchangeModel != null) {
dto.setCollect(true);
}
}
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
/**
* 病例交流-详情
*/
@GetMapping("/exchange/{exchange_id}")
public Response<CaseExchangeDto> getExchange(
@PathVariable("exchange_id") String exchangeId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取文章数据
CaseExchangeModel caseExchange = caseExchangeDao.selectById(exchangeId);
if (caseExchange == null) {
return Response.error();
}
// 查找用户
UserModel user = userDao.selectById(caseExchange.getUserId());
if (user == null) {
return Response.error();
}
// 获取当前用户所属医院
BasicHospitalModel basicHospital = basicHospitalDao.selectById(user.getHospitalId());
if (basicHospital == null) {
return Response.error();
}
// 获取投票数据
LambdaQueryWrapper<CaseExchangeVoteModel> caseExchangeVoteQueryWrapper = new LambdaQueryWrapper<>();
caseExchangeVoteQueryWrapper.eq(CaseExchangeVoteModel::getExchangeId, caseExchange.getExchangeId());
CaseExchangeVoteModel caseExchangeVote = caseExchangeVoteDao.selectOne(caseExchangeVoteQueryWrapper);
if (caseExchangeVote != null) {
// 检测是否过期
if (caseExchangeVote.getEndTime() == null) {
return Response.error();
}
// 获取选项
LambdaQueryWrapper<CaseExchangeVoteOptionModel> caseExchangeVoteOptionQueryWrapper = new LambdaQueryWrapper<>();
caseExchangeVoteOptionQueryWrapper.eq(CaseExchangeVoteOptionModel::getVoteId, caseExchangeVote.getVoteId());
List<CaseExchangeVoteOptionModel> caseExchangeVoteOptions = caseExchangeVoteOptionDao.selectList(caseExchangeVoteOptionQueryWrapper);
if (caseExchangeVoteOptions.isEmpty()) {
return Response.error();
}
caseExchangeVote.setCaseExchangeVoteOption(caseExchangeVoteOptions);
caseExchange.setCaseExchangeVote(caseExchangeVote);
}
// 处理返回值
CaseExchangeDto g = CaseExchangeDto.GetDto(caseExchange);
g.setAvatar(Replace.addOssDomain(user.getAvatar()));
g.setUserName(user.getUserName());
g.setHospitalName(basicHospital.getHospitalName());
// 获取用户收藏状态
if (userId != null) {
// 检测用户是否已收藏过
UserCollectExchangeModel userCollectExchangeModel = caseExchangeService.getUserCollectExchangeStatus(String.valueOf(caseExchange.getExchangeId()),userId);
if (userCollectExchangeModel != null) {
g.setCollect(true);
}
}
// 过期状态
if (g.getCaseExchangeVote().getEndTime().isAfter(LocalDateTime.now())) {
g.getCaseExchangeVote().setIsEnabled(1);
}else{
g.getCaseExchangeVote().setIsEnabled(0);
}
// 用户投票状态
if (userId != null) {
LambdaQueryWrapper<UserVoteExchangeModel> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(UserVoteExchangeModel::getUserId, userId);
queryWrapper.eq(UserVoteExchangeModel::getExchangeId, exchangeId);
queryWrapper.eq(UserVoteExchangeModel::getVoteId, g.getCaseExchangeVote().getVoteId());
UserVoteExchangeModel userVoteExchange = userVoteExchangeDao.selectOne(queryWrapper);
if (userVoteExchange != null) {
// 已投过票
g.getCaseExchangeVote().setIsEnabled(0);
}
}
// 处理投票数据
Integer voteNum = 0;
for (CaseExchangeVoteOptionDto dto : g.getCaseExchangeVote().getCaseExchangeVoteOption()){
voteNum += dto.getVoteNum();
}
for (CaseExchangeVoteOptionDto dto : g.getCaseExchangeVote().getCaseExchangeVoteOption()){
Integer proportion = (int) (Math.round((double) dto.getVoteNum() / voteNum * 10000) / 100.0);
dto.setProportion(proportion);
}
return Response.success(g);
}
/**
* 病例交流-详情-投票数据
*/
@GetMapping("/exchange/vote/{exchange_id}")
public Response<CaseExchangeVoteDto> getExchangeVote(
@PathVariable("exchange_id") String exchangeId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取投票数据
LambdaQueryWrapper<CaseExchangeVoteModel> caseExchangeVoteQueryWrapper = new LambdaQueryWrapper<>();
caseExchangeVoteQueryWrapper.eq(CaseExchangeVoteModel::getExchangeId, exchangeId);
CaseExchangeVoteModel caseExchangeVote = caseExchangeVoteDao.selectOne(caseExchangeVoteQueryWrapper);
if (caseExchangeVote == null) {
return Response.success();
}
// 检测是否过期
if (caseExchangeVote.getEndTime() == null) {
return Response.error();
}
// 获取选项
LambdaQueryWrapper<CaseExchangeVoteOptionModel> caseExchangeVoteOptionQueryWrapper = new LambdaQueryWrapper<>();
caseExchangeVoteOptionQueryWrapper.eq(CaseExchangeVoteOptionModel::getVoteId, caseExchangeVote.getVoteId());
List<CaseExchangeVoteOptionModel> caseExchangeVoteOptions = caseExchangeVoteOptionDao.selectList(caseExchangeVoteOptionQueryWrapper);
if (caseExchangeVoteOptions.isEmpty()) {
return Response.error();
}
caseExchangeVote.setCaseExchangeVoteOption(caseExchangeVoteOptions);
// 处理返回值
CaseExchangeVoteDto g = CaseExchangeVoteDto.GetDto(caseExchangeVote);
// 过期状态
if (g.getEndTime().isAfter(LocalDateTime.now())) {
g.setIsEnabled(1);
}else{
g.setIsEnabled(0);
}
// 用户投票状态
if (userId != null) {
LambdaQueryWrapper<UserVoteExchangeModel> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(UserVoteExchangeModel::getUserId, userId);
queryWrapper.eq(UserVoteExchangeModel::getExchangeId, exchangeId);
queryWrapper.eq(UserVoteExchangeModel::getVoteId, g.getVoteId());
UserVoteExchangeModel userVoteExchange = userVoteExchangeDao.selectOne(queryWrapper);
if (userVoteExchange != null) {
// 已投过票
g.setIsEnabled(0);
}
}
// 处理投票数据
Integer voteNum = 0;
for (CaseExchangeVoteOptionDto dto : g.getCaseExchangeVoteOption()){
voteNum += dto.getVoteNum();
}
for (CaseExchangeVoteOptionDto dto : g.getCaseExchangeVoteOption()){
Integer proportion = (int) (Math.round((double) dto.getVoteNum() / voteNum * 10000) / 100.0);
dto.setProportion(proportion);
}
return Response.success(g);
}
}

View File

@ -0,0 +1,63 @@
package com.example.caseData.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.caseData.common.Response;
import com.example.caseData.dao.StatsCaseExchangeDao;
import com.example.caseData.dao.StatsCaseExchangeUserDao;
import com.example.caseData.dao.StatsCaseExchangeUserDao;
import com.example.caseData.dto.statsCaseExchange.StatsCaseExchangeDto;
import com.example.caseData.dto.statsCaseExchange.StatsCaseExchangeDto;
import com.example.caseData.dto.statsCaseExchangeUser.StatsCaseExchangeUserDto;
import com.example.caseData.model.StatsCaseExchangeUserModel;
import com.example.caseData.model.StatsCaseExchangeModel;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api")
public class StatsCaseExchangeController extends BaseController {
@Resource
private StatsCaseExchangeDao statsCaseExchangeDao;
@Resource
private StatsCaseExchangeUserDao statsCaseExchangeUserDao;
@Resource
private HttpServletRequest httpServletRequest;
/**
* 病例交流-统计
*/
@GetMapping("/exchange/stats")
public Response<StatsCaseExchangeDto> getClinicalStats(){
LambdaQueryWrapper<StatsCaseExchangeModel> statsCaseExchangeQueryWrapper = new LambdaQueryWrapper<>();
StatsCaseExchangeModel statsCaseExchange = statsCaseExchangeDao.selectOne(statsCaseExchangeQueryWrapper);
StatsCaseExchangeDto g = StatsCaseExchangeDto.GetDto(statsCaseExchange);
return Response.success(g);
}
/**
* 病例交流-用户
*/
@GetMapping("/exchange/stats/user")
public Response<StatsCaseExchangeUserDto> getClinicalStatsUser(){
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId != null) {
return Response.error();
}
LambdaQueryWrapper<StatsCaseExchangeUserModel> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StatsCaseExchangeUserModel::getUserId, userId);
StatsCaseExchangeUserModel statsCaseExchangeUser = statsCaseExchangeUserDao.selectOne(queryWrapper);
StatsCaseExchangeUserDto g = StatsCaseExchangeUserDto.GetDto(statsCaseExchangeUser);
return Response.success(g);
}
}

View File

@ -89,4 +89,6 @@ public class UserController extends BaseController {
return Response.success(g);
}
}

View File

@ -0,0 +1,30 @@
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.caseExchange.CaseExchangeDto;
import com.example.caseData.model.CaseClinicalArticleModel;
import com.example.caseData.model.CaseExchangeModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface CaseExchangeDao extends BaseMapper<CaseExchangeModel> {
/**
* 临床病例库-搜索
* @param page 分页数据
* @param keyword 搜索关键词-标题/医生名称/标签名称
* @param order 排序
*/
IPage<CaseExchangeDto> getCaseExchangeSearchPage(
Page<?> page,
@Param("keyword") String keyword,
@Param("userId") String userId,
@Param("order") Map<String, String> order
);
}

View File

@ -0,0 +1,9 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.CaseExchangeModel;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CaseExchangeLabelDao extends BaseMapper<CaseExchangeModel> {
}

View File

@ -0,0 +1,16 @@
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.caseExchange.CaseExchangeDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.CaseExchangeVoteModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface CaseExchangeVoteDao extends BaseMapper<CaseExchangeVoteModel> {
}

View File

@ -0,0 +1,10 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.CaseExchangeVoteModel;
import com.example.caseData.model.CaseExchangeVoteOptionModel;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CaseExchangeVoteOptionDao extends BaseMapper<CaseExchangeVoteOptionModel> {
}

View File

@ -0,0 +1,30 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.StatsCaseClinicalModel;
import com.example.caseData.model.StatsCaseExchangeModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
public interface StatsCaseExchangeDao extends BaseMapper<StatsCaseExchangeModel> {
/**
* Inc 自增
* @param articleId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_exchange SET ${field} = ${field} + #{numeral} WHERE stats_id = #{statsId}")
int inc(@Param("statsId") Long articleId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param articleId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_exchange SET ${field} = ${field} - #{numeral} WHERE stats_id = #{statsId}")
int dec(@Param("statsId") Long articleId, @Param("field") String field, @Param("numeral") int numeral);
}

View File

@ -0,0 +1,17 @@
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.caseExchange.CaseExchangeDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.StatsCaseExchangeUserModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface StatsCaseExchangeUserDao extends BaseMapper<StatsCaseExchangeUserModel> {
}

View File

@ -0,0 +1,10 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.UserCollectExchangeModel;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserCollectExchangeDao extends BaseMapper<UserCollectExchangeModel> {
}

View File

@ -0,0 +1,17 @@
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.caseExchange.CaseExchangeDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.UserCommentExchangeModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface UserCommentExchangeDao extends BaseMapper<UserCommentExchangeModel> {
}

View File

@ -0,0 +1,11 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.UserCommentExchangeModel;
import com.example.caseData.model.UserVoteExchangeModel;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserVoteExchangeDao extends BaseMapper<UserVoteExchangeModel> {
}

View File

@ -0,0 +1,169 @@
package com.example.caseData.dto.caseExchange;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
import com.example.caseData.dto.caseExchangeVote.CaseExchangeVoteDto;
import com.example.caseData.dto.caseExchangeVoteOption.CaseExchangeVoteOptionDto;
import com.example.caseData.model.CaseExchangeModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class CaseExchangeDto {
/**
* 主键id
*/
@JsonProperty("exchange_id")
private String exchangeId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 标题
*/
@JsonProperty("exchange_title")
private String exchangeTitle;
/**
* 状态1:正常 2:禁用
*/
@JsonProperty("exchange_status")
private Integer exchangeStatus;
/**
* 阅读量
*/
@JsonProperty("read_num")
private Integer readNum;
/**
* 收藏量
*/
@JsonProperty("collect_num")
private Integer collectNum;
/**
* 发表时间
*/
@JsonProperty("push_date")
private LocalDateTime pushDate;
/**
* 内容
*/
@JsonProperty("exchange_content")
private String exchangeContent;
/**
* 总结
*/
@JsonProperty("exchange_summary")
private String exchangeSummary;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 用户名称
*/
@JsonProperty("user_name")
private String userName; // 用户名称
/**
* 头像
*/
@JsonProperty("avatar")
private String avatar; // 头像
/**
* 所属医院名称
*/
@JsonProperty("hospital_name")
private String hospitalName; // 所属医院名称
/**
* 收藏状态
*/
@JsonProperty("is_collect")
private boolean isCollect;
/**
* 投票数据
*/
@JsonProperty("case_exchange_vote")
private CaseExchangeVoteDto caseExchangeVote;
/**
* 列表
*/
public static List<CaseExchangeDto> GetListDto(List<CaseExchangeModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
CaseExchangeDto dto = BeanUtil.copyProperties(model, CaseExchangeDto.class);
// 示例手动处理字段类型不一致
if (model.getExchangeId() != null) {
dto.setExchangeId(String.valueOf(model.getExchangeId())); // Long -> String
}
dto.setExchangeContent("");
dto.setExchangeSummary("");
// 投票
if (model.getCaseExchangeVote() != null) {
CaseExchangeVoteDto listDto = CaseExchangeVoteDto.GetDto(model.getCaseExchangeVote());
dto.setCaseExchangeVote(listDto);
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static CaseExchangeDto GetDto(CaseExchangeModel model) {
if (model == null) {
return null;
}
CaseExchangeDto dto = BeanUtil.copyProperties(model, CaseExchangeDto.class);
// 类型转换示例
if (model.getExchangeId() != null) {
dto.setExchangeId(String.valueOf(model.getExchangeId())); // Long -> String
}
// 投票
if (model.getCaseExchangeVote() != null) {
CaseExchangeVoteDto listDto = CaseExchangeVoteDto.GetDto(model.getCaseExchangeVote());
dto.setCaseExchangeVote(listDto);
}
return dto;
}
}

View File

@ -0,0 +1,118 @@
package com.example.caseData.dto.caseExchangeVote;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.dto.caseExchangeVoteOption.CaseExchangeVoteOptionDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.CaseExchangeVoteModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class CaseExchangeVoteDto {
/**
* 主键id
*/
@JsonProperty("vote_id")
private String voteId;
/**
* 病例交流id
*/
@JsonProperty("exchange_id")
private String exchangeId;
/**
* 选项标题
*/
@JsonProperty("vote_title")
private String voteTitle;
/**
* 结束投票时间
*/
@JsonProperty("end_time")
private LocalDateTime endTime;
/**
* 是否开启中0: 1:
*/
@JsonProperty("is_enabled")
private Integer isEnabled;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 选项
*/
@JsonProperty("case_exchange_vote_option")
private List<CaseExchangeVoteOptionDto> caseExchangeVoteOption;
/**
* 列表
*/
public static List<CaseExchangeVoteDto> GetListDto(List<CaseExchangeVoteModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
CaseExchangeVoteDto dto = BeanUtil.copyProperties(model, CaseExchangeVoteDto.class);
// 示例手动处理字段类型不一致
if (model.getVoteId() != null) {
dto.setVoteId(String.valueOf(model.getVoteId())); // Long -> String
}
// 选项
if (model.getCaseExchangeVoteOption() != null && !model.getCaseExchangeVoteOption().isEmpty()) {
List<CaseExchangeVoteOptionDto> caseExchangeVoteOptionListDto = CaseExchangeVoteOptionDto.GetListDto(model.getCaseExchangeVoteOption());
dto.setCaseExchangeVoteOption(caseExchangeVoteOptionListDto);
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static CaseExchangeVoteDto GetDto(CaseExchangeVoteModel model) {
if (model == null) {
return null;
}
CaseExchangeVoteDto dto = BeanUtil.copyProperties(model, CaseExchangeVoteDto.class);
// 类型转换示例
if (model.getVoteId() != null) {
dto.setVoteId(String.valueOf(model.getVoteId())); // Long -> String
}
// 选项
if (model.getCaseExchangeVoteOption() != null && !model.getCaseExchangeVoteOption().isEmpty()) {
List<CaseExchangeVoteOptionDto> caseExchangeVoteOptionListDto = CaseExchangeVoteOptionDto.GetListDto(model.getCaseExchangeVoteOption());
dto.setCaseExchangeVoteOption(caseExchangeVoteOptionListDto);
}
return dto;
}
}

View File

@ -0,0 +1,98 @@
package com.example.caseData.dto.caseExchangeVoteOption;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.caseExchangeVote.CaseExchangeVoteDto;
import com.example.caseData.model.CaseExchangeVoteModel;
import com.example.caseData.model.CaseExchangeVoteOptionModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class CaseExchangeVoteOptionDto {
/**
* 主键id
*/
@JsonProperty("option_id")
private String optionId;
/**
* 投票id
*/
@JsonProperty("vote_id")
private String voteId;
/**
* 选项
*/
@JsonProperty("option_value")
private String optionValue;
/**
* 票数
*/
@JsonProperty("vote_num")
private Integer voteNum;
/**
* 被选择占比
*/
@JsonProperty("proportion")
private Integer proportion;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 列表
*/
public static List<CaseExchangeVoteOptionDto> GetListDto(List<CaseExchangeVoteOptionModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
CaseExchangeVoteOptionDto dto = BeanUtil.copyProperties(model, CaseExchangeVoteOptionDto.class);
// 示例手动处理字段类型不一致
if (model.getOptionId() != null) {
dto.setOptionId(String.valueOf(model.getOptionId())); // Long -> String
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static CaseExchangeVoteOptionDto GetDto(CaseExchangeVoteOptionModel model) {
if (model == null) {
return null;
}
CaseExchangeVoteOptionDto dto = BeanUtil.copyProperties(model, CaseExchangeVoteOptionDto.class);
// 类型转换示例
if (model.getOptionId() != null) {
dto.setOptionId(String.valueOf(model.getOptionId())); // Long -> String
}
return dto;
}
}

View File

@ -1,6 +1,7 @@
package com.example.caseData.dto.statsCaseClinical;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.example.caseData.model.StatsCaseClinicalModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@ -17,6 +18,12 @@ public class StatsCaseClinicalDto {
@JsonProperty("stats_id")
private String statsId;
/**
* 数量-文章
*/
@JsonProperty("article_num")
private Integer articleNum;
/**
* 总阅读量-文章
*/
@ -29,6 +36,12 @@ public class StatsCaseClinicalDto {
@JsonProperty("article_collect_num")
private Integer articleCollectNum;
/**
* 数量-视频
*/
@JsonProperty("video_num")
private Integer videoNum;
/**
* 总阅读量-视频
*/

View File

@ -0,0 +1,90 @@
package com.example.caseData.dto.statsCaseExchange;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.model.StatsCaseExchangeModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class StatsCaseExchangeDto {
/**
* 主键id
*/
@JsonProperty("stats_id")
private String statsId;
/**
* 数量-病例交流
*/
@JsonProperty("exchange_num")
private Integer exchangeNum;
/**
* 总阅读量-病例交流
*/
@JsonProperty("exchange_read_num")
private Integer exchangeReadNum;
/**
* 总收藏量-病例交流
*/
@JsonProperty("exchange_collect_num")
private Integer exchangeCollectNum;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 列表
*/
public static List<StatsCaseExchangeDto> GetListDto(List<StatsCaseExchangeModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
StatsCaseExchangeDto dto = BeanUtil.copyProperties(model, StatsCaseExchangeDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static StatsCaseExchangeDto GetDto(StatsCaseExchangeModel model) {
if (model == null) {
return null;
}
StatsCaseExchangeDto dto = BeanUtil.copyProperties(model, StatsCaseExchangeDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
}
}

View File

@ -0,0 +1,96 @@
package com.example.caseData.dto.statsCaseExchangeUser;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.model.StatsCaseExchangeUserModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class StatsCaseExchangeUserDto {
/**
* 主键id
*/
@JsonProperty("stats_id")
private String statsId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 数量-病例交流
*/
@JsonProperty("exchange_num")
private Integer exchangeNum;
/**
* 总阅读量-病例交流
*/
@JsonProperty("exchange_read_num")
private Integer exchangeReadNum;
/**
* 总收藏量-病例交流
*/
@JsonProperty("exchange_collect_num")
private Integer exchangeCollectNum;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 列表
*/
public static List<StatsCaseExchangeUserDto> GetListDto(List<StatsCaseExchangeUserModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
StatsCaseExchangeUserDto dto = BeanUtil.copyProperties(model, StatsCaseExchangeUserDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static StatsCaseExchangeUserDto GetDto(StatsCaseExchangeUserModel model) {
if (model == null) {
return null;
}
StatsCaseExchangeUserDto dto = BeanUtil.copyProperties(model, StatsCaseExchangeUserDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
}
}

View File

@ -26,24 +26,6 @@ import java.util.Map;
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {
// 处理所有未捕获的异常
@ExceptionHandler(Exception.class)
public ResponseEntity<Map<String, Object>> handleGlobalException(Exception ex) {
System.out.print(ExceptionUtils.getStackTrace(ex));
Map<String, Object> errorResponse = new HashMap<>();
String message = ExceptionUtils.getStackTrace(ex);
if (EnvUtil.isProd()) {
log.error("error:{}", message);
message = "内部错误";
}
errorResponse.put("message", "异常");
errorResponse.put("data", null);
errorResponse.put("code", HttpStatus.INTERNAL_SERVER_ERROR.value());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse);
}
// 处理 404 请求接口不存在
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
@ -92,4 +74,22 @@ public class GlobalExceptionHandler {
errorResponse.put("code", ex.getCode());
return ResponseEntity.ok(errorResponse);
}
// 处理所有未捕获的异常
@ExceptionHandler(Exception.class)
public ResponseEntity<Map<String, Object>> handleGlobalException(Exception ex) {
System.out.print(ExceptionUtils.getStackTrace(ex));
Map<String, Object> errorResponse = new HashMap<>();
String message = ExceptionUtils.getStackTrace(ex);
if (EnvUtil.isProd()) {
log.error("error:{}", message);
message = "内部错误";
}
errorResponse.put("message", "异常");
errorResponse.put("data", null);
errorResponse.put("code", HttpStatus.INTERNAL_SERVER_ERROR.value());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse);
}
}

View File

@ -1,6 +1,7 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -67,6 +68,7 @@ public class BasicHospitalModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -1,6 +1,7 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -24,6 +25,7 @@ public class BasicSensitiveWordModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -31,7 +31,7 @@ public class CaseClinicalArticleAuthorModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("updated_at")
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -1,6 +1,7 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -35,6 +36,7 @@ public class CaseClinicalArticleLabelModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -53,7 +53,7 @@ public class CaseClinicalArticleModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("updated_at")
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -52,7 +52,7 @@ public class CaseClinicalDoctorModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("updated_at")
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -37,7 +37,7 @@ public class CaseClinicalVideoLabelModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("updated_at")
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -56,7 +56,7 @@ public class CaseClinicalVideoModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("updated_at")
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -0,0 +1,52 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 病例库-病例交流-标签实体类
*/
@Data // Lombok注解用于自动生成getter/setter方法等
@TableName("`case_exchange_label`") // 指定数据库表名
public class CaseExchangeLabelModel {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long exchangeLabelId;
/**
* 临床文章id
*/
@TableField("exchange_id")
private Long exchangeId;
/**
* app唯一标识
*/
@TableField("app_iden")
private String appIden;
/**
* 标签名称
*/
@TableField("label_name")
private String labelName;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
}

View File

@ -0,0 +1,90 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
* 病例库-病例交流实体类
*/
@Data // Lombok注解用于自动生成getter/setter方法等
@TableName("`case_exchange`") // 指定数据库表名
public class CaseExchangeModel {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long exchangeId;
/**
* 用户id
*/
@TableField("user_id")
private Long userId;
/**
* 标题
*/
@TableField("exchange_title")
private String exchangeTitle;
/**
* 状态1:正常 2:禁用
*/
@TableField("exchange_status")
private Integer exchangeStatus;
/**
* 阅读量
*/
@TableField("read_num")
private Integer readNum;
/**
* 收藏量
*/
@TableField("collect_num")
private Integer collectNum;
/**
* 发表时间
*/
@TableField("push_date")
private LocalDateTime pushDate;
/**
* 内容
*/
@TableField("exchange_content")
private String exchangeContent;
/**
* 总结
*/
@TableField("exchange_summary")
private String exchangeSummary;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 投票
*/
@TableField(exist = false)
@JsonProperty("case_exchange_vote")
private CaseExchangeVoteModel caseExchangeVote;
}

View File

@ -0,0 +1,58 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
* 病例库-病例交流-投票实体类
*/
@Data // Lombok注解用于自动生成getter/setter方法等
@TableName("`case_exchange_vote`") // 指定数据库表名
public class CaseExchangeVoteModel {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long voteId;
/**
* 病例交流id
*/
@TableField("exchange_id")
private Long exchangeId;
/**
* 选项标题
*/
@TableField("vote_title")
private String voteTitle;
/**
* 结束投票时间
*/
@TableField("end_time")
private LocalDateTime endTime;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
// 选项
@TableField(exist = false)
@JsonProperty("case_exchange_vote_option")
private List<CaseExchangeVoteOptionModel> caseExchangeVoteOption;
}

View File

@ -0,0 +1,52 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 病例库-病例交流-投票选项实体类
*/
@Data // Lombok注解用于自动生成getter/setter方法等
@TableName("`case_exchange_vote_option`") // 指定数据库表名
public class CaseExchangeVoteOptionModel {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long optionId;
/**
* 投票id
*/
@TableField("vote_id")
private Long voteId;
/**
* 选项
*/
@TableField("option_value")
private String optionValue;
/**
* 票数
*/
@TableField("vote_num")
private Integer voteNum;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
}

View File

@ -1,6 +1,7 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -63,6 +64,7 @@ public class StatsCaseClinicalDoctorModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -67,7 +67,7 @@ public class StatsCaseClinicalHospitalModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("updated_at")
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -1,6 +1,7 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -14,6 +15,12 @@ public class StatsCaseClinicalModel {
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long statsId;
/**
* 数量-文章
*/
@TableField("article_num")
private Integer articleNum;
/**
* 总阅读量-文章
*/
@ -26,6 +33,12 @@ public class StatsCaseClinicalModel {
@TableField("article_collect_num")
private Integer articleCollectNum;
/**
* 数量-视频
*/
@TableField("video_num")
private Integer videoNum;
/**
* 总阅读量-视频
*/
@ -42,6 +55,7 @@ public class StatsCaseClinicalModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -0,0 +1,51 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 统计表-病例库-病例交流实体类
*/
@Data // Lombok注解用于自动生成getter/setter方法等
@TableName("`stats_case_exchange`") // 指定数据库表名
public class StatsCaseExchangeModel {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long statsId;
/**
* 数量-病例交流
*/
@TableField("exchange_num")
private Integer exchangeNum;
/**
* 总阅读量-病例交流
*/
@TableField("exchange_read_num")
private Integer exchangeReadNum;
/**
* 总收藏量-病例交流
*/
@TableField("exchange_collect_num")
private Integer exchangeCollectNum;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@ -0,0 +1,57 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 统计表-病例库-病例交流-用户实体类
*/
@Data // Lombok注解用于自动生成getter/setter方法等
@TableName("`stats_case_exchange_user`") // 指定数据库表名
public class StatsCaseExchangeUserModel {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long statsId;
/**
* 用户id
*/
@TableField("user_id")
private Long userId;
/**
* 数量-病例交流
*/
@TableField("exchange_num")
private Integer exchangeNum;
/**
* 总阅读量-病例交流
*/
@TableField("exchange_read_num")
private Integer exchangeReadNum;
/**
* 总收藏量-病例交流
*/
@TableField("exchange_collect_num")
private Integer exchangeCollectNum;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@ -1,6 +1,7 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -30,6 +31,7 @@ public class UserCollectClinicalArticleModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -1,6 +1,7 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -30,6 +31,7 @@ public class UserCollectClinicalVideoModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -0,0 +1,45 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 用户收藏-病例交流实体类
*/
@Data // Lombok注解用于自动生成getter/setter方法等
@TableName("`user_collect_exchange`") // 指定数据库表名
public class UserCollectExchangeModel {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long collectId;
/**
* 用户id
*/
@TableField("user_id")
private Long userId;
/**
* 临床文章id
*/
@TableField("exchange_id")
private Long exchangeId;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@ -1,6 +1,7 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -90,6 +91,7 @@ public class UserCommentClinicalArticleModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -1,6 +1,7 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -84,6 +85,7 @@ public class UserCommentClinicalVideoModel {
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**

View File

@ -0,0 +1,103 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 用户评论-病例交流实体类
*/
@Data // Lombok注解用于自动生成getter/setter方法等
@TableName("`user_comment_exchange`") // 指定数据库表名
public class UserCommentExchangeModel {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long commentId;
/**
* 用户id
*/
@TableField("user_id")
private Long userId;
/**
* 病例交流id
*/
@TableField("exchange_id")
private Long exchangeId;
/**
* 父级id一级评论为null
*/
@TableField("parent_id")
private Long parentId;
/**
* 根评论id一级评论时为null其余为一级评论id
*/
@TableField("root_id")
private Long rootId;
/**
* 评论状态0:禁用 1:正常
*/
private Integer status;
/**
* 是否存在敏感词0: 1:
*/
@TableField("is_sensitive")
private Integer isSensitive;
/**
* 是否置顶0: 1:
*/
@TableField("is_top")
private Integer isTop;
/**
* 点赞数量
*/
@TableField("like_num")
private Integer likeNum;
/**
* 是否作者评论0: 1:
*/
@TableField("is_author")
private Integer isAuthor;
/**
* 评论内容
*/
private String content;
/**
* 评论内容(原版)
*/
@TableField("content_word")
private String contentWord;
/**
* 评论图片
*/
@TableField("comment_image")
private String commentImage;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@ -0,0 +1,57 @@
package com.example.caseData.model;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 用户投票表-病例交流实体类
*/
@Data // Lombok注解用于自动生成getter/setter方法等
@TableName("`user_vote_exchange`") // 指定数据库表名
public class UserVoteExchangeModel {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID) // 使用MyBatis-Plus的ID生成策略
private Long voteExchangeId;
/**
* 用户id
*/
@TableField("user_id")
private Long userId;
/**
* 病例交流id
*/
@TableField("exchange_id")
private Long exchangeId;
/**
* 投票id
*/
@TableField("vote_id")
private Long voteId;
/**
* 投票时间
*/
@TableField("vote_time")
private LocalDateTime voteTime;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@ -0,0 +1,88 @@
package com.example.caseData.request.caseExchangeRequest;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Min;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
@Data
public class getCaseExchangeSearchPage {
// 分页参数
@Min(value = 1,message = "页码最小为 1")
private Integer page = 1;
@JsonProperty("page_size")
@Min(value = 1, message = "每页个数最小为 1")
private Integer pageSize = 20;
// 标题/作者名称/疾病名称
@JsonProperty("keyword")
private String keyword;
// 用户id
@JsonProperty("user_id")
private String userId;
// 排序字段
private OrderRequest order;
/**
* 排序字段嵌套结构体
*/
@Data
public static class OrderRequest {
@JsonProperty("created_at")
private String createdAt; // 创建时间
@JsonProperty("read_num")
private String readNum; // 阅读量
@JsonProperty("push_date")
private String pushDate; // 发表时间
public Map<String, String> toMap() {
Map<String, String> map = new HashMap<>();
if (StringUtils.hasText(createdAt)) {
map.put("a.created_at", createdAt);
}
if (StringUtils.hasText(readNum)) {
map.put("a.read_num", readNum);
}
if (StringUtils.hasText(pushDate)) {
map.put("a.push_date", pushDate);
}
// 默认排序如果用户未传递任何排序字段
if (map.isEmpty()) {
map.put("a.updated_at", "desc");
}
return map;
}
}
/**
* 获取排序字段若无用户输入则使用默认排序
*/
public Map<String, String> handleOrder() {
return order != null ? order.toMap() : new OrderRequest().toMap();
}
// 校验分页参数
public void validateForPage() {
// 如果 page 为空设为默认值 1
if (page == null) {
page = 1;
}
if (pageSize == null) {
pageSize = 20;
}
}
}

View File

@ -0,0 +1,30 @@
package com.example.caseData.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.caseData.dao.UserCollectClinicalArticleDao;
import com.example.caseData.dao.UserCollectExchangeDao;
import com.example.caseData.model.UserCollectExchangeModel;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
@Service
public class CaseExchangeService {
@Resource
private UserCollectExchangeDao userCollectExchangeDao;
/**
* 获取用户收藏数据
* @param exchangeId 病例交流id
* @param userId 用户id
* @return bool false:未收藏 true已收藏
*/
public UserCollectExchangeModel getUserCollectExchangeStatus(String exchangeId, String userId){
// 检测用户是否已收藏过
LambdaQueryWrapper<UserCollectExchangeModel> mapQueryWrapper = new LambdaQueryWrapper<>();
mapQueryWrapper.eq(UserCollectExchangeModel::getUserId, userId);
mapQueryWrapper.eq(UserCollectExchangeModel::getExchangeId, exchangeId);
return userCollectExchangeDao.selectOne(mapQueryWrapper);
}
}

View File

@ -0,0 +1,31 @@
<?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.CaseExchangeDao">
<select id="getCaseExchangeSearchPage" resultType="com.example.caseData.dto.caseExchange.CaseExchangeDto">
SELECT DISTINCT
a.*,
c.user_name,
c.avatar,
c.hospital_id
FROM case_exchange a
LEFT JOIN case_exchange_label b ON a.exchange_id = b.exchange_id
LEFT JOIN user c ON c.user_id = a.user_id
WHERE a.exchange_status = 1
<if test="keyword != null and keyword != ''">
AND (
a.exchange_title LIKE CONCAT('%', #{keyword}, '%')
OR c.user_name LIKE CONCAT('%', #{keyword}, '%')
OR b.label_name LIKE CONCAT('%', #{keyword}, '%')
)
</if>
<if test="userId != null and userId != ''">
AND c.user_id = ${userId}
</if>
<if test="order != null and !order.isEmpty()">
ORDER BY
<foreach item="entry" index="key" collection="order" separator=",">
${key} ${entry}
</foreach>
</if>
</select>
</mapper>