mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-25 20:35:35 +08:00
added: 资源分类批量修改接口
This commit is contained in:
@@ -24,11 +24,6 @@ import xyz.playedu.api.types.paginate.ResourcePaginateFilter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
* @description 针对表【resources】的数据库操作Service
|
||||
* @createDate 2023-02-23 10:50:26
|
||||
*/
|
||||
public interface ResourceService extends IService<Resource> {
|
||||
|
||||
PaginationResult<Resource> paginate(int page, int size, ResourcePaginateFilter filter);
|
||||
@@ -58,4 +53,6 @@ public interface ResourceService extends IService<Resource> {
|
||||
Integer total(String type);
|
||||
|
||||
Integer duration(Integer id);
|
||||
|
||||
void categoryChange(List<Integer> ids, Integer categoryId);
|
||||
}
|
||||
|
||||
@@ -155,4 +155,9 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource>
|
||||
}
|
||||
return resourceVideo.getDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void categoryChange(List<Integer> ids, Integer categoryId) {
|
||||
relationService.rebuild(ids, categoryId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,24 +23,26 @@ import xyz.playedu.api.domain.ResourceCategoryRelation;
|
||||
import xyz.playedu.api.mapper.ResourceCategoryRelationMapper;
|
||||
import xyz.playedu.api.service.internal.ResourceCategoryRelationService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
* @description 针对表【resource_category】的数据库操作Service实现
|
||||
* @createDate 2023-03-08 16:54:56
|
||||
*/
|
||||
@Service
|
||||
public class ResourceCategoryRelationServiceImpl
|
||||
extends ServiceImpl<ResourceCategoryRelationMapper, ResourceCategoryRelation>
|
||||
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();
|
||||
public void rebuild(List<Integer> ids, Integer categoryId) {
|
||||
remove(query().getWrapper().in("rid", ids));
|
||||
List<ResourceCategoryRelation> data = new ArrayList<>();
|
||||
ids.forEach(
|
||||
(item) ->
|
||||
data.add(
|
||||
new ResourceCategoryRelation() {
|
||||
{
|
||||
setCid(categoryId);
|
||||
setRid(item);
|
||||
}
|
||||
}));
|
||||
saveBatch(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,6 @@ import xyz.playedu.api.domain.ResourceCategoryRelation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
* @description 针对表【resource_category】的数据库操作Service
|
||||
* @createDate 2023-03-08 16:54:56
|
||||
*/
|
||||
public interface ResourceCategoryRelationService extends IService<ResourceCategoryRelation> {
|
||||
|
||||
List<Integer> getRidsByCids(List<Integer> categoryIds);
|
||||
public void rebuild(List<Integer> ids, Integer categoryId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user