|
|
@@ -1,11 +1,13 @@
|
|
|
package com.izouma.nineth.service;
|
|
|
|
|
|
+import com.izouma.nineth.domain.MetaAtomTask;
|
|
|
import com.izouma.nineth.domain.MetaTaskBind;
|
|
|
import com.izouma.nineth.domain.MetaTaskNew;
|
|
|
import com.izouma.nineth.dto.MetaRestResult;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.enums.MetaTaskType;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
+import com.izouma.nineth.repo.MetaAtomTaskRepo;
|
|
|
import com.izouma.nineth.repo.MetaTaskBindRepo;
|
|
|
import com.izouma.nineth.repo.MetaTaskNewRepo;
|
|
|
import com.izouma.nineth.utils.JpaUtils;
|
|
|
@@ -16,6 +18,7 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
@@ -23,6 +26,7 @@ public class MetaTaskNewService {
|
|
|
|
|
|
private MetaTaskNewRepo metaTaskNewRepo;
|
|
|
private MetaTaskBindRepo metaTaskBindRepo;
|
|
|
+ private MetaAtomTaskRepo metaAtomTaskRepo;
|
|
|
|
|
|
public MetaTaskNew save(MetaTaskNew record) {
|
|
|
if (record.getId() != null) {
|
|
|
@@ -76,7 +80,11 @@ public class MetaTaskNewService {
|
|
|
|
|
|
public MetaRestResult<List<MetaTaskNew>> canGet(Long userId, Long channelId) {
|
|
|
List<MetaTaskNew> metaTaskNews = metaTaskNewRepo.canGet(userId, channelId);
|
|
|
- metaTaskNews.forEach(this::buildAtomTask);
|
|
|
+ try {
|
|
|
+ metaTaskNews.forEach(this::buildAtomTask);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return MetaRestResult.returnError(e.getMessage());
|
|
|
+ }
|
|
|
return MetaRestResult.returnSuccess(metaTaskNews);
|
|
|
}
|
|
|
|
|
|
@@ -84,10 +92,12 @@ public class MetaTaskNewService {
|
|
|
if (MetaTaskType.MAIN_LINE.equals(metaTaskNew.getType())) {
|
|
|
List<MetaTaskBind> metaNodeTask = metaTaskBindRepo.findByTaskIdAndTypeAndDel(metaTaskNew.getId(), MetaTaskType.NODE, false);
|
|
|
if (CollectionUtils.isNotEmpty(metaNodeTask)) {
|
|
|
+ buildMetaAtomTask(metaNodeTask);
|
|
|
metaTaskNew.setMetaNodeTask(metaNodeTask);
|
|
|
}
|
|
|
List<MetaTaskBind> metaBranchLineTask = metaTaskBindRepo.findByTaskIdAndTypeAndDel(metaTaskNew.getId(), MetaTaskType.BRANCH_LINE, false);
|
|
|
if (CollectionUtils.isNotEmpty(metaBranchLineTask)) {
|
|
|
+ buildMetaAtomTask(metaBranchLineTask);
|
|
|
metaTaskNew.setMetaBranchLineTask(metaBranchLineTask);
|
|
|
}
|
|
|
return;
|
|
|
@@ -95,6 +105,7 @@ public class MetaTaskNewService {
|
|
|
if (MetaTaskType.BRANCH_LINE.equals(metaTaskNew.getType())) {
|
|
|
List<MetaTaskBind> metaBranchLineTask = metaTaskBindRepo.findByTaskIdAndTypeAndDel(metaTaskNew.getId(), MetaTaskType.BRANCH_LINE, false);
|
|
|
if (CollectionUtils.isNotEmpty(metaBranchLineTask)) {
|
|
|
+ buildMetaAtomTask(metaBranchLineTask);
|
|
|
metaTaskNew.setMetaBranchLineTask(metaBranchLineTask);
|
|
|
}
|
|
|
return;
|
|
|
@@ -102,8 +113,21 @@ public class MetaTaskNewService {
|
|
|
if (MetaTaskType.DAILY.equals(metaTaskNew.getType())) {
|
|
|
List<MetaTaskBind> metaDailyTask = metaTaskBindRepo.findByTaskIdAndTypeAndDel(metaTaskNew.getId(), MetaTaskType.DAILY, false);
|
|
|
if (CollectionUtils.isNotEmpty(metaDailyTask)) {
|
|
|
+ buildMetaAtomTask(metaDailyTask);
|
|
|
metaTaskNew.setMetaDailyTask(metaDailyTask);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void buildMetaAtomTask(List<MetaTaskBind> metaTaskBinds) {
|
|
|
+ if (CollectionUtils.isNotEmpty(metaTaskBinds)) {
|
|
|
+ metaTaskBinds.forEach(metaTaskBind -> {
|
|
|
+ MetaAtomTask metaAtomTask = metaAtomTaskRepo.findByIdAndDel(metaTaskBind.getAtomTaskId(), false);
|
|
|
+ if (Objects.isNull(metaAtomTask)) {
|
|
|
+ throw new BusinessException("原子任务不存在");
|
|
|
+ }
|
|
|
+ metaTaskBind.setMetaAtomTask(metaAtomTask);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|