课程分类

This commit is contained in:
none
2023-02-24 14:12:51 +08:00
parent 2ca2b0989a
commit 97820eb402
12 changed files with 516 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
package xyz.playedu.api.bus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xyz.playedu.api.domain.CourseCategory;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.service.CourseCategoryService;
/**
* @Author 杭州白书科技有限公司
* @create 2023/2/24 13:57
*/
@Component
public class CourseCategoryBus {
@Autowired
private CourseCategoryService categoryService;
public String compParentChain(Integer parentId) throws NotFoundException {
String parentChain = "";
if (parentId != 0) {
CourseCategory parentCourseCategory = categoryService.getById(parentId);
if (parentCourseCategory == null) {
throw new NotFoundException("父级分类不存在");
}
String pc = parentCourseCategory.getParentChain();
parentChain = pc == null || pc.length() == 0 ? parentId + "" : pc + "," + parentId;
}
return parentChain;
}
public static String childrenParentChain(CourseCategory CourseCategory) {
String prefix = CourseCategory.getId() + "";
if (CourseCategory.getParentChain() != null && CourseCategory.getParentChain().length() > 0) {
prefix = CourseCategory.getParentChain() + "," + prefix;
}
return prefix;
}
}