/** * 添加评审信息(支持海选、初审、终审、正式入选)。role = [MANAGER] * * @param review the review * @return the data wrapper */ @RequestMapping(value = "/review", method = RequestMethod.POST) @RequiredRole(Role.MANAGER) DataWrapper add(@RequestBody Review review) { if (review.getPhase() == null) { return new DataWrapper(ErrorCodeEnum.BIZ_DATA_INSUFFICIENT, "Review phase is missing."); } DataWrapper check = isProjectValid(review.getProjectId(), review.getPhase()); if (check != null) { return check; } Account manager = currentAccount(); review.setCreaterId(manager.getId()); if (review.getPhase() == Phase.AUDITION) { review.setManagerName(manager.getName()); return reviewService.addLike(review); } if (review.getPhase() == Phase.FIRST_REVIEW) { return reviewService.addFirstReview(review); } if (review.getPhase() == Phase.FINAL_REVIEW) { return reviewService.addFinalReview(review); } if (review.getPhase() == Phase.ACCEPTED) { return reviewService.addEvaluation(review); } return new DataWrapper(ErrorCodeEnum.BIZ_PHASE_ERROR, "Unsupported phase for review."); }
/** * Checks if is review valid. * * @param rid the rid * @return the data wrapper */ private DataWrapper isReviewValid(Long rid) { Review review = reviewService.get(rid); if (review == null) { return new DataWrapper( ErrorCodeEnum.BIZ_DATA_NOT_FOUND, String.format("The review (ID=%d) does not exist.", rid)); } return isProjectValid(review.getProjectId(), review.getPhase()); }