|
@@ -1,6 +1,7 @@
|
|
|
package cn.iselab.mooctest.site.web.ctrl;
|
|
package cn.iselab.mooctest.site.web.ctrl;
|
|
|
|
|
|
|
|
import cn.iselab.mooctest.site.common.constant.UrlConstants;
|
|
import cn.iselab.mooctest.site.common.constant.UrlConstants;
|
|
|
|
|
+import cn.iselab.mooctest.site.models.ContestMentor;
|
|
|
import cn.iselab.mooctest.site.models.Task;
|
|
import cn.iselab.mooctest.site.models.Task;
|
|
|
import cn.iselab.mooctest.site.models.User;
|
|
import cn.iselab.mooctest.site.models.User;
|
|
|
import cn.iselab.mooctest.site.service.UserService;
|
|
import cn.iselab.mooctest.site.service.UserService;
|
|
@@ -38,16 +39,24 @@ public class ContestController {
|
|
|
private UserService userService;
|
|
private UserService userService;
|
|
|
|
|
|
|
|
@RequestMapping(value = UrlConstants.API + "contest/enter/{contestId}", method = RequestMethod.POST)
|
|
@RequestMapping(value = UrlConstants.API + "contest/enter/{contestId}", method = RequestMethod.POST)
|
|
|
- public List<ContestMentorVO> enterContest(@PathVariable("contestId") Long contestId, @RequestBody List<ContestMentorVO> contestMentorVOS) {
|
|
|
|
|
|
|
+ public boolean enterContest(@PathVariable("contestId") Long contestId) {
|
|
|
User user = (User) SecurityUtils.getSubject().getSession().getAttribute("User");
|
|
User user = (User) SecurityUtils.getSubject().getSession().getAttribute("User");
|
|
|
- return contestLogic.enterContest(contestId,user.getId(), contestMentorVOS);
|
|
|
|
|
|
|
+ return contestLogic.enterContest(contestId,user.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequestMapping(value = UrlConstants.API + "contest/mentors/{contestId}/{role}", method = RequestMethod.POST)
|
|
|
|
|
+ public List<ContestMentorVO> addContestMentor(@PathVariable("contestId") Long contestId,
|
|
|
|
|
+ @PathVariable("role") Byte role,
|
|
|
|
|
+ @RequestBody List<ContestMentorVO> contestMentorVOS) {
|
|
|
|
|
+ User user = (User) SecurityUtils.getSubject().getSession().getAttribute("User");
|
|
|
|
|
+ return contestLogic.addContestMentor(contestId,user.getId(), contestMentorVOS, role);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = UrlConstants.API + "contest/mentors/{contestId}", method = RequestMethod.GET)
|
|
@RequestMapping(value = UrlConstants.API + "contest/mentors/{contestId}", method = RequestMethod.GET)
|
|
|
- public List<ContestMentorVO> getContestMentor(@PathVariable("contestId") Long contestId) {
|
|
|
|
|
|
|
+ public List<ContestMentorVO> getContestMentor(@PathVariable("contestId") Long contestId, @RequestParam(name = "role") Byte role) {
|
|
|
User user = (User) SecurityUtils.getSubject().getSession().getAttribute("User");
|
|
User user = (User) SecurityUtils.getSubject().getSession().getAttribute("User");
|
|
|
examLogic.getExamByIdAndParticipantIdIfPermited(contestId, user.getId());
|
|
examLogic.getExamByIdAndParticipantIdIfPermited(contestId, user.getId());
|
|
|
- return contestLogic.getContestMentor(contestId,user.getId());
|
|
|
|
|
|
|
+ return contestLogic.getContestMentor(contestId,user.getId(),role);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = UrlConstants.API + "contest", method = RequestMethod.GET)
|
|
@RequestMapping(value = UrlConstants.API + "contest", method = RequestMethod.GET)
|
|
@@ -65,12 +74,12 @@ public class ContestController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = UrlConstants.API + "contest/enterWithoutLogin/{contestId}", method = RequestMethod.POST)
|
|
@RequestMapping(value = UrlConstants.API + "contest/enterWithoutLogin/{contestId}", method = RequestMethod.POST)
|
|
|
- public List<ContestMentorVO> enterContestWithoutLogin(@PathVariable("contestId") Long contestId, @RequestBody EnterContestVO enterContestVO) {
|
|
|
|
|
|
|
+ public Boolean enterContestWithoutLogin(@PathVariable("contestId") Long contestId, @RequestBody EnterContestVO enterContestVO) {
|
|
|
User user = userService.findByEmail(enterContestVO.getEmail());
|
|
User user = userService.findByEmail(enterContestVO.getEmail());
|
|
|
if(user.getPassword()!=enterContestVO.getPassword()){
|
|
if(user.getPassword()!=enterContestVO.getPassword()){
|
|
|
throw new UnauthorizedException("unauthorized");
|
|
throw new UnauthorizedException("unauthorized");
|
|
|
}
|
|
}
|
|
|
- return contestLogic.enterContest(contestId,user.getId(), enterContestVO.getTeachers());
|
|
|
|
|
|
|
+ return contestLogic.enterContest(contestId,user.getId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = UrlConstants.API_COMMON + "contest/{year:\\d+}", method = RequestMethod.GET)
|
|
@RequestMapping(value = UrlConstants.API_COMMON + "contest/{year:\\d+}", method = RequestMethod.GET)
|