| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.domain.TaskUser; |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | |
| | | @Override |
| | | public void addTaskUser(String taskId) { |
| | | //如果有用户认领了这个任务 |
| | | |
| | | //看看他在不在这个任务中 |
| | | TaskUserMongo byId = mongoTemplate.findById(taskId, TaskUserMongo.class); |
| | | |
| | | TaskMongo taskMongo = mongoTemplate.findById(byId.getTask().getId(), TaskMongo.class); |
| | | List<Long> containUserList = taskMongo.getContainUserList(); |
| | | if(!containUserList.contains(SecurityUtils.getCurrentUserId())){ |
| | | //如果获取的这个人不在这个任务中 |
| | | throw new BadRequestException("您不在当前的任务中,无法领取该任务"); |
| | | } |
| | | |
| | | if(byId != null){ |
| | | byId.setUserId(SecurityUtils.getCurrentUserId()); |
| | | mongoTemplate.save(byId); |