提交 c48b6c3e 编写于 作者: minghao.wu's avatar minghao.wu

Merge branch 'dev' into dev_phase2

# Conflicts:
#	server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/AnalysisController.java
package com.pica.cloud.online.exam.analysis.server.controller; package com.pica.cloud.online.exam.analysis.server.controller;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode; import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.redis.RedisClient; import com.pica.cloud.foundation.redis.RedisClient;
import com.pica.cloud.foundation.utils.entity.PICAUser; import com.pica.cloud.foundation.utils.entity.PICAUser;
import com.pica.cloud.online.exam.analysis.common.CommonUtils; import com.pica.cloud.online.exam.analysis.common.CommonUtils;
import com.pica.cloud.online.exam.analysis.common.constants.CommonConstants; import com.pica.cloud.online.exam.analysis.common.constants.CommonConstants;
import com.pica.cloud.online.exam.analysis.common.dto.*; import com.pica.cloud.online.exam.analysis.common.dto.*;
import com.pica.cloud.online.exam.analysis.common.util.ReturnUtil; import com.pica.cloud.online.exam.analysis.common.util.ReturnUtil;
import com.pica.cloud.online.exam.analysis.server.client.IConfigServiceClient; import com.pica.cloud.online.exam.analysis.server.client.IConfigServiceClient;
import com.pica.cloud.online.exam.analysis.server.configuration.PropertiesConfiguration; import com.pica.cloud.online.exam.analysis.server.configuration.PropertiesConfiguration;
import com.pica.cloud.online.exam.analysis.server.entity.*; import com.pica.cloud.online.exam.analysis.server.entity.*;
import com.pica.cloud.online.exam.analysis.server.service.CHCAnalysisService; import com.pica.cloud.online.exam.analysis.server.service.CHCAnalysisService;
import com.pica.cloud.online.exam.analysis.server.service.DoctorService; import com.pica.cloud.online.exam.analysis.server.service.DoctorService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
/** /**
* @author wuminghao * @author wuminghao
* @date 2018/8/16 18:10 * @date 2018/8/16 18:10
*/ */
@RestController @RestController
@RequestMapping("/") @RequestMapping("/")
@Api(value = "题目分析接口", description = "查看活动及详情,用户点赞、医生回复") @Api(value = "题目分析接口", description = "查看活动及详情,用户点赞、医生回复")
public class AnalysisController { public class AnalysisController {
@Autowired @Autowired
private RedisClient redisClient; private RedisClient redisClient;
@Autowired @Autowired
private LoadBalancerClient slb; private LoadBalancerClient slb;
@Autowired @Autowired
private IConfigServiceClient client; private IConfigServiceClient client;
@Autowired @Autowired
private CHCAnalysisService analysisService; private CHCAnalysisService analysisService;
@Autowired @Autowired
private DoctorService doctorService; private DoctorService doctorService;
@ApiOperation(value = "获取活动详情", response = PicaResponse.class) @ApiOperation(value = "获取活动详情", response = PicaResponse.class)
@RequestMapping(value = "/activityDetail", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @RequestMapping(value = "/activityDetail", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public PicaResponse<CHCAnalysisDto> getActivityDetail(@RequestParam(required = false) Integer id) { public PicaResponse<CHCAnalysisDto> getActivityDetail(@RequestParam(required = false) Integer id) {
PicaResponse.Builder<CHCAnalysisDto> builder = new PicaResponse.Builder<>(); PicaResponse.Builder<CHCAnalysisDto> builder = new PicaResponse.Builder<>();
/** /**
* 如果不传活动id进来,活动id就用1 * 如果不传活动id进来,活动id就用1
*/ */
id = (id == null ? 1 : id); id = (id == null ? 1 : id);
try { try {
CHCAnalysisDto analysisDto = analysisService.getCHCAnalysisById(id); CHCAnalysisDto analysisDto = analysisService.getCHCAnalysisById(id);
List<AnalysisRoundDto> roundList = analysisService.getRoundListByAnalysisId(id); List<AnalysisRoundDto> roundList = analysisService.getRoundListByAnalysisId(id);
analysisDto.setRoundList(roundList); analysisDto.setRoundList(roundList);
builder.setData(analysisDto); builder.setData(analysisDto);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR); return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR);
} }
return builder.build(); return builder.build();
} }
@ApiOperation(value = "获取某一轮的题目", response = PicaResponse.class) @ApiOperation(value = "获取某一轮的题目", response = PicaResponse.class)
@RequestMapping(value = "/roundDetail/{roundId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @RequestMapping(value = "/roundDetail/{roundId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public PicaResponse<RoundExamTitleDto> getRoundDetail(@PathVariable("roundId") Integer roundId) { public PicaResponse<RoundExamTitleDto> getRoundDetail(@PathVariable("roundId") Integer roundId) {
PicaResponse.Builder<RoundExamTitleDto> builder = new PicaResponse.Builder<>(); PicaResponse.Builder<RoundExamTitleDto> builder = new PicaResponse.Builder<>();
try { try {
RoundExamTitleDto roundExamTitleDto = analysisService.getRoundById(roundId); RoundExamTitleDto roundExamTitleDto = analysisService.getRoundById(roundId);
List<ExamTitleDto> examTitleDtoList = analysisService.getExamTitleListByRoundId(roundId); List<ExamTitleDto> examTitleDtoList = analysisService.getExamTitleListByRoundId(roundId);
roundExamTitleDto.setExamTitleList(examTitleDtoList); roundExamTitleDto.setExamTitleList(examTitleDtoList);
builder.setData(roundExamTitleDto); builder.setData(roundExamTitleDto);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR); return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR);
} }
return builder.build(); return builder.build();
} }
@ApiOperation(value = "获取某一道题目的回复列表", response = PicaResponse.class) @ApiOperation(value = "获取某一道题目的回复列表", response = PicaResponse.class)
@RequestMapping(value = "/replyList/{examTitleId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @RequestMapping(value = "/replyList/{examTitleId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public PicaResponse<ExamTitleReplyDto> getReplyList(@PathVariable("examTitleId") Integer examTitleId, public PicaResponse<ExamTitleReplyDto> getReplyList(@PathVariable("examTitleId") Integer examTitleId,
@RequestParam(required = false) String token) { @RequestParam(required = false) String token) {
PICAUser user = null; PICAUser user = null;
if (token != null) { if (token != null) {
user = CommonUtils.getUserByToken(redisClient, token); user = CommonUtils.getUserByToken(redisClient, token);
} }
PicaResponse.Builder<ExamTitleReplyDto> builder = new PicaResponse.Builder<>(); PicaResponse.Builder<ExamTitleReplyDto> builder = new PicaResponse.Builder<>();
try { try {
AnalysisRoundExamTitle analysisRoundExamTitle = analysisService.getAnanlysisRoundExamTitleById(examTitleId); AnalysisRoundExamTitle analysisRoundExamTitle = analysisService.getAnanlysisRoundExamTitleById(examTitleId);
ExamTitleReplyDto examTitleReplyDto = new ExamTitleReplyDto(); ExamTitleReplyDto examTitleReplyDto = new ExamTitleReplyDto();
ExamTitleDto examTitleDto = analysisService.getExamTitleDtoById(examTitleId); ExamTitleDto examTitleDto = analysisService.getExamTitleDtoById(examTitleId);
List<ReplyDto> replyDtoList = analysisService.getReplyListDtoByExamTitleId(examTitleId, user != null ? user.getId() : 0); List<ReplyDto> replyDtoList = analysisService.getReplyListDtoByExamTitleId(examTitleId, user != null ? user.getId() : 0);
examTitleReplyDto.setAnalysisId(analysisRoundExamTitle.getAnalysisId()); examTitleReplyDto.setAnalysisId(analysisRoundExamTitle.getAnalysisId());
examTitleReplyDto.setRoundId(analysisRoundExamTitle.getRoundId()); examTitleReplyDto.setRoundId(analysisRoundExamTitle.getRoundId());
examTitleReplyDto.setExamTitle(examTitleDto); examTitleReplyDto.setExamTitle(examTitleDto);
examTitleReplyDto.setReplyList(replyDtoList); examTitleReplyDto.setReplyList(replyDtoList);
builder.setData(examTitleReplyDto); builder.setData(examTitleReplyDto);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR); return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR);
} }
return builder.build(); return builder.build();
} }
@ApiOperation(value = "查看回复详情", response = PicaResponse.class) @ApiOperation(value = "查看回复详情", response = PicaResponse.class)
@RequestMapping(value = "/replyDetail/{replyId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @RequestMapping(value = "/replyDetail/{replyId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public PicaResponse<ExamTitleReplyDetailDto> getReplyDetail(@PathVariable("replyId") Integer replyId, public PicaResponse<ExamTitleReplyDetailDto> getReplyDetail(@PathVariable("replyId") Integer replyId,
@RequestParam(required = false) String token) { @RequestParam(required = false) String token) {
PICAUser user = null; PICAUser user = null;
if (token != null) { if (token != null) {
user = CommonUtils.getUserByToken(redisClient, token); user = CommonUtils.getUserByToken(redisClient, token);
} }
PicaResponse.Builder<ExamTitleReplyDetailDto> builder = new PicaResponse.Builder<>(); PicaResponse.Builder<ExamTitleReplyDetailDto> builder = new PicaResponse.Builder<>();
try { try {
ExamTitleReplyDetailDto examTitleReplyDetailDto = new ExamTitleReplyDetailDto(); ExamTitleReplyDetailDto examTitleReplyDetailDto = new ExamTitleReplyDetailDto();
Reply reply = analysisService.getReplyById(replyId); Reply reply = analysisService.getReplyById(replyId);
AnalysisRoundExamTitle analysisRoundExamTitle = analysisService.getAnanlysisRoundExamTitleById(reply.getAnalysisRoundExamTitleId()); AnalysisRoundExamTitle analysisRoundExamTitle = analysisService.getAnanlysisRoundExamTitleById(reply.getAnalysisRoundExamTitleId());
ExamTitleDto examTitleDto = analysisService.getExamTitleDtoById(reply.getAnalysisRoundExamTitleId()); ExamTitleDto examTitleDto = analysisService.getExamTitleDtoById(reply.getAnalysisRoundExamTitleId());
ReplyDto replyDto = analysisService.getReplyDtoByReply(reply, user != null ? user.getId() : 0); ReplyDto replyDto = analysisService.getReplyDtoByReply(reply, user != null ? user.getId() : 0);
examTitleReplyDetailDto.setAnalysisId(analysisRoundExamTitle.getAnalysisId()); examTitleReplyDetailDto.setAnalysisId(analysisRoundExamTitle.getAnalysisId());
examTitleReplyDetailDto.setRoundId(analysisRoundExamTitle.getRoundId()); examTitleReplyDetailDto.setRoundId(analysisRoundExamTitle.getRoundId());
examTitleReplyDetailDto.setExamTitle(examTitleDto); examTitleReplyDetailDto.setExamTitle(examTitleDto);
examTitleReplyDetailDto.setReply(replyDto); examTitleReplyDetailDto.setReply(replyDto);
builder.setData(examTitleReplyDetailDto); builder.setData(examTitleReplyDetailDto);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR); return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR);
} }
return builder.build(); return builder.build();
} }
@ApiOperation(value = "点赞", response = PicaResponse.class) @ApiOperation(value = "点赞", response = PicaResponse.class)
@RequestMapping(value = "/starReply/{replyId}/analysis/{analysisId}/round/{roundId}/examTitle/{examTitleId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @RequestMapping(value = "/starReply/{replyId}/analysis/{analysisId}/round/{roundId}/examTitle/{examTitleId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public PicaResponse starReply(@PathVariable("analysisId") Integer analysisId, @PathVariable("roundId") Integer roundId, public PicaResponse starReply(@PathVariable("analysisId") Integer analysisId, @PathVariable("roundId") Integer roundId,
@PathVariable("examTitleId") Integer examTitleId, @PathVariable("replyId") Integer replyId, @PathVariable("examTitleId") Integer examTitleId, @PathVariable("replyId") Integer replyId,
@RequestParam(required = false) String token) { @RequestParam(required = false) String token) {
if (token == null) { if (token == null) {
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_NO_TOKEN); return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_NO_TOKEN);
} }
PICAUser user = CommonUtils.getUserByToken(redisClient, token); PICAUser user = CommonUtils.getUserByToken(redisClient, token);
if (user == null) { if (user == null || user.getId().intValue() == 0) {
System.out.println("starrecord: user=null token=" + token); return ReturnUtil.getPicaResponse(PicaResultCode.LOGIN_FAILE);
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INVALID_TOKEN); }
}
Doctor doctor = doctorService.getDoctorById(user.getId());
Doctor doctor = doctorService.getDoctorById(user.getId());
if (doctor == null) {
if (doctor == null) { return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INVALID_TOKEN);
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INVALID_TOKEN); }
}
/**
/** * 未认证用户直接返回
* 未认证用户直接返回 */
*/ if (!(doctor.getStatus().equals(CommonConstants.DOCTOR_STATUS_3) ||
if (!(doctor.getStatus().equals(CommonConstants.DOCTOR_STATUS_3) || doctor.getStatus().equals(CommonConstants.DOCTOR_STATUS_6) ||
doctor.getStatus().equals(CommonConstants.DOCTOR_STATUS_6) || doctor.getStatus().equals(CommonConstants.DOCTOR_STATUS_7) )) {
doctor.getStatus().equals(CommonConstants.DOCTOR_STATUS_7)) ) { return ReturnUtil.getPicaResponse(PicaResultCode.INTERFACE_FORBID_VISIT);
return ReturnUtil.getPicaResponse(PicaResultCode.INTERFACE_FORBID_VISIT); }
}
System.out.println("starrecord: replyid=" + replyId.toString() + " token=" + token + " roundId=" + roundId + " examTitleId=" + examTitleId);
System.out.println("starrecord: replyid=" + replyId.toString() + " token=" + token + " roundId=" + roundId + " examTitleId=" + examTitleId);
if (0 != analysisService.insertStarRecord(analysisId, roundId, examTitleId, replyId, user.getId())) {
if (0 != analysisService.insertStarRecord(analysisId, roundId, examTitleId, replyId, user.getId())) { /**
/** * 已经点过赞
* 已经点过赞 */
*/ return ReturnUtil.getPicaResponse(PicaResultCode.DATA_ALREADY_EXISTED);
return ReturnUtil.getPicaResponse(PicaResultCode.DATA_ALREADY_EXISTED); }
} return ReturnUtil.getPicaResponse(PicaResultCode.SUCCESS);
return ReturnUtil.getPicaResponse(PicaResultCode.SUCCESS); }
}
@ApiOperation(value = "取消点赞", response = PicaResponse.class)
@ApiOperation(value = "取消点赞", response = PicaResponse.class) @RequestMapping(value = "/cancelStar/{replyId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@RequestMapping(value = "/cancelStar/{replyId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") public PicaResponse cancelStar( @PathVariable("replyId") Integer replyId, @RequestParam(required = false) String token) {
public PicaResponse cancelStar( @PathVariable("replyId") Integer replyId, @RequestParam(required = false) String token) { if (token == null) {
if (token == null) { return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_NO_TOKEN);
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_NO_TOKEN); }
}
PICAUser user = CommonUtils.getUserByToken(redisClient, token);
PICAUser user = CommonUtils.getUserByToken(redisClient, token);
if (user == null) {
if (user == null) { return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INVALID_TOKEN);
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INVALID_TOKEN); }
}
System.out.println("cancelStar: replyid=" + replyId.toString() + " token=" + token);
System.out.println("cancelStar: replyid=" + replyId.toString() + " token=" + token);
if (0 != analysisService.removeStarRecord(replyId, user.getId())) {
if (0 != analysisService.removeStarRecord(replyId, user.getId())) { return ReturnUtil.getPicaResponse(PicaResultCode.RESULE_DATA_NONE);
return ReturnUtil.getPicaResponse(PicaResultCode.RESULE_DATA_NONE); }
}
return ReturnUtil.getPicaResponse(PicaResultCode.SUCCESS);
return ReturnUtil.getPicaResponse(PicaResultCode.SUCCESS); }
} }
@ApiOperation(value = "获取某一道题目的下一道题", response = PicaResponse.class)
@RequestMapping(value = "/nextExamTitle/{examTitleId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public PicaResponse<ExamTitleReplyDto> nextReplyList(@PathVariable("examTitleId") Integer examTitleId,
@RequestHeader(required = false) String token) {
PICAUser user = null;
if (token != null) {
user = CommonUtils.getUserByToken(redisClient, token);
}
PicaResponse.Builder<ExamTitleReplyDto> builder = new PicaResponse.Builder<>();
try {
AnalysisRoundExamTitle analysisRoundExamTitle = analysisService.getAnanlysisRoundExamTitleById(examTitleId);
ExamTitleReplyDto examTitleReplyDto = new ExamTitleReplyDto();
ExamTitleDto examTitleDto = analysisService.getNextExamTitleDtoById(analysisRoundExamTitle.getRoundId(), examTitleId);
List<ReplyDto> replyDtoList = analysisService.getReplyListDtoByExamTitleId(examTitleDto.getExamTitleId(), user != null ? user.getId() : 0);
examTitleReplyDto.setAnalysisId(analysisRoundExamTitle.getAnalysisId());
examTitleReplyDto.setRoundId(analysisRoundExamTitle.getRoundId());
examTitleReplyDto.setExamTitle(examTitleDto);
examTitleReplyDto.setReplyList(replyDtoList);
builder.setData(examTitleReplyDto);
} catch (Exception e) {
e.printStackTrace();
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR);
}
return builder.build();
}
@ApiOperation(value = "获取某一道题目的下一道题", response = PicaResponse.class)
@RequestMapping(value = "/nextReply/{replyId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public PicaResponse<ExamTitleReplyDto> nextReplyDetail(@PathVariable("replyId") Integer replyId,
@RequestHeader(required = false) String token) {
PICAUser user = null;
if (token != null) {
user = CommonUtils.getUserByToken(redisClient, token);
}
PicaResponse.Builder<ExamTitleReplyDetailDto> builder = new PicaResponse.Builder<>();
try {
ExamTitleReplyDetailDto examTitleReplyDetailDto = new ExamTitleReplyDetailDto();
Reply reply = analysisService.getNextReplyById(replyId);
AnalysisRoundExamTitle analysisRoundExamTitle = analysisService.getAnanlysisRoundExamTitleById(reply.getAnalysisRoundExamTitleId());
ExamTitleDto examTitleDto = analysisService.getExamTitleDtoById(reply.getAnalysisRoundExamTitleId());
ReplyDto replyDto = analysisService.getReplyDtoByReply(reply, user != null ? user.getId() : 0);
examTitleReplyDetailDto.setAnalysisId(analysisRoundExamTitle.getAnalysisId());
examTitleReplyDetailDto.setRoundId(analysisRoundExamTitle.getRoundId());
examTitleReplyDetailDto.setExamTitle(examTitleDto);
examTitleReplyDetailDto.setReply(replyDto);
builder.setData(examTitleReplyDetailDto);
} catch (Exception e) {
e.printStackTrace();
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INNER_ERROR);
}
return builder.build();
}
}
...@@ -154,7 +154,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService { ...@@ -154,7 +154,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
examTitleDto.setExamTitleId(analysisRoundExamTitle.getId()); examTitleDto.setExamTitleId(analysisRoundExamTitle.getId());
examTitleDto.setSeqNo(analysisRoundExamTitle.getSeqNo()); examTitleDto.setSeqNo(analysisRoundExamTitle.getSeqNo());
examTitleDto.setType(analysisRoundExamTitle.getExamTitleType()); examTitleDto.setType(analysisRoundExamTitle.getExamTitleType());
examTitleDto.setQuestion(analysisRoundExamTitle.getQuestion()); examTitleDto.setQuestion(analysisRoundExamTitle.getSeqNo().toString() + "." + analysisRoundExamTitle.getQuestion());
/** /**
* 设置选项 * 设置选项
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册