From 00a34fc36a7da51c9adf5cf73724a978fdc75fe6 Mon Sep 17 00:00:00 2001 From: Wtd <1658714322@qq.com> Date: Tue, 24 Oct 2023 10:57:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E7=9A=84=E7=82=B9=E8=B5=9E?= =?UTF-8?q?=E7=82=B9=E8=B8=A9=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../patient/circle/domain/Review.java | 8 ++ .../february/patient/circle/domain/User.java | 9 ++ .../domain/request/UserLoginRequest.java | 21 ++++ .../domain/response/DiseaseDetailName.java | 25 ++++ .../domain/response/UserLoginResponse.java | 21 ++++ .../circle/domain/response/UserResponse.java | 18 +++ .../circle/controller/AuthController.java | 51 +++++++++ .../circle/controller/PatientController.java | 106 ++++++++++++++++- .../patient/circle/mapper/AuthMapper.java | 16 +++ .../patient/circle/mapper/PatientMapper.java | 33 +++++- .../patient/circle/service/AuthService.java | 22 ++++ .../circle/service/PatientService.java | 27 ++++- .../circle/service/impl/AuthServiceImpl.java | 72 ++++++++++++ .../service/impl/PatientServiceImpl.java | 108 +++++++++++++++++- .../resources/mapper/circle/AuthMapper.xml | 10 ++ .../resources/mapper/circle/PatientMapper.xml | 49 +++++++- 16 files changed, 588 insertions(+), 8 deletions(-) create mode 100644 february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/request/UserLoginRequest.java create mode 100644 february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/DiseaseDetailName.java create mode 100644 february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/UserLoginResponse.java create mode 100644 february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/UserResponse.java create mode 100644 february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/controller/AuthController.java create mode 100644 february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/mapper/AuthMapper.java create mode 100644 february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/AuthService.java create mode 100644 february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/impl/AuthServiceImpl.java create mode 100644 february-patient/february-patient-circle/february-patient-circle-server/src/main/resources/mapper/circle/AuthMapper.xml diff --git a/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/Review.java b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/Review.java index f8226e9..dda46c7 100644 --- a/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/Review.java +++ b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/Review.java @@ -77,4 +77,12 @@ public class Review { * 是否采纳 */ private Integer isAdopted; + /** + * 点赞状态 + */ + private Integer approveState; + /** + * 点踩状态 + */ + private Integer disapproveState; } diff --git a/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/User.java b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/User.java index 5de5787..d96a4cf 100644 --- a/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/User.java +++ b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/User.java @@ -3,6 +3,7 @@ package com.february.patient.circle.domain; import io.swagger.models.auth.In; import lombok.Data; +import java.io.StringReader; import java.math.BigDecimal; /** @@ -21,6 +22,14 @@ public class User { * 用户名 */ private String userName; + /** + * 邮箱账号 + */ + private String userEmail; + /** + * 密码 + */ + private String password; // /** // * 用户邮箱 // */ diff --git a/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/request/UserLoginRequest.java b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/request/UserLoginRequest.java new file mode 100644 index 0000000..77d84a9 --- /dev/null +++ b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/request/UserLoginRequest.java @@ -0,0 +1,21 @@ +package com.february.patient.circle.domain.request; + +import lombok.Data; + +/** + * @program: february + * @description: + * @author: Mr.Wang + * @create: 2023-10-23 09:25 + **/ +@Data +public class UserLoginRequest { + /** + * 邮箱账号 + */ + private String userEmail; + /** + * 密码 + */ + private String password; +} diff --git a/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/DiseaseDetailName.java b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/DiseaseDetailName.java new file mode 100644 index 0000000..cbf7a95 --- /dev/null +++ b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/DiseaseDetailName.java @@ -0,0 +1,25 @@ +package com.february.patient.circle.domain.response; + +import lombok.Data; + +/** + * @program: february + * @description: 科室及症状 + * @author: Mr.Wang + * @create: 2023-10-22 15:56 + **/ +@Data +public class DiseaseDetailName { + /** + * 主键 + */ + private Integer diseaseId; + /** + * 科室名称 + */ + private String diseaseName; + /** + * 病症名称 + */ + private String diseaseDetailName; +} diff --git a/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/UserLoginResponse.java b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/UserLoginResponse.java new file mode 100644 index 0000000..d0ab0ae --- /dev/null +++ b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/UserLoginResponse.java @@ -0,0 +1,21 @@ +package com.february.patient.circle.domain.response; + +import lombok.Data; + +/** + * @program: february + * @description: + * @author: Mr.Wang + * @create: 2023-10-23 09:27 + **/ +@Data +public class UserLoginResponse { + /** + * token令牌 + */ + private String token; + /** + * 过期时间 + */ + private String expireTime; +} diff --git a/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/UserResponse.java b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/UserResponse.java new file mode 100644 index 0000000..acf43ab --- /dev/null +++ b/february-patient/february-patient-circle/february-patient-circle-common/src/main/java/com/february/patient/circle/domain/response/UserResponse.java @@ -0,0 +1,18 @@ +package com.february.patient.circle.domain.response; + +import com.february.patient.circle.domain.User; +import lombok.Data; + +/** + * @program: february + * @description: 用户详细信息 + * @author: Mr.Wang + * @create: 2023-10-22 16:17 + **/ +@Data +public class UserResponse extends User { + /** + * 角色名称 + */ + private String roleName; +} diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/controller/AuthController.java b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/controller/AuthController.java new file mode 100644 index 0000000..72a55e2 --- /dev/null +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/controller/AuthController.java @@ -0,0 +1,51 @@ +package com.february.patient.circle.controller; + +import com.february.patient.circle.domain.User; +import com.february.patient.circle.domain.request.UserLoginRequest; +import com.february.patient.circle.domain.response.UserLoginResponse; +import com.february.patient.circle.domain.response.UserResponse; +import com.february.patient.circle.result.Result; +import com.february.patient.circle.service.AuthService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @program: february + * @description: 登录控制层 + * @author: Mr.Wang + * @create: 2023-10-23 09:04 + **/ +@RestController +public class AuthController { + @Autowired + private AuthService authService; + + /** + * 根据邮箱账号查询用户信息 + * @param userEmail + * @return + */ + @PostMapping("/loginByUserEmail") + public Result loginByUserEmail(@RequestParam String userEmail){ + return authService.loginByUserEmail(userEmail); + } + + /** + * 登录操作 + * @param userLoginRequest + * @return + */ + @PostMapping("/login") + public Result login(@RequestBody UserLoginRequest userLoginRequest){ + return authService.login(userLoginRequest); + } + + /** + * 获取用户详细信息 + * @return + */ + @GetMapping("/info") + public Result Info(){ + return authService.Info(); + } +} diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/controller/PatientController.java b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/controller/PatientController.java index 06ae919..733cfec 100644 --- a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/controller/PatientController.java +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/controller/PatientController.java @@ -5,6 +5,9 @@ import com.february.patient.circle.domain.*; import com.february.patient.circle.domain.request.PatientCircleRequest; import com.february.patient.circle.domain.request.PatientRequest; import com.february.patient.circle.domain.request.ReviewPatientRequest; +import com.february.patient.circle.domain.response.DiseaseDetailName; +import com.february.patient.circle.domain.response.DiseaseName; +import com.february.patient.circle.domain.response.UserResponse; import com.february.patient.circle.result.Result; import com.february.patient.circle.service.PatientService; import io.swagger.models.auth.In; @@ -157,7 +160,108 @@ public class PatientController { * @return */ @GetMapping("/findDiseaseName") - public Result> findDiseaseName(){ + public Result> findDiseaseName(){ return patientService.findDiseaseName(); } + + /** + * 查询病症及对应科室 + * @param diseaseId + * @return + */ + @PostMapping("/findDisease") + public Result> findDiseaseDetailName(@RequestParam Integer diseaseId){ + return patientService.findDiseaseDetailName(diseaseId); + } + + /** + * 查询治疗经历 + * @param diseaseProcessId + * @return + */ + @PostMapping("/findDiseaseProcess") + public Result> findDiseaseProcess(@RequestParam Integer diseaseProcessId){ + return patientService.findDiseaseProcess(diseaseProcessId); + } + + /** + * 添加经历 + * @param diseaseProcess + * @return + */ + @PostMapping("/addDiseaseProcess") + public Result addDiseaseProcess(@RequestBody DiseaseProcess diseaseProcess){ + return patientService.addDiseaseProcess(diseaseProcess); + } + + /** + * 查询用户信息 + * @param userId + * @return + */ + @PostMapping("/findUser") + public Result findUser(@RequestParam Integer userId){ + return patientService.findUser(userId); + } + + /** + * 查看评论列表 + * @return + */ + @GetMapping("/reviewList") + public Result> reviewList(){ + return patientService.reviewList(); + } + + /** + * 被采纳的评论 + * @return + */ + @PostMapping("findAdoptReview") + public Result> findAdoptReview(){ + return patientService.findAdoptReview(); + } + /** + * 病友圈详情列表 + */ + @GetMapping("/patientCircleList") + public Result> patientCircleList(){ + return patientService.patientCircleList(); + } + /** + * 写评论 + */ + @PostMapping("/addReview") + public Result addReview(@RequestBody Review review){ + return patientService.addReview(review); + } + + /** + * 根据评论id查询评论信息 + * @param reviewId + * @return + */ + @PostMapping("/findByReviewId") + public Result findByReviewId(@RequestParam Integer reviewId){ + return patientService.findByReviewId(reviewId); + } + /** + * 评论点赞操作 + * @param reviewId + * @return + */ + @PostMapping("/upvote") + public Result upvote(@RequestParam Integer reviewId){ + return patientService.upvote(reviewId); + } + + /** + * 评论点踩操作 + * @param reviewId + * @return + */ + @PostMapping("/taunt") + public Result taunt(@RequestParam Integer reviewId){ + return patientService.taunt(reviewId); + } } diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/mapper/AuthMapper.java b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/mapper/AuthMapper.java new file mode 100644 index 0000000..882bac3 --- /dev/null +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/mapper/AuthMapper.java @@ -0,0 +1,16 @@ +package com.february.patient.circle.mapper; + +import com.february.patient.circle.domain.User; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * @program: february + * @description: + * @author: Mr.Wang + * @create: 2023-10-23 09:04 + **/ +@Mapper +public interface AuthMapper { + User loginByUserEmail(@Param("userEmail") String userEmail); +} diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/mapper/PatientMapper.java b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/mapper/PatientMapper.java index b0c2d18..e5205e5 100644 --- a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/mapper/PatientMapper.java +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/mapper/PatientMapper.java @@ -5,6 +5,9 @@ import com.february.patient.circle.domain.*; import com.february.patient.circle.domain.request.PatientCircleRequest; import com.february.patient.circle.domain.request.PatientRequest; import com.february.patient.circle.domain.request.ReviewPatientRequest; +import com.february.patient.circle.domain.response.DiseaseDetailName; +import com.february.patient.circle.domain.response.DiseaseName; +import com.february.patient.circle.domain.response.UserResponse; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -18,7 +21,35 @@ import java.util.List; **/ @Mapper public interface PatientMapper { - List findDiseaseName(); + List findDiseaseName(); + + List findDiseaseDetailName(@Param("diseaseId") Integer diseaseId); + + List findDiseaseProcess(@Param("diseaseProcessId") Integer diseaseProcessId); + + UserResponse findUser(@Param("userId") Integer userId); + + List reviewList(); + + List findAdoptReview(); + + Integer addDiseaseProcess(DiseaseProcess diseaseProcess); + + List patientCircleList(); + + Integer addReview(Review review); + + Review findByReviewId(@Param("reviewId") Integer reviewId); + + Integer upvote(@Param("reviewId") Integer reviewId); + + void disUpvote(@Param("reviewId") Integer reviewId); + + Integer taunt(@Param("reviewId") Integer reviewId); + + void disTaunt(@Param("reviewId") Integer reviewId); + + // List patientCircleList(@Param("diseaseId") Integer diseaseId); // // diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/AuthService.java b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/AuthService.java new file mode 100644 index 0000000..6f5c410 --- /dev/null +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/AuthService.java @@ -0,0 +1,22 @@ +package com.february.patient.circle.service; + +import com.february.patient.circle.domain.User; +import com.february.patient.circle.domain.request.UserLoginRequest; +import com.february.patient.circle.domain.response.UserLoginResponse; +import com.february.patient.circle.result.Result; +import org.springframework.stereotype.Component; + +/** + * @program: february + * @description: + * @author: Mr.Wang + * @create: 2023-10-23 09:05 + **/ +@Component +public interface AuthService { + Result loginByUserEmail(String userEmail); + + Result login(UserLoginRequest userLoginRequest); + + Result Info(); +} diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/PatientService.java b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/PatientService.java index 2ab0c61..3bbd00c 100644 --- a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/PatientService.java +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/PatientService.java @@ -5,6 +5,9 @@ import com.february.patient.circle.domain.*; import com.february.patient.circle.domain.request.PatientCircleRequest; import com.february.patient.circle.domain.request.PatientRequest; import com.february.patient.circle.domain.request.ReviewPatientRequest; +import com.february.patient.circle.domain.response.DiseaseDetailName; +import com.february.patient.circle.domain.response.DiseaseName; +import com.february.patient.circle.domain.response.UserResponse; import com.february.patient.circle.result.Result; import io.swagger.models.auth.In; import org.springframework.stereotype.Component; @@ -20,7 +23,29 @@ import java.util.List; **/ @Component public interface PatientService { - Result> findDiseaseName(); + Result> findDiseaseName(); + + Result> findDiseaseDetailName(Integer diseaseId); + + Result> findDiseaseProcess(Integer diseaseProcessId); + + Result findUser(Integer userId); + + Result> reviewList(); + + Result> findAdoptReview(); + + Result addDiseaseProcess(DiseaseProcess diseaseProcess); + + Result> patientCircleList(); + + Result addReview(Review review); + + Result upvote(Integer reviewId); + + Result findByReviewId(Integer reviewId); + + Result taunt(Integer reviewId); // Result> patientCircleList(Integer diseaseId); // // Result> patientList(String patientNickname); diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/impl/AuthServiceImpl.java b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/impl/AuthServiceImpl.java new file mode 100644 index 0000000..6066a15 --- /dev/null +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/impl/AuthServiceImpl.java @@ -0,0 +1,72 @@ +package com.february.patient.circle.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.february.common.core.utils.JwtUtils; +import com.february.common.core.utils.StringUtils; +import com.february.common.core.utils.uuid.UUID; +import com.february.patient.circle.constants.JwtConstants; +import com.february.patient.circle.constants.TokenConstants; +import com.february.patient.circle.domain.User; +import com.february.patient.circle.domain.request.UserLoginRequest; +import com.february.patient.circle.domain.response.UserLoginResponse; +import com.february.patient.circle.mapper.AuthMapper; +import com.february.patient.circle.result.Result; +import com.february.patient.circle.service.AuthService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.concurrent.TimeUnit; + +/** + * @program: february + * @description: + * @author: Mr.Wang + * @create: 2023-10-23 09:05 + **/ +@Service +public class AuthServiceImpl implements AuthService { + @Autowired + private AuthMapper authMapper; + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private HttpServletRequest request; + @Override + public Result loginByUserEmail(String userEmail) { + User user=authMapper.loginByUserEmail(userEmail); + return Result.success(user); + } + + @Override + public Result login(UserLoginRequest userLoginRequest) { + if(StringUtils.isAnyBlank(userLoginRequest.getUserEmail(),userLoginRequest.getPassword())){ + return Result.error("请输入邮箱账号和密码"); + } + User user = authMapper.loginByUserEmail(userLoginRequest.getUserEmail()); + if(null==user){ + return Result.error("该用户不存在"); + } + String userKey = UUID.randomUUID().toString().replaceAll("-", ""); + HashMap map = new HashMap<>(); + map.put(JwtConstants.USER_KEY,userKey); + map.put(JwtConstants.DETAILS_USER_ID,user.getUserId()); + String token = JwtUtils.createToken(map); + redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+userKey, JSONObject.toJSONString(user),15, TimeUnit.MINUTES); + UserLoginResponse userLoginResponse = new UserLoginResponse(); + userLoginResponse.setExpireTime("15MIN"); + userLoginResponse.setToken(token); + return Result.success(userLoginResponse); + } + + @Override + public Result Info() { + String token = request.getHeader(TokenConstants.TOKEN); + String userKey = JwtUtils.getUserKey(token); + String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY+userKey); + User user = JSONObject.parseObject(s, User.class); + return Result.success(user); + } +} diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/impl/PatientServiceImpl.java b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/impl/PatientServiceImpl.java index 0848ba3..ef0c6a0 100644 --- a/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/impl/PatientServiceImpl.java +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/java/com/february/patient/circle/service/impl/PatientServiceImpl.java @@ -1,5 +1,12 @@ package com.february.patient.circle.service.impl; +import com.alibaba.fastjson.JSONObject; +import com.february.common.core.utils.JwtUtils; +import com.february.patient.circle.constants.TokenConstants; +import com.february.patient.circle.domain.response.DiseaseDetailName; +import com.february.patient.circle.domain.response.DiseaseName; +import com.february.patient.circle.domain.response.UserResponse; +import com.february.patient.circle.mapper.AuthMapper; import org.apache.poi.util.IOUtils; import com.february.patient.circle.constants.JwtConstants; import com.february.patient.circle.domain.*; @@ -14,9 +21,11 @@ import com.february.patient.circle.util.OssUtil; import io.swagger.models.auth.In; import lombok.Cleanup; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import java.util.List; /** @@ -30,15 +39,110 @@ public class PatientServiceImpl implements PatientService { @Autowired private PatientMapper patientMapper; @Autowired + private HttpServletRequest request; + @Autowired + private RedisTemplate redisTemplate; + @Autowired private FastUtil fastUtil; @Autowired private OssUtil ossUtil; @Override - public Result> findDiseaseName() { - List list=patientMapper.findDiseaseName(); + public Result> findDiseaseName() { + List list=patientMapper.findDiseaseName(); return Result.success(list); } + + @Override + public Result> findDiseaseDetailName(Integer diseaseId) { + List list=patientMapper.findDiseaseDetailName(diseaseId); + return Result.success(list); + } + + @Override + public Result> findDiseaseProcess(Integer diseaseProcessId) { + List list=patientMapper.findDiseaseProcess(diseaseProcessId); + return Result.success(list); + } + + @Override + public Result findUser(Integer userId) { + UserResponse user=patientMapper.findUser(userId); + return Result.success(user); + } + + @Override + public Result> reviewList() { + List list=patientMapper.reviewList(); + return Result.success(list); + } + + @Override + public Result> findAdoptReview() { + List list=patientMapper.findAdoptReview(); + return Result.success(list); + } + + @Override + public Result addDiseaseProcess(DiseaseProcess diseaseProcess) { + Integer i=patientMapper.addDiseaseProcess(diseaseProcess); + if(i>0){ + return Result.success("添加成功"); + } + return Result.success("添加失败"); + } + + @Override + public Result> patientCircleList() { + List list=patientMapper.patientCircleList(); + return Result.success(list); + } + + @Override + public Result addReview(Review review) { + String token = request.getHeader(TokenConstants.TOKEN); + String userKey = JwtUtils.getUserKey(token); + String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey); + User user = JSONObject.parseObject(s, User.class); + Integer userId = user.getUserId(); + review.setUserId(userId); + Integer i=patientMapper.addReview(review); + if(i>0){ + return Result.success("发表评论成功"); + } + return Result.error("评论发表失败"); + } + + @Override + public Result upvote(Integer reviewId) { + Review review = patientMapper.findByReviewId(reviewId); + if(review.getApproveState()==0){ + Integer i=patientMapper.upvote(reviewId); + if(i>0){ + return Result.success("点赞成功"); + } + } + patientMapper.disUpvote(reviewId); + return Result.success("取消点赞操作成功"); + } + @Override + public Result findByReviewId(Integer reviewId) { + Review review=patientMapper.findByReviewId(reviewId); + return Result.success(review); + } + + @Override + public Result taunt(Integer reviewId) { + Review review = patientMapper.findByReviewId(reviewId); + if(review.getDisapproveState()==0){ + Integer i=patientMapper.taunt(reviewId); + if(i>0){ + return Result.success("点踩成功"); + } + } + patientMapper.disTaunt(reviewId); + return Result.success("取消点踩"); + } // @Override // public Result> patientCircleList(Integer diseaseId) { // String diseaseName = findDiseaseName(diseaseId); diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/resources/mapper/circle/AuthMapper.xml b/february-patient/february-patient-circle/february-patient-circle-server/src/main/resources/mapper/circle/AuthMapper.xml new file mode 100644 index 0000000..ce5f474 --- /dev/null +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/resources/mapper/circle/AuthMapper.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/february-patient/february-patient-circle/february-patient-circle-server/src/main/resources/mapper/circle/PatientMapper.xml b/february-patient/february-patient-circle/february-patient-circle-server/src/main/resources/mapper/circle/PatientMapper.xml index f1065b4..6cc2fdf 100644 --- a/february-patient/february-patient-circle/february-patient-circle-server/src/main/resources/mapper/circle/PatientMapper.xml +++ b/february-patient/february-patient-circle/february-patient-circle-server/src/main/resources/mapper/circle/PatientMapper.xml @@ -1,7 +1,28 @@ - + + INSERT INTO `patient-circle`.`tb_disease_process` ( `hospital_name`, `start_time`, `end_time`, `disease_process`) + VALUES ( #{hospitalName}, #{startTime}, #{endTime}, #{diseaseProcess}) + + + INSERT INTO `patient-circle`.`tb_review` ( `avatar`,`user_id`,`review_detail`, `review_time`, `approve_num`, `disapprove_num`, `is_adopted`,`approve_state`,`disapprove_state`) + VALUES ( #{avatar},#{userId},#{reviewDetail}, now(), 0, 0, 0,0,0) + + + UPDATE `patient-circle`.`tb_review` SET `approve_num` = approve_num+1,`approve_state`=1 WHERE `review_id` = #{reviewId} + + + UPDATE `patient-circle`.`tb_review` SET `approve_num` = approve_num-1,`approve_state`=0 WHERE `review_id` = #{reviewId} + + + UPDATE `patient-circle`.`tb_review` SET `disapprove_num` = disapprove_num+1,`disapprove_state`=1 WHERE `review_id` = #{reviewId} + + + UPDATE `patient-circle`.`tb_review` SET `disapprove_num` = disapprove_num-1,`disapprove_state`=0 WHERE `review_id` = #{reviewId} + + + @@ -38,8 +59,30 @@ - + select disease_id,disease_name from tb_disease where disease_parent_id =0 + + + + + + + +