点赞点踩具体操作

master
王堂东 2023-10-25 21:28:22 +08:00
parent 2e1b7d996e
commit d6a5280880
17 changed files with 275 additions and 28 deletions

View File

@ -14,10 +14,10 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
@ -33,7 +33,7 @@ spring:
datasource: datasource:
ds1: ds1:
nacos: nacos:
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
dataId: sentinel-february-gateway dataId: sentinel-february-gateway
groupId: DEFAULT_GROUP groupId: DEFAULT_GROUP
data-type: json data-type: json

View File

@ -14,10 +14,10 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
@ -26,6 +26,6 @@ spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://10.100.1.4:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://47.113.231.62:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: wuzu123... password: wuzu123...

View File

@ -14,10 +14,10 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -69,5 +69,10 @@
<groupId>com.february</groupId> <groupId>com.february</groupId>
<artifactId>february-common-swagger</artifactId> <artifactId>february-common-swagger</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>cloudauth20190307</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -45,6 +45,10 @@ public class PatientCircle {
* id * id
*/ */
private Integer patientCircleId; private Integer patientCircleId;
/**
*
*/
private String patientCircleTitle;
/** /**
* ID * ID
*/ */
@ -77,4 +81,8 @@ public class PatientCircle {
* id * id
*/ */
private Integer adoptedId; private Integer adoptedId;
/**
*
*/
private Integer collectState;
} }

View File

@ -0,0 +1,44 @@
package com.february.patient.circle.domain;
import io.swagger.models.auth.In;
import lombok.Data;
import java.util.Date;
/**
* @program: february
* @description:
* @author: Mr.Wang
* @create: 2023-10-25 13:43
**/
@Data
public class ReviewLog {
/**
* id
*/
private Integer logId;
/**
* id
*/
private Integer reviewId;
/**
* id
*/
private Integer userId;
/**
* id
*/
private Integer typeId;
/**
*
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
}

View File

@ -5,11 +5,16 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
*
* @program: patient * @program: patient
* @description: * @description:
* @author: Mr.Wang * @author: Mr.Wang
* @create: 2023-10-18 21:50 * @create: 2023-10-18 21:50
**/ **/
/**
*
*/
@Data @Data
public class PatientCircleRequest { public class PatientCircleRequest {
/** /**

View File

@ -0,0 +1,32 @@
package com.february.patient.circle.domain.response;
import com.february.patient.circle.domain.PatientCircle;
import lombok.Data;
import java.util.Date;
/**
* @program: february
* @description:
* @author: Mr.Wang
* @create: 2023-10-24 16:59
**/
@Data
public class PatientCircleResponse extends PatientCircle {
/**
*
*/
private String hospitalName;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
/**
*
*/
private String diseaseProcess;
}

View File

@ -17,12 +17,10 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
/** /**
* @program: patient *
* @description: */
* @author: Mr.Wang
* @create: 2023-10-18 11:13
**/
@RestController @RestController
public class PatientController { public class PatientController {
@Autowired @Autowired
@ -224,9 +222,9 @@ public class PatientController {
/** /**
* *
*/ */
@GetMapping("/patientCircleList") @PostMapping("/patientCircleList")
public Result<List<PatientCircle>> patientCircleList(){ public Result<List<PatientCircle>> patientCircleList(@RequestBody PatientCircleRequest patientCircleRequest){
return patientService.patientCircleList(); return patientService.patientCircleList(patientCircleRequest);
} }
/** /**
* *
@ -264,4 +262,42 @@ public class PatientController {
public Result taunt(@RequestParam Integer reviewId){ public Result taunt(@RequestParam Integer reviewId){
return patientService.taunt(reviewId); return patientService.taunt(reviewId);
} }
/**
*
* @return
*/
@PostMapping("/toCollect")
public Result toCollect(@RequestParam Integer patientCircleId){
return patientService.toCollect(patientCircleId);
}
/**
* id
* @param patientCircleId
* @return
*/
@PostMapping("/findByPatientCircleId")
public Result<PatientCircle> findByPatientCircleId(@RequestParam Integer patientCircleId){
return patientService.findByPatientCircleId(patientCircleId);
}
/**
*
* @param file
* @return
*/
@PostMapping("/upload")
public Result upload(@RequestParam("file")MultipartFile file){
return patientService.upload(file);
}
/**
*
* @return
*/
@PostMapping("/addReviewLog")
public Result addReviewLog(@RequestBody ReviewLog reviewLog){
return patientService.addReviewLog(reviewLog);
}
} }

View File

@ -35,7 +35,7 @@ public interface PatientMapper {
Integer addDiseaseProcess(DiseaseProcess diseaseProcess); Integer addDiseaseProcess(DiseaseProcess diseaseProcess);
List<PatientCircle> patientCircleList(); List<PatientCircle> patientCircleList(PatientCircleRequest patientCircleRequest);
Integer addReview(Review review); Integer addReview(Review review);
@ -51,6 +51,14 @@ public interface PatientMapper {
Integer findReviewNum(@Param("patientCircleId") Integer patientCircleId); Integer findReviewNum(@Param("patientCircleId") Integer patientCircleId);
Integer toCollect(@Param("patientCircleId") Integer patientCircleId);
PatientCircle findByPatientCircleId(@Param("patientCircleId") Integer patientCircleId);
void disToCollect(@Param("patientCircleId") Integer patientCircleId);
Integer addReviewLog(ReviewLog reviewLog);
// List<PatientCircle> patientCircleList(@Param("diseaseId") Integer diseaseId); // List<PatientCircle> patientCircleList(@Param("diseaseId") Integer diseaseId);
// //

View File

@ -37,7 +37,7 @@ public interface PatientService {
Result addDiseaseProcess(DiseaseProcess diseaseProcess); Result addDiseaseProcess(DiseaseProcess diseaseProcess);
Result<List<PatientCircle>> patientCircleList(); Result<List<PatientCircle>> patientCircleList(PatientCircleRequest patientCircleRequest);
Result addReview(Review review); Result addReview(Review review);
@ -46,6 +46,16 @@ public interface PatientService {
Result<Review> findByReviewId(Integer reviewId); Result<Review> findByReviewId(Integer reviewId);
Result taunt(Integer reviewId); Result taunt(Integer reviewId);
Result toCollect(Integer patientCircleId);
Result<PatientCircle> findByPatientCircleId(Integer patientCircleId);
Result upload(MultipartFile file);
Result addReviewLog(ReviewLog reviewLog);
// Result<List<PatientCircle>> patientCircleList(Integer diseaseId); // Result<List<PatientCircle>> patientCircleList(Integer diseaseId);
// //
// Result<List<PatientRequest>> patientList(String patientNickname); // Result<List<PatientRequest>> patientList(String patientNickname);

View File

@ -26,6 +26,8 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -93,8 +95,8 @@ public class PatientServiceImpl implements PatientService {
} }
@Override @Override
public Result<List<PatientCircle>> patientCircleList() { public Result<List<PatientCircle>> patientCircleList(PatientCircleRequest patientCircleRequest) {
List<PatientCircle> list=patientMapper.patientCircleList(); List<PatientCircle> list=patientMapper.patientCircleList(patientCircleRequest);
list.forEach(l->{ list.forEach(l->{
Integer patientCircleId = l.getPatientCircleId(); Integer patientCircleId = l.getPatientCircleId();
Integer i=patientMapper.findReviewNum(patientCircleId); Integer i=patientMapper.findReviewNum(patientCircleId);
@ -121,12 +123,26 @@ public class PatientServiceImpl implements PatientService {
@Override @Override
public Result upvote(Integer reviewId) { public Result upvote(Integer reviewId) {
Review review = patientMapper.findByReviewId(reviewId); Review review = patientMapper.findByReviewId(reviewId);
User info = getInfo();
ReviewLog reviewLog = new ReviewLog();
if(review.getApproveState()==0){ if(review.getApproveState()==0){
Integer i=patientMapper.upvote(reviewId); Integer i=patientMapper.upvote(reviewId);
if(i>0){ if(i>0){
reviewLog.setReviewId(reviewId);
reviewLog.setUserId(info.getUserId());
reviewLog.setTypeId(1);
reviewLog.setStatus(1);
reviewLog.setCreateTime(new Date());
addReviewLog(reviewLog);
return Result.success("点赞成功"); return Result.success("点赞成功");
} }
} }
reviewLog.setReviewId(reviewId);
reviewLog.setUserId(info.getUserId());
reviewLog.setTypeId(1);
reviewLog.setStatus(2);
reviewLog.setUpdateTime(new Date());
addReviewLog(reviewLog);
patientMapper.disUpvote(reviewId); patientMapper.disUpvote(reviewId);
return Result.success("取消点赞操作成功"); return Result.success("取消点赞操作成功");
} }
@ -139,15 +155,79 @@ public class PatientServiceImpl implements PatientService {
@Override @Override
public Result taunt(Integer reviewId) { public Result taunt(Integer reviewId) {
Review review = patientMapper.findByReviewId(reviewId); Review review = patientMapper.findByReviewId(reviewId);
User info = getInfo();
ReviewLog reviewLog = new ReviewLog();
if(review.getDisapproveState()==0){ if(review.getDisapproveState()==0){
Integer i=patientMapper.taunt(reviewId); Integer i=patientMapper.taunt(reviewId);
if(i>0){ if(i>0){
reviewLog.setReviewId(reviewId);
reviewLog.setUserId(info.getUserId());
reviewLog.setTypeId(2);
reviewLog.setStatus(1);
reviewLog.setCreateTime(new Date());
addReviewLog(reviewLog);
return Result.success("点踩成功"); return Result.success("点踩成功");
} }
} }
reviewLog.setReviewId(reviewId);
reviewLog.setUserId(info.getUserId());
reviewLog.setTypeId(2);
reviewLog.setStatus(2);
reviewLog.setUpdateTime(new Date());
addReviewLog(reviewLog);
patientMapper.disTaunt(reviewId); patientMapper.disTaunt(reviewId);
return Result.success("取消点踩"); return Result.success("取消点踩");
} }
@Override
public Result toCollect(Integer patientCircleId) {
PatientCircle patientCircle = patientMapper.findByPatientCircleId(patientCircleId);
if(patientCircle.getCollectState()==0) {
Integer i = patientMapper.toCollect(patientCircleId);
if (i > 0) {
return Result.success("收藏成功");
}
}
patientMapper.disToCollect(patientCircleId);
return Result.error("取消收藏");
}
@Override
public Result<PatientCircle> findByPatientCircleId(Integer patientCircleId) {
PatientCircle patientCircle=patientMapper.findByPatientCircleId(patientCircleId);
return Result.success(patientCircle);
}
@Override
public Result upload(MultipartFile file) {
try {
String upload = fastUtil.upload(file);
InputStream inputStream = file.getInputStream();
IOUtils.closeQuietly(inputStream);
return Result.success("http://47.120.41.50:8888/"+upload,"上传成功");
} catch (Exception e) {
e.printStackTrace();
}
return Result.error("上传失败");
}
@Override
public Result addReviewLog(ReviewLog reviewLog) {
Integer i=patientMapper.addReviewLog(reviewLog);
if(i>0){
return Result.success("信息记录成功");
}
return Result.error("信息记录失败");
}
public User getInfo(){
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 user;
}
// @Override // @Override
// public Result<List<PatientCircle>> patientCircleList(Integer diseaseId) { // public Result<List<PatientCircle>> patientCircleList(Integer diseaseId) {
// String diseaseName = findDiseaseName(diseaseId); // String diseaseName = findDiseaseName(diseaseId);

View File

@ -9,6 +9,10 @@
INSERT INTO `patient-circle`.`tb_review` ( `avatar`,`user_id`,`review_detail`, `review_time`, `approve_num`, `disapprove_num`, `is_adopted`,`approve_state`,`disapprove_state`) 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) VALUES ( #{avatar},#{userId},#{reviewDetail}, now(), 0, 0, 0,0,0)
</insert> </insert>
<insert id="addReviewLog">
INSERT INTO `patient-circle`.`tb_review_log` ( `review_id`, `user_id`, `type_id`, `status`, `create_time`, `update_time`)
VALUES ( #{reviewId}, #{userId}, #{typeId}, #{status}, #{createTime}, #{updateTime})
</insert>
<update id="upvote"> <update id="upvote">
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`=1 WHERE `review_id` = #{reviewId}
</update> </update>
@ -21,6 +25,12 @@
<update id="disTaunt"> <update id="disTaunt">
UPDATE `patient-circle`.`tb_review` SET `disapprove_num` = disapprove_num-1,`disapprove_state`=0 WHERE `review_id` = #{reviewId} UPDATE `patient-circle`.`tb_review` SET `disapprove_num` = disapprove_num-1,`disapprove_state`=0 WHERE `review_id` = #{reviewId}
</update> </update>
<update id="toCollect">
UPDATE `patient-circle`.`tb_patient_circle` SET `collect_num` = collect_num+1 ,collect_state=1 WHERE `patient_circle_id` = #{patientCircleId}
</update>
<update id="disToCollect">
UPDATE `patient-circle`.`tb_patient_circle` SET `collect_num` = collect_num-1,collect_state=0 WHERE `patient_circle_id` = #{patientCircleId}
</update>
<!-- <insert id="addPatientCircle">--> <!-- <insert id="addPatientCircle">-->
<!-- INSERT INTO `patient`.`t_patient_circle_log` (`patient_circle_title`, `disease_id`, `drug_id`, `patient_circle_detail`, `hospital`, `patient_circle_start_time`, `patient_circle_end_time`, `patient_circle_process`, `patient_circle_picture`) VALUES ( #{patientCircleTitle}, #{diseaseId}, #{drugId}, #{patientCircleDetail}, #{hospital}, #{patientCircleStartTime}, #{patientCircleEndTime}, #{patientCircleProcess}, #{patientCirclePicture})--> <!-- INSERT INTO `patient`.`t_patient_circle_log` (`patient_circle_title`, `disease_id`, `drug_id`, `patient_circle_detail`, `hospital`, `patient_circle_start_time`, `patient_circle_end_time`, `patient_circle_process`, `patient_circle_picture`) VALUES ( #{patientCircleTitle}, #{diseaseId}, #{drugId}, #{patientCircleDetail}, #{hospital}, #{patientCircleStartTime}, #{patientCircleEndTime}, #{patientCircleProcess}, #{patientCirclePicture})-->
@ -80,6 +90,11 @@
</select> </select>
<select id="patientCircleList" resultType="com.february.patient.circle.domain.PatientCircle"> <select id="patientCircleList" resultType="com.february.patient.circle.domain.PatientCircle">
select * from tb_patient_circle select * from tb_patient_circle
<where>
<if test="patientCircleTitle!=null and patientCircleTitle!=''">
and patient_circle_title like concat ('%',#{patientCircleTitle},'%')
</if>
</where>
</select> </select>
<select id="findByReviewId" resultType="com.february.patient.circle.domain.Review"> <select id="findByReviewId" resultType="com.february.patient.circle.domain.Review">
select * from tb_review where review_id=#{reviewId} select * from tb_review where review_id=#{reviewId}
@ -87,5 +102,9 @@
<select id="findReviewNum" resultType="java.lang.Integer"> <select id="findReviewNum" resultType="java.lang.Integer">
SELECT COUNT(*) from tb_review WHERE patient_circle_id=#{patientCircleId} SELECT COUNT(*) from tb_review WHERE patient_circle_id=#{patientCircleId}
</select> </select>
<select id="findByPatientCircleId" resultType="com.february.patient.circle.domain.PatientCircle">
select * from tb_patient_circle where patient_circle_id=#{patientCircleId}
</select>
</mapper> </mapper>

View File

@ -14,10 +14,10 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 10.100.1.2:8848 server-addr: 47.120.41.50:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置