mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-22 18:29:51 +08:00
资源分类增加检测api
This commit is contained in:
@@ -29,4 +29,8 @@ public interface ResourceCategoryService extends IService<ResourceCategory> {
|
||||
|
||||
String compParentChain(Integer parentId) throws NotFoundException;
|
||||
|
||||
List<Integer> getCourseIdsById(Integer id);
|
||||
|
||||
List<Integer> getRidsById(Integer id);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,4 +27,6 @@ public interface ResourceService extends IService<Resource> {
|
||||
|
||||
List<Resource> chunks(List<Integer> ids);
|
||||
|
||||
List<Resource> chunks(List<Integer> ids, List<String> fields);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package xyz.playedu.api.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import xyz.playedu.api.domain.ResourceCategory;
|
||||
import xyz.playedu.api.domain.ResourceCategoryRelation;
|
||||
import xyz.playedu.api.domain.ResourceCourseCategory;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.service.ResourceCategoryService;
|
||||
import xyz.playedu.api.mapper.ResourceCategoryMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import xyz.playedu.api.service.internal.ResourceCategoryRelationService;
|
||||
import xyz.playedu.api.service.internal.ResourceCourseCategoryService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -21,6 +26,12 @@ import java.util.List;
|
||||
public class ResourceCategoryServiceImpl extends ServiceImpl<ResourceCategoryMapper, ResourceCategory>
|
||||
implements ResourceCategoryService {
|
||||
|
||||
@Autowired
|
||||
private ResourceCourseCategoryService resourceCourseCategoryService;
|
||||
|
||||
@Autowired
|
||||
private ResourceCategoryRelationService resourceCategoryRelationService;
|
||||
|
||||
@Override
|
||||
public List<ResourceCategory> listByParentId(Integer id) {
|
||||
return list(query().getWrapper().eq("parent_id", id).orderByAsc("sort"));
|
||||
@@ -154,7 +165,16 @@ public class ResourceCategoryServiceImpl extends ServiceImpl<ResourceCategoryMap
|
||||
}
|
||||
return parentChain;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Integer> getCourseIdsById(Integer id) {
|
||||
return resourceCourseCategoryService.list(resourceCourseCategoryService.query().getWrapper().eq("category_id", id)).stream().map(ResourceCourseCategory::getCourseId).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getRidsById(Integer id) {
|
||||
return resourceCategoryRelationService.list(resourceCategoryRelationService.query().getWrapper().eq("cid", id)).stream().map(ResourceCategoryRelation::getRid).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -150,6 +150,11 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
public List<Resource> chunks(List<Integer> ids) {
|
||||
return list(query().getWrapper().in("id", ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Resource> chunks(List<Integer> ids, List<String> fields) {
|
||||
return list(query().getWrapper().in("id", ids).select(fields));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user