获取用户信息增加了医生id
This commit is contained in:
parent
9e1c30a81c
commit
6aaff9f345
@ -9,6 +9,7 @@ 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.UserCommentCaseExchangeDto;
|
||||
import com.example.caseData.exception.BusinessException;
|
||||
import com.example.caseData.model.*;
|
||||
import com.example.caseData.request.caseExchangeRequest.addCaseExchange;
|
||||
@ -58,6 +59,9 @@ public class CaseExchangeController {
|
||||
@Resource
|
||||
private UserVoteExchangeDao userVoteExchangeDao;
|
||||
|
||||
@Resource
|
||||
private UserCommentExchangeDao userCommentExchangeDao;
|
||||
|
||||
/**
|
||||
* 临床病例库-病例交流-搜索
|
||||
*/
|
||||
@ -497,87 +501,65 @@ public class CaseExchangeController {
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 病例交流-评论-列表
|
||||
// */
|
||||
// @PostMapping("/exchange/comment/page")
|
||||
// public Response<Map<String, Object>> getCaseExchangeCommentPage(
|
||||
// @Validated()
|
||||
// @RequestBody getCaseExchangeCommentPage 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<UserCommentCaseExchangeDto> resultPage = userCommentCaseExchangeDao.getCaseExchangeCommentPage(
|
||||
// page,
|
||||
// request.getArticleId(),
|
||||
// request.getRootId()
|
||||
// );
|
||||
//
|
||||
// // 获取文章数据
|
||||
// CaseCaseExchangeModel article = caseExchangeDao.selectById(request.getArticleId());
|
||||
// if (article == null) {
|
||||
// return Response.error();
|
||||
// }
|
||||
//
|
||||
// if (article.getArticleStatus() != 1){
|
||||
// return Response.error();
|
||||
// }
|
||||
//
|
||||
// // 获取文章作者数据
|
||||
// LambdaQueryWrapper<CaseCaseExchangeAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// authorQueryWrapper.eq(CaseCaseExchangeAuthorModel::getArticleId, request.getArticleId());
|
||||
// List<CaseCaseExchangeAuthorModel> caseExchangeAuthors = caseExchangeAuthorDao.selectList(authorQueryWrapper);
|
||||
// for (CaseCaseExchangeAuthorModel author : caseExchangeAuthors) {
|
||||
// // 查询医生
|
||||
// CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
|
||||
// if (caseClinicalDoctor == null) {
|
||||
// return Response.error();
|
||||
// }
|
||||
//
|
||||
// // 处理是否本人评论
|
||||
// for (UserCommentCaseExchangeDto dto : resultPage.getRecords()) {
|
||||
// if (Objects.equals(dto.getUserIden(), caseClinicalDoctor.getDoctorIden())){
|
||||
// dto.setIsAuthor(1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 处理返回值
|
||||
// for (UserCommentCaseExchangeDto dto : resultPage.getRecords()) {
|
||||
// // 去除用户唯一标识
|
||||
// dto.setUserIden(null);
|
||||
//
|
||||
// // 获取次级评论
|
||||
// if (request.getIsHaveSubComment() == 1){
|
||||
// if (dto.getRootId() == null){
|
||||
// List<UserCommentCaseExchangeDto> subComments = userCommentCaseExchangeDao.getCaseExchangeCommentList(
|
||||
// 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);
|
||||
// }
|
||||
/**
|
||||
* 病例交流-评论-列表
|
||||
*/
|
||||
@PostMapping("/exchange/comment/page")
|
||||
public Response<Map<String, Object>> getCaseExchangeCommentPage(
|
||||
@Validated()
|
||||
@RequestBody getCaseExchangeCommentPage 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<UserCommentCaseExchangeDto> resultPage = userCommentExchangeDao.getCaseExchangeCommentPage(
|
||||
page,
|
||||
request.getExchangeId(),
|
||||
request.getRootId()
|
||||
);
|
||||
|
||||
// 处理是否本人评论
|
||||
for (UserCommentCaseExchangeDto dto : resultPage.getRecords()) {
|
||||
if (Objects.equals(dto.getUserId(), userId)){
|
||||
dto.setIsAuthor(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
for (UserCommentCaseExchangeDto dto : resultPage.getRecords()) {
|
||||
// 去除用户唯一标识
|
||||
dto.setUserIden(null);
|
||||
|
||||
// 获取次级评论
|
||||
if (request.getIsHaveSubComment() == 1){
|
||||
if (dto.getRootId() == null){
|
||||
List<UserCommentCaseExchangeDto> subComments = userCommentExchangeDao.getCaseExchangeCommentList(
|
||||
dto.getExchangeId(),
|
||||
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,14 +1,17 @@
|
||||
package com.example.caseData.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.caseData.common.Response;
|
||||
import com.example.caseData.dao.BasicHospitalDao;
|
||||
import com.example.caseData.dao.CaseClinicalDoctorDao;
|
||||
import com.example.caseData.dao.UserDao;
|
||||
import com.example.caseData.dto.user.UserDto;
|
||||
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
|
||||
import com.example.caseData.dto.user.UserDto;
|
||||
import com.example.caseData.model.BasicHospitalModel;
|
||||
import com.example.caseData.model.CaseClinicalDoctorModel;
|
||||
import com.example.caseData.model.UserModel;
|
||||
import com.example.caseData.request.UserRequest;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -35,6 +38,9 @@ public class UserController extends BaseController {
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Resource
|
||||
private CaseClinicalDoctorDao caseClinicalDoctorDao;
|
||||
|
||||
// // 查询所有用户
|
||||
// @GetMapping("/users")
|
||||
// public Response<Map<String, Object>> getUserPage(@Validated({UserRequest.Page.class}) @ModelAttribute UserRequest request) {
|
||||
@ -79,6 +85,12 @@ public class UserController extends BaseController {
|
||||
}
|
||||
user.setBasicHospital(basicHospital);
|
||||
|
||||
|
||||
// 获取对应医生数据
|
||||
LambdaQueryWrapper<CaseClinicalDoctorModel> caseClinicalDoctorWrapper = new LambdaQueryWrapper<>();
|
||||
caseClinicalDoctorWrapper.eq(CaseClinicalDoctorModel::getDoctorIden, user.getUserIden());
|
||||
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectOne(caseClinicalDoctorWrapper);
|
||||
|
||||
// 处理返回值
|
||||
UserDto g = UserDto.GetDto(user);
|
||||
g.setUserIden("");
|
||||
@ -87,6 +99,10 @@ public class UserController extends BaseController {
|
||||
g.setUserMobile("");
|
||||
g.setMobileEncryption("");
|
||||
|
||||
if (caseClinicalDoctor != null) {
|
||||
g.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
|
||||
}
|
||||
|
||||
return Response.success(g);
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +32,6 @@ public interface StatsCaseExchangeUserDao extends BaseMapper<StatsCaseExchangeUs
|
||||
* @param numeral 减少的数值
|
||||
* @return 更新的行数
|
||||
*/
|
||||
@Update("UPDATE stats_case_exchange_user SET ${field} = ${field} - #{numeral} WHERE stats_id = #{statsId}")
|
||||
@Update("UPDATE stats_case_exchange_user SET ${field} = ${field} - #{numeral} WHERE user_id = #{userId}")
|
||||
int dec(@Param("userId") Long userId, @Param("field") String field, @Param("numeral") int numeral);
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ public interface UserCommentClinicalArticleDao extends BaseMapper<UserCommentCli
|
||||
);
|
||||
|
||||
/**
|
||||
* 临床病例库--评论-分页
|
||||
* 临床病例库--评论-列表
|
||||
*/
|
||||
List<UserCommentClinicalArticleDto> getClinicalArticleCommentList(
|
||||
@Param("articleId") String articleId,
|
||||
|
||||
@ -4,14 +4,35 @@ 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.UserCommentCaseExchangeDto;
|
||||
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserCommentExchangeDao extends BaseMapper<UserCommentExchangeModel> {
|
||||
|
||||
/**
|
||||
* 临床病例库--评论-分页
|
||||
* @param page 分页数据
|
||||
*/
|
||||
IPage<UserCommentCaseExchangeDto> getCaseExchangeCommentPage(
|
||||
Page<?> page,
|
||||
@Param("exchangeId") String exchangeId,
|
||||
@Param("rootId") String rootId
|
||||
);
|
||||
|
||||
/**
|
||||
* 临床病例库--评论-列表
|
||||
*/
|
||||
List<UserCommentCaseExchangeDto> getCaseExchangeCommentList(
|
||||
@Param("exchangeId") String exchangeId,
|
||||
@Param("rootId") String rootId,
|
||||
@Param("limit") int limit
|
||||
);
|
||||
}
|
||||
|
||||
@ -0,0 +1,123 @@
|
||||
package com.example.caseData.dto.userCommentCaseExchange;
|
||||
|
||||
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 UserCommentCaseExchangeDto {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@JsonProperty("comment_id")
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@JsonProperty("user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 病例交流id
|
||||
*/
|
||||
@JsonProperty("exchange_id")
|
||||
private String exchangeId;
|
||||
|
||||
/**
|
||||
* 父级id,一级评论为null
|
||||
*/
|
||||
@JsonProperty("parent_id")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 根评论id,一级评论时为null。其余为一级评论id
|
||||
*/
|
||||
@JsonProperty("root_id")
|
||||
private String rootId;
|
||||
|
||||
/**
|
||||
* 评论状态(0:禁用 1:正常)
|
||||
*/
|
||||
@JsonProperty("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否存在敏感词(0:否 1:是)
|
||||
*/
|
||||
@JsonProperty("is_sensitive")
|
||||
private Integer isSensitive;
|
||||
|
||||
/**
|
||||
* 是否置顶(0:否 1:是)
|
||||
*/
|
||||
@JsonProperty("is_top")
|
||||
private Integer isTop;
|
||||
|
||||
/**
|
||||
* 点赞数量
|
||||
*/
|
||||
@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("user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户唯一标识
|
||||
*/
|
||||
@JsonProperty("user_iden")
|
||||
private String userIden;
|
||||
|
||||
/**
|
||||
* 是否作者(0:否 1:是)
|
||||
*/
|
||||
@JsonProperty("is_author")
|
||||
private Integer isAuthor;
|
||||
|
||||
/**
|
||||
* 次级评论
|
||||
*/
|
||||
@JsonProperty("sub_comment")
|
||||
private List<UserCommentCaseExchangeDto> subComment;
|
||||
}
|
||||
@ -27,7 +27,7 @@ public class getCaseExchangeCommentPage {
|
||||
|
||||
// 是否需要子评论(0:否 1:是)
|
||||
@JsonProperty("is_have_sub_comment")
|
||||
private Integer isHaveSubComment;
|
||||
private Integer isHaveSubComment = 1;
|
||||
|
||||
// ✅ 校验分页参数
|
||||
public void validateForPage() {
|
||||
|
||||
39
src/main/resources/mapper/UserCommentExchangeMapper.xml
Normal file
39
src/main/resources/mapper/UserCommentExchangeMapper.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?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.UserCommentExchangeDao">
|
||||
<select id="getCaseExchangeCommentPage"
|
||||
resultType="com.example.caseData.dto.userCommentCaseExchange.UserCommentCaseExchangeDto">
|
||||
SELECT
|
||||
a.*,
|
||||
b.user_name,
|
||||
b.user_iden
|
||||
FROM user_comment_exchange 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="getCaseExchangeCommentList"
|
||||
resultType="com.example.caseData.dto.userCommentCaseExchange.UserCommentCaseExchangeDto">
|
||||
SELECT
|
||||
a.*,
|
||||
b.user_name,
|
||||
b.user_iden
|
||||
FROM user_comment_exchange 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