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

fix: 允许分享页面不带token值进行调用

上级 08d1f97f
...@@ -93,15 +93,12 @@ public class AnalysisController { ...@@ -93,15 +93,12 @@ public class AnalysisController {
@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 String token) { @RequestParam(required = false) String token) {
if (token == null) {
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_NO_TOKEN);
}
PICAUser user = CommonUtils.getUserByToken(redisClient, token); PICAUser user = null;
if (user == null) { if (token != null) {
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INVALID_TOKEN); user = CommonUtils.getUserByToken(redisClient, token);
} }
PicaResponse.Builder<ExamTitleReplyDto> builder = new PicaResponse.Builder<>(); PicaResponse.Builder<ExamTitleReplyDto> builder = new PicaResponse.Builder<>();
...@@ -111,7 +108,7 @@ public class AnalysisController { ...@@ -111,7 +108,7 @@ public class AnalysisController {
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.getId()); 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());
...@@ -130,15 +127,11 @@ public class AnalysisController { ...@@ -130,15 +127,11 @@ public class AnalysisController {
@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 String token) { @RequestParam(required = false) String token) {
if (token == null) { PICAUser user = null;
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_NO_TOKEN);
}
PICAUser user = CommonUtils.getUserByToken(redisClient, token);
if (user == null) { if (token != null) {
return ReturnUtil.getPicaResponse(PicaResultCode.SYSTEM_INVALID_TOKEN); user = CommonUtils.getUserByToken(redisClient, token);
} }
PicaResponse.Builder<ExamTitleReplyDetailDto> builder = new PicaResponse.Builder<>(); PicaResponse.Builder<ExamTitleReplyDetailDto> builder = new PicaResponse.Builder<>();
...@@ -150,7 +143,7 @@ public class AnalysisController { ...@@ -150,7 +143,7 @@ public class AnalysisController {
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.getId()); 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());
...@@ -170,7 +163,7 @@ public class AnalysisController { ...@@ -170,7 +163,7 @@ public class AnalysisController {
@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 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);
} }
...@@ -201,7 +194,7 @@ public class AnalysisController { ...@@ -201,7 +194,7 @@ public class AnalysisController {
@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 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);
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册