mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-29 00:42:50 +08:00
资源分类过滤
This commit is contained in:
parent
64309a078a
commit
db1f6fc9c6
@ -13,7 +13,6 @@ public class BackendConstant {
|
||||
public final static String RESOURCE_TYPE_WORD = "WORD";
|
||||
public final static String RESOURCE_TYPE_PPT = "PPT";
|
||||
|
||||
public final static String[] RESOURCE_TYPE_WHITELIST = {RESOURCE_TYPE_IMAGE, RESOURCE_TYPE_PDF, RESOURCE_TYPE_VIDEO, RESOURCE_TYPE_WORD, RESOURCE_TYPE_PPT};
|
||||
public final static HashMap<String, String> RESOURCE_EXT_2_CONTENT_TYPE = new HashMap<>() {{
|
||||
put("png", "image/png");
|
||||
put("jpg", "image/jpg");
|
||||
|
@ -54,7 +54,13 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
wrapper.eq("type", filter.getType());
|
||||
}
|
||||
if (filter.getCategoryIds() != null && filter.getCategoryIds().length > 0) {
|
||||
// todo 资源分类过滤
|
||||
List<Integer> ridArray = relationService.getRidsByCids(Arrays.asList(filter.getCategoryIds()));
|
||||
if (ridArray == null || ridArray.size() == 0) {
|
||||
ridArray = new ArrayList<>() {{
|
||||
add(0);
|
||||
}};
|
||||
}
|
||||
wrapper.in("id", ridArray);
|
||||
}
|
||||
|
||||
String sortFiled = filter.getSortField();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package xyz.playedu.api.service.impl;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -20,6 +21,7 @@ import java.util.List;
|
||||
* @create 2023/3/8 14:02
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class UploadServiceImpl implements UploadService {
|
||||
|
||||
@Autowired
|
||||
|
@ -6,15 +6,24 @@ import xyz.playedu.api.service.internal.ResourceCategoryRelationService;
|
||||
import xyz.playedu.api.mapper.ResourceCategoryRelationMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
* @description 针对表【resource_category】的数据库操作Service实现
|
||||
* @createDate 2023-03-08 16:54:56
|
||||
*/
|
||||
* @author tengteng
|
||||
* @description 针对表【resource_category】的数据库操作Service实现
|
||||
* @createDate 2023-03-08 16:54:56
|
||||
*/
|
||||
@Service
|
||||
public class ResourceCategoryRelationServiceImpl extends ServiceImpl<ResourceCategoryRelationMapper, ResourceCategoryRelation>
|
||||
implements ResourceCategoryRelationService{
|
||||
|
||||
implements ResourceCategoryRelationService {
|
||||
@Override
|
||||
public List<Integer> getRidsByCids(List<Integer> categoryIds) {
|
||||
List<ResourceCategoryRelation> relations = list(query().getWrapper().in("cid", categoryIds));
|
||||
if (relations == null) {
|
||||
return null;
|
||||
}
|
||||
return relations.stream().map(ResourceCategoryRelation::getRid).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@ package xyz.playedu.api.service.internal;
|
||||
import xyz.playedu.api.domain.ResourceCategoryRelation;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
* @description 针对表【resource_category】的数据库操作Service
|
||||
@ -10,4 +12,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface ResourceCategoryRelationService extends IService<ResourceCategoryRelation> {
|
||||
|
||||
List<Integer> getRidsByCids(List<Integer> categoryIds);
|
||||
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ minio:
|
||||
mybatis:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
#mybatis-plus:
|
||||
# configuration:
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
# PlayEdu
|
||||
playedu:
|
||||
|
Loading…
x
Reference in New Issue
Block a user