Commit 36271eb4 authored by nie'hong's avatar nie'hong

限制有对应展板的视频删除操作

parent 6b7782fc
......@@ -11,6 +11,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.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -29,6 +30,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
......@@ -61,6 +63,10 @@ public class ExhibitionBoardController extends BaseController {
private AuditService auditService;
@Resource
private AssetService assetService;
@Resource
private LearningContentBoardService learningContentBoardService;
@Resource
private LearningContentService learningContentService;
@PostMapping("/save")
@RequiresAuthentication //@RequiresPermissions("exhibition:board:save")
......@@ -487,6 +493,24 @@ public class ExhibitionBoardController extends BaseController {
@MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.UPPER)
public Map<String, Object> enableExhibitionBoard(@PathVariable("id") String id, @RequestParam("isPublish") Boolean isPublish) {
TUser user = getcurUser();
// 下架一个展板时,该展板对应的学习内容没下架不允许下架该展板
if (!isPublish) {
// 查询该展板对应的所有学习内容的id
LambdaQueryWrapper<LearningContentBoard> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
objectLambdaQueryWrapper.eq(LearningContentBoard::getExhibitionBoardId, id);
List<LearningContentBoard> list = this.learningContentBoardService.list(objectLambdaQueryWrapper);
List<String> collect = list.stream().map(LearningContentBoard::getLearningContentId).collect(Collectors.toList());
// 查询学习内容,判断是否已全部下架
LambdaQueryWrapper<LearningContent> learningContentLambdaQueryWrapper = new LambdaQueryWrapper<>();
learningContentLambdaQueryWrapper.in(LearningContent::getId,collect);
List<LearningContent> list1 = this.learningContentService.list(learningContentLambdaQueryWrapper);
for (LearningContent learningContent : list1) {
if (learningContent.getPublished()) {
return getFailResult("该展板所在学习内容未下架,展板不能被下架!");
}
}
}
final ExhibitionBoard exhibitionBoard = this.exhibitionBoardService.getById(id);
final Audit audit = Audit.builder()
.userId(user.getId())
......
......@@ -10,6 +10,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.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -362,6 +363,11 @@ public class VideoContentController extends BaseController {
})
@MethodLog(operModule = OperModule.VIDEOCONTENT, operType = OperType.DELETE)
public Map<String, Object> deleteVideoContent(@PathVariable("id") String id) {
// 视频关联展板时视频不能被删除
final List<ExhibitionBoard> exhibitionBoardList = this.exhibitionBoardService.list(Wrappers.<ExhibitionBoard>lambdaQuery().eq(ExhibitionBoard::getVideoContentId, id));
if (CollectionUtil.isNotEmpty(exhibitionBoardList)) {
return getFailResult("该视频有对应的展板信息,不能够被删除!");
}
final VideoContent videoContent = this.videoContentService.getById(id);
final Audit audit = Audit.builder()
.content(videoContent.getName())
......
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