|
@@ -18,6 +18,7 @@ import com.yonge.cooleshow.biz.dal.service.SubjectService;
|
|
|
import com.yonge.cooleshow.common.dal.BaseDAO;
|
|
|
import com.yonge.cooleshow.common.page.PageInfo;
|
|
|
import com.yonge.cooleshow.common.service.impl.BaseServiceImpl;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@Service
|
|
|
public class SubjectServiceImpl extends BaseServiceImpl<Long, Subject> implements SubjectService {
|
|
@@ -31,6 +32,15 @@ public class SubjectServiceImpl extends BaseServiceImpl<Long, Subject> implement
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<Subject> findBySubjectByIdList(List<Long> subjectIdList) {
|
|
|
+ return subjectDao.findBySubjectIds(subjectIdList);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public List<Subject> findBySubjectByIdList(String subjectIdList) {
|
|
|
+ return subjectDao.findBySubjectByIdList(subjectIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public PageInfo<Subject> queryPageTree(SubjectQueryInfo queryInfo) {
|
|
|
PageInfo<Subject> pageInfo = queryPage(queryInfo);
|
|
|
for (Subject subject : pageInfo.getRows()) {
|
|
@@ -59,46 +69,6 @@ public class SubjectServiceImpl extends BaseServiceImpl<Long, Subject> implement
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Long upset(Subject subject, Long parentId) {
|
|
|
- if (parentId != null) {
|
|
|
- subject.setParentSubjectId(parentId);
|
|
|
- }
|
|
|
- if (subject.getId() != null) {
|
|
|
- subject.setUpdateTime(new Date());
|
|
|
- subjectDao.update(subject);
|
|
|
- } else {
|
|
|
- subjectDao.insert(subject);
|
|
|
- }
|
|
|
- return subject.getId();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private Subject getTree(Subject sub, YesOrNoEnum yesOrNoEnum) {
|
|
|
- //得到根节点对象
|
|
|
- //获取子节点list
|
|
|
- List<Subject> subjects = subjectDao.findByParentId(sub.getId(), yesOrNoEnum);
|
|
|
- //如果存在子节点
|
|
|
- if (subjects != null && subjects.size() > 0) {
|
|
|
- //将子节点list放入父节点对象
|
|
|
- sub.setSubjects(subjects);
|
|
|
- //遍历子节点....
|
|
|
- for (Subject subject : subjects) {
|
|
|
- getTree(subject, yesOrNoEnum);
|
|
|
- }
|
|
|
- }
|
|
|
- return sub;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Subject> findBySubjectByIdList(List<Long> subjectIdList) {
|
|
|
- return subjectDao.findBySubjectByIdList(StringUtils.join(subjectIdList, ","));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Subject> findBySubjectByIdList(String subjectIdList) {
|
|
|
- return subjectDao.findBySubjectByIdList(subjectIdList);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public List<SubjectSelectVo> subjectSelect() {
|
|
|
List<Subject> allList = subjectDao.findAll(new HashMap<>());
|
|
@@ -114,11 +84,11 @@ public class SubjectServiceImpl extends BaseServiceImpl<Long, Subject> implement
|
|
|
});
|
|
|
|
|
|
List<SubjectSelectVo> parents = allListVo.stream()
|
|
|
- .filter(o -> (!o.getParentSubjectId().equals(0) && null != o.getParentSubjectId()))
|
|
|
+ .filter(o -> (null == o.getParentSubjectId() || o.getParentSubjectId().equals(0L) ))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
List<SubjectSelectVo> subjects = allListVo.stream()
|
|
|
- .filter(o -> (null == o.getParentSubjectId() || o.getParentSubjectId().equals(0)))
|
|
|
+ .filter(o -> !(null == o.getParentSubjectId() || o.getParentSubjectId().equals(0L)))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
for (SubjectSelectVo parent : parents) {
|
|
@@ -130,10 +100,58 @@ public class SubjectServiceImpl extends BaseServiceImpl<Long, Subject> implement
|
|
|
continue;
|
|
|
}
|
|
|
if (subject.getParentSubjectId().equals(parent.getId())) {
|
|
|
- parent.getChildren().add(subject);
|
|
|
+ List<SubjectSelectVo> children = parent.getChildren();
|
|
|
+ if(CollectionUtils.isEmpty(children)){
|
|
|
+ children = new ArrayList<>();
|
|
|
+ }
|
|
|
+ children.add(subject);
|
|
|
+ parent.setChildren(children);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return parents;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 新增、修改声部
|
|
|
+ * @param: subject
|
|
|
+ * @param: parentId
|
|
|
+ * @updateTime 2022/4/6 11:33
|
|
|
+ * @return: java.lang.Long
|
|
|
+ */
|
|
|
+ private Long upset(Subject subject, Long parentId) {
|
|
|
+ if (parentId != null) {
|
|
|
+ subject.setParentSubjectId(parentId);
|
|
|
+ }
|
|
|
+ if (subject.getId() != null) {
|
|
|
+ subject.setUpdateTime(new Date());
|
|
|
+ subjectDao.update(subject);
|
|
|
+ } else {
|
|
|
+ subjectDao.insert(subject);
|
|
|
+ }
|
|
|
+ return subject.getId();
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * 查询声部树
|
|
|
+ * @param: sub
|
|
|
+ * @param: yesOrNoEnum
|
|
|
+ * @updateTime 2022/4/6 11:33
|
|
|
+ * @return: com.yonge.cooleshow.biz.dal.entity.Subject
|
|
|
+ */
|
|
|
+ private Subject getTree(Subject sub, YesOrNoEnum yesOrNoEnum) {
|
|
|
+ //得到根节点对象
|
|
|
+ //获取子节点list
|
|
|
+ List<Subject> subjects = subjectDao.findByParentId(sub.getId(), yesOrNoEnum);
|
|
|
+ //如果存在子节点
|
|
|
+ if (subjects != null && subjects.size() > 0) {
|
|
|
+ //将子节点list放入父节点对象
|
|
|
+ sub.setSubjects(subjects);
|
|
|
+ //遍历子节点....
|
|
|
+ for (Subject subject : subjects) {
|
|
|
+ getTree(subject, yesOrNoEnum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sub;
|
|
|
+ }
|
|
|
}
|