| | |
| | | package me.zhengjie.modules.task.service.impl;
|
| | |
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import me.zhengjie.exception.BadRequestException;
|
| | | import me.zhengjie.modules.constant.Constant;
|
| | | import me.zhengjie.modules.project.domain.Project;
|
| | | import me.zhengjie.modules.project.repository.ProjectRepository;
|
| | |
| | | @CacheEvict(cacheNames = "ChildrenTask", allEntries = true)
|
| | | public TaskMongo create(Long userId, TaskMongo resources) {
|
| | | resources.setTaskStatus(Constant.TASK_STATUS_NOT_STARTED);
|
| | | boolean existed = mongoTemplate.exists(Query.query(Criteria.where("name").is(resources.getName()).and("projectId").is(resources.getProjectId())), TaskMongo.class);
|
| | | if (existed) {
|
| | | throw new BadRequestException("任务名称重复");
|
| | | }
|
| | | synchronized (lock) {
|
| | | // 查询最大的old_id值
|
| | | Query query = new Query();
|
| | |
| | | //
|
| | | // containUserList.addAll(userIdList.stream().filter(o -> !containUserList.contains(o)).collect(Collectors.toList()));
|
| | |
|
| | |
|
| | | boolean existed = mongoTemplate.exists(Query.query(Criteria.where("name").is(resources.getName()).and("projectId").is(resources.getProjectId()).and("id").ne(resources.getId())), TaskMongo.class);
|
| | | if (existed) {
|
| | | throw new BadRequestException("任务名称重复");
|
| | | }
|
| | | return mongoTemplate.save(resources);
|
| | |
|
| | | }
|