|
@@ -11,6 +11,7 @@ import com.ynfy.buss.course.coursecatalog.service.ICourseCatalogService;
|
|
|
import com.ynfy.buss.course.usercoursecatalog.entity.UserCourseCatalog;
|
|
|
import com.ynfy.buss.course.usercoursecatalog.service.IUserCourseCatalogService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -127,27 +128,27 @@ public class CourseCatalogServiceImpl extends ServiceImpl<CourseCatalogMapper, C
|
|
|
@Override
|
|
|
public boolean checkPreTaskComplete(String id, LoginUser user) {
|
|
|
CourseCatalog courseCatalog = getById(id);
|
|
|
- if (!Objects.isNull(courseCatalog)) {
|
|
|
- if (StringUtils.isNotBlank(courseCatalog.getParentId())) { //点击了目录下的任务
|
|
|
- if (courseCatalog.getSort() > 1) { //如果点击的是目录下的第n(n>1)个任务,获取本目录下的点击任务的前一个任务
|
|
|
- return isComplete(user, getPre(courseCatalog.getParentId(), courseCatalog.getSort() - 1).getId());
|
|
|
- } else { //sort == 1 //如果点击的是目录下的第一个任务
|
|
|
- CourseCatalog parent = getParent(courseCatalog.getParentId()); //获取父节点
|
|
|
- if (!Objects.isNull(parent) && parent.getSort() > 1) {//不是第一个根节点,获取前一个根节点
|
|
|
- return calcIsFinish(user, courseCatalog.getCourseId(), parent.getSort() - 1);
|
|
|
- } else { //是第一个根节点
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- } else { //点击了根节点的任务
|
|
|
- if (courseCatalog.getSort() > 1) {
|
|
|
- return calcIsFinish(user, courseCatalog.getCourseId(), courseCatalog.getSort() - 1);
|
|
|
- } else {
|
|
|
+ if (Objects.isNull(courseCatalog)) {
|
|
|
+ throw new JeecgBootException("课程任务不存在");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(courseCatalog.getParentId())) { //点击了目录下的任务
|
|
|
+ if (courseCatalog.getSort() > 1) { //如果点击的是目录下的第n(n>1)个任务,获取本目录下的点击任务的前一个任务
|
|
|
+ return isComplete(user, getPre(courseCatalog.getParentId(), courseCatalog.getSort() - 1).getId());
|
|
|
+ } else { //sort == 1 //如果点击的是目录下的第一个任务
|
|
|
+ CourseCatalog parent = getParent(courseCatalog.getParentId()); //获取父节点
|
|
|
+ if (!Objects.isNull(parent) && parent.getSort() > 1) {//不是第一个根节点,获取前一个根节点
|
|
|
+ return calcIsFinish(user, courseCatalog.getCourseId(), parent.getSort() - 1);
|
|
|
+ } else { //是第一个根节点
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
+ } else { //点击了根节点的任务
|
|
|
+ if (courseCatalog.getSort() > 1) {
|
|
|
+ return calcIsFinish(user, courseCatalog.getCourseId(), courseCatalog.getSort() - 1);
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
public CourseCatalog getPre(String parentId, Integer sort) {
|