Commit 6b7782fc authored by nie'hong's avatar nie'hong

限制展板分类和视频分类在使用时不能被删除

parent 516e9bd6
......@@ -13,6 +13,7 @@ import cn.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
......@@ -202,15 +203,24 @@ public class ExhibitionBoardCatController extends BaseController {
})
@MethodLog(operModule = OperModule.DISPLAYCLASSIFY, operType = OperType.DELETE)
public Map<String, Object> deleteExhibitionBoardCat(@PathVariable("id") String id) {
this.exhibitionBoardCatService.removeById(id);
// 该展板在被使用时,不能被删除
LambdaUpdateWrapper<CopyrightOwnerBoardCat> copyrightOwnerBoardCatLambdaUpdateWrapper = Wrappers.<CopyrightOwnerBoardCat>lambdaUpdate().eq(CopyrightOwnerBoardCat::getBoardCatId, id);
List<CopyrightOwnerBoardCat> list = this.copyrightOwnerBoardCatService.list(copyrightOwnerBoardCatLambdaUpdateWrapper);
if (CollectionUtils.isNotEmpty(list)) {
return getFailResult("该展板分类正在被使用,不能删除!");
}
// 删除展板分类信息
this.exhibitionBoardCatService.removeById(id);
// 删除版权方展板分类信息
this.copyrightOwnerBoardCatService.remove(copyrightOwnerBoardCatLambdaUpdateWrapper);
final LambdaQueryWrapper<ExhibitionBoard> exhibitionBoardLambdaQueryWrapper = Wrappers.<ExhibitionBoard>lambdaQuery().eq(ExhibitionBoard::getExhibitionBoardCatId, id).select(ExhibitionBoard::getId);
final List<String> exhibitionBoardIdList = this.exhibitionBoardService.listObjs(exhibitionBoardLambdaQueryWrapper, Object::toString);
if (exhibitionBoardIdList != null && !exhibitionBoardIdList.isEmpty()) {
// 删除该展板分类下得展板信息
this.exhibitionBoardService.removeByIds(exhibitionBoardIdList);
// 删除该展板
this.assetService.remove(Wrappers.<Asset>lambdaUpdate().in(Asset::getRefItemId, exhibitionBoardIdList));
final LambdaQueryWrapper<LearningContentBoard> learningContentBoardLambdaQueryWrapper = Wrappers.<LearningContentBoard>lambdaQuery().in(LearningContentBoard::getExhibitionBoardCatId, exhibitionBoardIdList);
......
......@@ -8,6 +8,7 @@ import cn.chnmuseum.party.common.vo.GenericPageParam;
import cn.chnmuseum.party.model.*;
import cn.chnmuseum.party.service.*;
import cn.chnmuseum.party.web.controller.base.BaseController;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
......@@ -182,9 +183,15 @@ public class VideoContentCatController extends BaseController {
})
@MethodLog(operModule = OperModule.VIDEOCLASSIFY, operType = OperType.DELETE)
public Map<String, Object> deleteVideoContentCat(@PathVariable("id") String id) {
this.videoContentCatService.removeById(id);
// 该视频分类正在被使用时,不能被删除
final LambdaUpdateWrapper<CopyrightOwnerVideoContentCat> updateWrapper1 = Wrappers.<CopyrightOwnerVideoContentCat>lambdaUpdate().eq(CopyrightOwnerVideoContentCat::getVideoContentCatId, id);
List<CopyrightOwnerVideoContentCat> list = this.copyrightOwnerVideoContentCatService.list(updateWrapper1);
if (CollectionUtil.isNotEmpty(list)) {
return getFailResult("该视频分类正在被使用,不能删除");
}
// 删除视频分类信息
this.videoContentCatService.removeById(id);
// 删除版权方和视频分类对应信息
this.copyrightOwnerVideoContentCatService.remove(updateWrapper1);
final LambdaQueryWrapper<VideoContent> lambdaQueryWrapper = Wrappers.<VideoContent>lambdaQuery().eq(VideoContent::getVideoContentCatId, id).select(VideoContent::getId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment