CopyrightOwnerController.java 25 KB
Newer Older
liqin's avatar
liqin committed
1
package cn.chnmuseum.party.web.controller;
liqin's avatar
liqin committed
2

liqin's avatar
liqin committed
3 4 5 6 7 8 9 10 11 12 13
import cn.chnmuseum.party.common.enums.CopyrightOwnerTypeEnum;
import cn.chnmuseum.party.common.log.MethodLog;
import cn.chnmuseum.party.common.log.OperModule;
import cn.chnmuseum.party.common.log.OperType;
import cn.chnmuseum.party.common.util.TimeUtils;
import cn.chnmuseum.party.common.validator.groups.Add;
import cn.chnmuseum.party.common.validator.groups.Update;
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;
liqin's avatar
liqin committed
14 15 16 17 18 19 20 21 22 23
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
wzp's avatar
wzp committed
24
import org.apache.shiro.authz.annotation.RequiresAuthentication;
liqin's avatar
liqin committed
25 26 27 28
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
liqin's avatar
liqin committed
29
import java.util.ArrayList;
liqin's avatar
liqin committed
30 31
import java.util.List;
import java.util.Map;
liqin's avatar
liqin committed
32
import java.util.stream.Collectors;
liqin's avatar
liqin committed
33 34

/**
liqin's avatar
liqin committed
35
 * <pre>
liqin's avatar
liqin committed
36
 * 版权方 前端控制器
liqin's avatar
liqin committed
37
 * </pre>
liqin's avatar
liqin committed
38 39
 *
 * @author Danny Lee
liqin's avatar
liqin committed
40
 * @since 2021-03-17
liqin's avatar
liqin committed
41
 */
liqin's avatar
liqin committed
42
@Slf4j
liqin's avatar
liqin committed
43
@RestController
liqin's avatar
liqin committed
44
@RequestMapping("/copyrightOwner")
liqin's avatar
liqin committed
45
@Api(tags = {"版权方接口"})
liqin's avatar
liqin committed
46 47
public class CopyrightOwnerController extends BaseController {

liqin's avatar
liqin committed
48 49 50
    @Resource
    private CopyrightOwnerService copyrightOwnerService;
    @Resource
liqin's avatar
liqin committed
51
    private VideoContentCatService videoContentCatService;
liqin's avatar
liqin committed
52 53
    @Resource
    private VideoContentService videoContentService;
liqin's avatar
liqin committed
54
    @Resource
liqin's avatar
liqin committed
55
    private CopyrightOwnerVideoContentCatService copyrightOwnerVideoContentCatService;
liqin's avatar
liqin committed
56 57 58 59
    @Resource
    private CopyrightOwnerBoardCatService copyrightOwnerBoardCatService;
    @Resource
    private ExhibitionBoardCatService exhibitionBoardCatService;
liqin's avatar
liqin committed
60 61
    @Resource
    private ExhibitionBoardService exhibitionBoardService;
liqin's avatar
liqin committed
62 63
    @Resource
    private LearningContentCopyrightOwnerService learningContentCopyrightOwnerService;
liqin's avatar
liqin committed
64 65
    @Resource
    private LearningContentService learningContentService;
liqin's avatar
liqin committed
66 67 68 69
    @Resource
    private LearningContentBoardService learningContentBoardService;
    @Resource
    private LearningContentBoardCatService learningContentBoardCatService;
liqin's avatar
liqin committed
70 71
    @Resource
    private AssetService assetService;
liqin's avatar
liqin committed
72

liqin's avatar
liqin committed
73
    @PostMapping("/save")
wzp's avatar
wzp committed
74
    @RequiresAuthentication  //@RequiresPermissions("copyright:owner:save")
liqin's avatar
liqin committed
75
    @ApiOperation(value = "添加版权方", notes = "添加版权方")
wzp's avatar
wzp committed
76
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.ADD)
liqin's avatar
liqin committed
77
    public Map<String, Object> saveCopyrightOwner(@Validated(value = {Add.class}) CopyrightOwner copyrightOwner) {
liqin's avatar
liqin committed
78 79 80 81 82 83
        final LambdaQueryWrapper<CopyrightOwner> lambdaQueryWrapper = Wrappers.<CopyrightOwner>lambdaQuery().eq(CopyrightOwner::getName, copyrightOwner.getName().trim());
        lambdaQueryWrapper.eq(CopyrightOwner::getOwnerType, copyrightOwner.getOwnerType().trim());
        final int count = this.copyrightOwnerService.count(lambdaQueryWrapper);
        if (count > 0) {
            return getFailResult("400", "名称已存在,请修改名称");
        }
liqin's avatar
liqin committed
84
        boolean result = copyrightOwnerService.save(copyrightOwner);
liqin's avatar
liqin committed
85

liqin's avatar
liqin committed
86 87 88 89 90 91
        final List<String> videoContentCatIdList = copyrightOwner.getVideoContentCatIdList();
        if (videoContentCatIdList != null && !videoContentCatIdList.isEmpty()) {
            List<CopyrightOwnerVideoContentCat> copyrightOwnerVideoContentCatList = new ArrayList<>();
            for (String videoContentCatId : videoContentCatIdList) {
                copyrightOwnerVideoContentCatList.add(CopyrightOwnerVideoContentCat.builder()
                        .videoContentCatId(videoContentCatId)
liqin's avatar
liqin committed
92 93 94
                        .copyrightOwnerId(copyrightOwner.getId())
                        .build());
            }
liqin's avatar
liqin committed
95
            this.copyrightOwnerVideoContentCatService.saveBatch(copyrightOwnerVideoContentCatList);
liqin's avatar
liqin committed
96 97
        }

liqin's avatar
liqin committed
98 99 100 101 102 103 104 105 106 107 108 109
        final List<String> boardCatIdList = copyrightOwner.getBoardCatIdList();
        if (boardCatIdList != null && !boardCatIdList.isEmpty()) {
            List<CopyrightOwnerBoardCat> copyrightOwnerBoardCatList = new ArrayList<>();
            for (String boardCatId : boardCatIdList) {
                copyrightOwnerBoardCatList.add(CopyrightOwnerBoardCat.builder()
                        .boardCatId(boardCatId)
                        .copyrightOwnerId(copyrightOwner.getId())
                        .build());
            }
            this.copyrightOwnerBoardCatService.saveBatch(copyrightOwnerBoardCatList);
        }

liqin's avatar
liqin committed
110 111 112 113 114 115 116 117 118 119
        // 返回操作结果
        if (result) {
            return getSuccessResult();
        } else {
            // 保存失败
            return getFailResult();
        }
    }

    @PutMapping("/update")
wzp's avatar
wzp committed
120
    @RequiresAuthentication  //@RequiresPermissions("copyright:owner:update")
liqin's avatar
liqin committed
121
    @ApiOperation(value = "修改版权方信息", notes = "修改版权方信息")
wzp's avatar
wzp committed
122
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.UPDATE)
liqin's avatar
liqin committed
123
    public Map<String, Object> updateCopyrightOwner(@Validated(value = {Update.class}) CopyrightOwner copyrightOwner) {
liqin's avatar
liqin committed
124 125
        final LambdaQueryWrapper<CopyrightOwner> lambdaQueryWrapper = Wrappers.<CopyrightOwner>lambdaQuery().eq(CopyrightOwner::getName, copyrightOwner.getName().trim());
        lambdaQueryWrapper.eq(CopyrightOwner::getOwnerType, copyrightOwner.getOwnerType().trim());
liqin's avatar
liqin committed
126
        lambdaQueryWrapper.ne(CopyrightOwner::getId, copyrightOwner.getId());
liqin's avatar
liqin committed
127 128 129 130
        final int count = this.copyrightOwnerService.count(lambdaQueryWrapper);
        if (count > 0) {
            return getFailResult("400", "名称已存在,请修改名称");
        }
liqin's avatar
liqin committed
131
        boolean flag = copyrightOwnerService.updateById(copyrightOwner);
liqin's avatar
liqin committed
132

liqin's avatar
liqin committed
133 134 135 136
        final List<String> videoContentCatIdList = copyrightOwner.getVideoContentCatIdList();
        if (videoContentCatIdList != null && !videoContentCatIdList.isEmpty()) {
            LambdaUpdateWrapper<CopyrightOwnerVideoContentCat> updateWrapper = Wrappers.<CopyrightOwnerVideoContentCat>lambdaUpdate().eq(CopyrightOwnerVideoContentCat::getCopyrightOwnerId, copyrightOwner.getId());
            this.copyrightOwnerVideoContentCatService.remove(updateWrapper);
liqin's avatar
liqin committed
137

liqin's avatar
liqin committed
138 139 140 141
            List<CopyrightOwnerVideoContentCat> copyrightOwnerVideoContentCatList = new ArrayList<>();
            for (String videoContentCatId : videoContentCatIdList) {
                copyrightOwnerVideoContentCatList.add(CopyrightOwnerVideoContentCat.builder()
                        .videoContentCatId(videoContentCatId)
liqin's avatar
liqin committed
142 143 144
                        .copyrightOwnerId(copyrightOwner.getId())
                        .build());
            }
liqin's avatar
liqin committed
145
            this.copyrightOwnerVideoContentCatService.saveBatch(copyrightOwnerVideoContentCatList);
liqin's avatar
liqin committed
146
        }
liqin's avatar
liqin committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162

        final List<String> boardCatIdList = copyrightOwner.getBoardCatIdList();
        if (boardCatIdList != null && !boardCatIdList.isEmpty()) {
            LambdaUpdateWrapper<CopyrightOwnerBoardCat> updateWrapper = Wrappers.<CopyrightOwnerBoardCat>lambdaUpdate().eq(CopyrightOwnerBoardCat::getCopyrightOwnerId, copyrightOwner.getId());
            this.copyrightOwnerBoardCatService.remove(updateWrapper);

            List<CopyrightOwnerBoardCat> copyrightOwnerBoardCatList = new ArrayList<>();
            for (String boardCatId : boardCatIdList) {
                copyrightOwnerBoardCatList.add(CopyrightOwnerBoardCat.builder()
                        .boardCatId(boardCatId)
                        .copyrightOwnerId(copyrightOwner.getId())
                        .build());
            }
            this.copyrightOwnerBoardCatService.saveBatch(copyrightOwnerBoardCatList);
        }

liqin's avatar
liqin committed
163 164 165 166 167 168
        if (flag) {
            return getSuccessResult();
        }
        return getFailResult();
    }

liqin's avatar
liqin committed
169 170 171
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "copyrightOwnerType", value = "版权方类型", paramType = "query", dataType = "String", required = true)
    })
liqin's avatar
liqin committed
172
    @GetMapping("/getList")
wzp's avatar
wzp committed
173
    @RequiresAuthentication  //@RequiresPermissions("copyright:owner:list")
liqin's avatar
liqin committed
174
    @ApiOperation(value = "获取版权方全部列表(无分页)", notes = "获取版权方全部列表(无分页)")
wzp's avatar
wzp committed
175
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.SELECT)
liqin's avatar
liqin committed
176 177
    public Map<String, Object> getCopyrightOwnerList(@RequestParam("copyrightOwnerType") CopyrightOwnerTypeEnum copyrightOwnerTypeEnum) {
        LambdaQueryWrapper<CopyrightOwner> lambdaQueryWrapper = Wrappers.<CopyrightOwner>lambdaQuery().eq(CopyrightOwner::getOwnerType, copyrightOwnerTypeEnum.name());
178
        lambdaQueryWrapper.le(CopyrightOwner::getExpireDateStart, TimeUtils.getDateTimeOfTimestamp(System.currentTimeMillis()).toLocalDate()).ge(CopyrightOwner::getExpireDateEnd, TimeUtils.getDateTimeOfTimestamp(System.currentTimeMillis()).toLocalDate());
liqin's avatar
liqin committed
179
        lambdaQueryWrapper.orderByDesc(CopyrightOwner::getCreateTime);
liqin's avatar
liqin committed
180
        List<CopyrightOwner> copyrightOwnerList = copyrightOwnerService.list(lambdaQueryWrapper);
liqin's avatar
liqin committed
181 182 183 184 185 186
        return getResult(copyrightOwnerList);
    }

    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
liqin's avatar
liqin committed
187
            @ApiImplicitParam(name = "ownerType", value = "版权方类型", paramType = "query", dataType = "String", required = true, allowableValues = "VIDEO_CONTENT, EXHIBITION_BOARD"),
liqin's avatar
liqin committed
188 189 190 191 192
            @ApiImplicitParam(name = "nameOrCode", value = "名称或编码", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "startDate", value = "创建时间-开始", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String")
    })
    @PostMapping("/getPageList")
wzp's avatar
wzp committed
193
    @RequiresAuthentication  //@RequiresPermissions("copyright:owner:page")
liqin's avatar
liqin committed
194
    @ApiOperation(value = "获取版权方分页列表", notes = "获取版权方分页列表")
wzp's avatar
wzp committed
195
    @MethodLog(operModule = OperModule.VIDEOCOPYRIGHT, operType = OperType.SELECT)
liqin's avatar
liqin committed
196 197
    public Map<String, Object> getCopyrightOwnerPageList(GenericPageParam genericPageParam) {
        LambdaQueryWrapper<CopyrightOwner> queryWrapper = new LambdaQueryWrapper<>();
liqin's avatar
liqin committed
198
        queryWrapper.eq(CopyrightOwner::getOwnerType, genericPageParam.getOwnerType());
liqin's avatar
liqin committed
199 200 201 202 203 204
        // 对名称或编码模糊查询
        if (StringUtils.isNotBlank(genericPageParam.getNameOrCode())) {
            queryWrapper.like(CopyrightOwner::getName, genericPageParam.getNameOrCode());
        }
        // 根据创建时间区间检索
        if (genericPageParam.getStartDate() != null && genericPageParam.getEndDate() != null) {
liqin's avatar
liqin committed
205 206
            queryWrapper.ge(CopyrightOwner::getExpireDateStart, genericPageParam.getStartDate().atTime(0, 0, 0))
                    .le(CopyrightOwner::getExpireDateEnd, genericPageParam.getEndDate().atTime(23, 59, 59));
liqin's avatar
liqin committed
207 208 209 210 211 212 213
        }
        // 设置排序规则
        queryWrapper.orderByDesc(CopyrightOwner::getCreateTime);
        // 设置查询内容
        queryWrapper.select(
                CopyrightOwner::getId,
                CopyrightOwner::getName,
liqin's avatar
liqin committed
214
                CopyrightOwner::getOwnerType,
liqin's avatar
liqin committed
215 216 217
                CopyrightOwner::getExpireDateStart,
                CopyrightOwner::getExpireDateEnd,
                CopyrightOwner::getRemarks,
liqin's avatar
liqin committed
218 219 220 221
                CopyrightOwner::getCreateTime,
                CopyrightOwner::getUpdateTime);
        Page<CopyrightOwner> page = this.copyrightOwnerService.page(getPage(), queryWrapper);
        for (CopyrightOwner copyrightOwner : page.getRecords()) {
liqin's avatar
liqin committed
222 223 224
            if (CopyrightOwnerTypeEnum.VIDEO_CONTENT.name().equals(genericPageParam.getOwnerType())) {
                List<CopyrightOwnerVideoContentCat> copyrightOwnerVideoContentCatList = this.copyrightOwnerVideoContentCatService.list(Wrappers.<CopyrightOwnerVideoContentCat>lambdaQuery().eq(CopyrightOwnerVideoContentCat::getCopyrightOwnerId, copyrightOwner.getId()));
                if (!copyrightOwnerVideoContentCatList.isEmpty()) {
liqin's avatar
liqin committed
225
                    final List<String> idList = copyrightOwnerVideoContentCatList.stream().map(CopyrightOwnerVideoContentCat::getVideoContentCatId).distinct().collect(Collectors.toList());
liqin's avatar
liqin committed
226 227 228
                    List<VideoContentCat> videoContentCatList = this.videoContentCatService.listByIds(idList);
                    String videoContentCatNames = videoContentCatList.stream().map(VideoContentCat::getName).collect(Collectors.joining("、"));
                    copyrightOwner.setVideoContentCatNames(videoContentCatNames);
liqin's avatar
liqin committed
229
                }
liqin's avatar
liqin committed
230
            } else if (CopyrightOwnerTypeEnum.EXHIBITION_BOARD.name().equals(genericPageParam.getOwnerType())) {
liqin's avatar
liqin committed
231 232 233 234 235 236
                final List<CopyrightOwnerBoardCat> copyrightOwnerBoardCatList = this.copyrightOwnerBoardCatService.list(Wrappers.<CopyrightOwnerBoardCat>lambdaQuery().eq(CopyrightOwnerBoardCat::getCopyrightOwnerId, copyrightOwner.getId()));
                if (!copyrightOwnerBoardCatList.isEmpty()) {
                    List<String> idList = copyrightOwnerBoardCatList.stream().map(CopyrightOwnerBoardCat::getBoardCatId).distinct().collect(Collectors.toList());
                    final List<ExhibitionBoardCat> exhibitionBoardCatList = this.exhibitionBoardCatService.listByIds(idList);
                    final String exhibitionBoardCatNames = exhibitionBoardCatList.stream().map(ExhibitionBoardCat::getName).collect(Collectors.joining("、"));
                    copyrightOwner.setBoardCatNames(exhibitionBoardCatNames);
liqin's avatar
liqin committed
237
                }
liqin's avatar
liqin committed
238
            }
liqin's avatar
liqin committed
239 240 241 242 243 244 245 246 247
        }
        return getResult(page);
    }

    @ApiOperation(value = "获取版权方详情", notes = "获取版权方详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path")
    })
    @GetMapping("/get/{id}")
wzp's avatar
wzp committed
248
    @RequiresAuthentication  //@RequiresPermissions("copyright:owner:get:id")
wzp's avatar
wzp committed
249
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.DETAILS)
liqin's avatar
liqin committed
250 251
    public Map<String, Object> getById(@PathVariable("id") String id) {
        CopyrightOwner copyrightOwner = copyrightOwnerService.getById(id);
liqin's avatar
liqin committed
252
        String ownerType = copyrightOwner.getOwnerType();
liqin's avatar
liqin committed
253 254 255 256 257 258 259
        if (CopyrightOwnerTypeEnum.VIDEO_CONTENT.name().equals(ownerType)) {
            LambdaQueryWrapper<CopyrightOwnerVideoContentCat> lambdaQueryWrapper = Wrappers.<CopyrightOwnerVideoContentCat>lambdaQuery().eq(CopyrightOwnerVideoContentCat::getCopyrightOwnerId, id);
            final List<CopyrightOwnerVideoContentCat> copyrightOwnerVideoContentCatList = this.copyrightOwnerVideoContentCatService.list(lambdaQueryWrapper);
            if (!copyrightOwnerVideoContentCatList.isEmpty()) {
                List<String> videoContentCatIdList = copyrightOwnerVideoContentCatList.stream().map(CopyrightOwnerVideoContentCat::getVideoContentCatId).distinct().collect(Collectors.toList());
                copyrightOwner.setVideoContentCatIdList(videoContentCatIdList);
                final List<VideoContentCat> videoContentCatList = this.videoContentCatService.listByIds(videoContentCatIdList);
liqin's avatar
liqin committed
260
                if (!videoContentCatList.isEmpty()) {
liqin's avatar
liqin committed
261 262
                    final List<String> videoContentCatNameList = videoContentCatList.stream().map(VideoContentCat::getName).collect(Collectors.toList());
                    copyrightOwner.setVideoContentCatNameList(videoContentCatNameList);
liqin's avatar
liqin committed
263 264 265
                }
            }
        }
liqin's avatar
liqin committed
266 267 268 269 270 271 272 273 274 275 276 277
        if (CopyrightOwnerTypeEnum.EXHIBITION_BOARD.name().equals(ownerType)) {
            final List<CopyrightOwnerBoardCat> copyrightOwnerBoardCatList = this.copyrightOwnerBoardCatService.list(Wrappers.<CopyrightOwnerBoardCat>lambdaQuery().eq(CopyrightOwnerBoardCat::getCopyrightOwnerId, id));
            if (!copyrightOwnerBoardCatList.isEmpty()) {
                final List<String> boardCatIdList = copyrightOwnerBoardCatList.stream().map(CopyrightOwnerBoardCat::getBoardCatId).distinct().collect(Collectors.toList());
                copyrightOwner.setBoardCatIdList(boardCatIdList);
                final List<ExhibitionBoardCat> exhibitionBoardCatList = this.exhibitionBoardCatService.listByIds(boardCatIdList);
                if (!exhibitionBoardCatList.isEmpty()) {
                    final List<String> exhibitionBoardCatNameList = exhibitionBoardCatList.stream().map(ExhibitionBoardCat::getName).collect(Collectors.toList());
                    copyrightOwner.setBoardCatNameList(exhibitionBoardCatNameList);
                }
            }
        }
liqin's avatar
liqin committed
278

liqin's avatar
liqin committed
279 280 281
        return getResult(copyrightOwner);
    }

liqin's avatar
liqin committed
282 283 284 285 286 287
    @DeleteMapping("/delete/{id}")
    @RequiresAuthentication  //@RequiresPermissions("exhibition:board:cat:delete")
    @ApiOperation(value = "根据ID删除版权方", notes = "根据ID删除版权方")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
    })
wzp's avatar
wzp committed
288
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.DELETE)
liqin's avatar
liqin committed
289 290
    public Map<String, Object> deleteCopyrightOwner(@PathVariable("id") String id) {
        this.copyrightOwnerService.removeById(id);
liqin's avatar
liqin committed
291

liqin's avatar
liqin committed
292 293 294 295 296
        LambdaUpdateWrapper<CopyrightOwnerBoardCat> copyrightOwnerBoardCatLambdaUpdateWrapper = Wrappers.<CopyrightOwnerBoardCat>lambdaUpdate().eq(CopyrightOwnerBoardCat::getCopyrightOwnerId, id);
        this.copyrightOwnerBoardCatService.remove(copyrightOwnerBoardCatLambdaUpdateWrapper);

        LambdaUpdateWrapper<CopyrightOwnerVideoContentCat> copyrightOwnerVideoContentCatLambdaUpdateWrapper = Wrappers.<CopyrightOwnerVideoContentCat>lambdaUpdate().eq(CopyrightOwnerVideoContentCat::getCopyrightOwnerId, id);
        this.copyrightOwnerVideoContentCatService.remove(copyrightOwnerVideoContentCatLambdaUpdateWrapper);
liqin's avatar
liqin committed
297

liqin's avatar
liqin committed
298 299 300 301 302
        final LambdaQueryWrapper<VideoContent> videoContentLambdaQueryWrapper = Wrappers.<VideoContent>lambdaQuery().eq(VideoContent::getVideoContentCopyrightOwnerId, id).select(VideoContent::getId);
        final List<String> videoContentIdList = this.videoContentService.listObjs(videoContentLambdaQueryWrapper, Object::toString);
        if (videoContentIdList != null && !videoContentIdList.isEmpty()) {
            this.videoContentService.removeByIds(videoContentIdList);
            this.assetService.remove(Wrappers.<Asset>lambdaUpdate().in(Asset::getRefItemId, videoContentIdList));
liqin's avatar
liqin committed
303

liqin's avatar
liqin committed
304 305 306 307 308
            final LambdaQueryWrapper<ExhibitionBoard> exhibitionBoardLambdaQueryWrapper = Wrappers.<ExhibitionBoard>lambdaQuery().in(ExhibitionBoard::getVideoContentId, videoContentIdList).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));
liqin's avatar
liqin committed
309

liqin's avatar
liqin committed
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
                final LambdaQueryWrapper<LearningContentBoard> learningContentBoardLambdaQueryWrapper = Wrappers.<LearningContentBoard>lambdaQuery().in(LearningContentBoard::getExhibitionBoardCatId, ExhibitionBoardIdList);
                final List<LearningContentBoard> learningContentBoardList = this.learningContentBoardService.list(learningContentBoardLambdaQueryWrapper);
                if (learningContentBoardList != null && !learningContentBoardList.isEmpty()) {
                    final Map<String, List<String>> collect = learningContentBoardList.stream().collect(Collectors.groupingBy(LearningContentBoard::getLearningContentId, Collectors.mapping(LearningContentBoard::getExhibitionBoardId, Collectors.toList())));
                    collect.forEach((k, v) -> {
                        if (v.size() == 1) {
                            this.learningContentService.removeById(k);
                            this.learningContentBoardService.remove(Wrappers.<LearningContentBoard>lambdaUpdate().eq(LearningContentBoard::getLearningContentId, k));
                            this.learningContentBoardCatService.remove(Wrappers.<LearningContentBoardCat>lambdaUpdate().eq(LearningContentBoardCat::getLearningContentId, k));
                            this.learningContentCopyrightOwnerService.remove(Wrappers.<LearningContentCopyrightOwner>lambdaUpdate().eq(LearningContentCopyrightOwner::getLearningContentId, k));
                        }
                    });
                    LambdaUpdateWrapper<LearningContentBoard> deleteWrapper1 = Wrappers.<LearningContentBoard>lambdaUpdate().in(LearningContentBoard::getExhibitionBoardId, ExhibitionBoardIdList);
                    this.learningContentBoardService.remove(deleteWrapper1);
                }
            }
        }

        final LambdaQueryWrapper<ExhibitionBoard> exhibitionBoardLambdaQueryWrapper = Wrappers.<ExhibitionBoard>lambdaQuery().eq(ExhibitionBoard::getBoardCopyrightOwnerId, 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);
            final List<LearningContentBoard> learningContentBoardList = this.learningContentBoardService.list(learningContentBoardLambdaQueryWrapper);
            if (learningContentBoardList != null && !learningContentBoardList.isEmpty()) {
                final Map<String, List<String>> collect = learningContentBoardList.stream().collect(Collectors.groupingBy(LearningContentBoard::getLearningContentId, Collectors.mapping(LearningContentBoard::getExhibitionBoardId, Collectors.toList())));
                collect.forEach((k, v) -> {
                    if (v.size() == 1) {
                        this.learningContentService.removeById(k);
                        this.learningContentBoardService.remove(Wrappers.<LearningContentBoard>lambdaUpdate().eq(LearningContentBoard::getLearningContentId, k));
                        this.learningContentBoardCatService.remove(Wrappers.<LearningContentBoardCat>lambdaUpdate().eq(LearningContentBoardCat::getLearningContentId, k));
                        this.learningContentCopyrightOwnerService.remove(Wrappers.<LearningContentCopyrightOwner>lambdaUpdate().eq(LearningContentCopyrightOwner::getLearningContentId, k));
                    }
                });
                LambdaUpdateWrapper<LearningContentBoard> learningContentBoardLambdaUpdateWrapper = Wrappers.<LearningContentBoard>lambdaUpdate().in(LearningContentBoard::getExhibitionBoardId, exhibitionBoardIdList);
                this.learningContentBoardService.remove(learningContentBoardLambdaUpdateWrapper);
            }
        }
liqin's avatar
liqin committed
350

liqin's avatar
liqin committed
351 352 353
        final LambdaQueryWrapper<LearningContentCopyrightOwner> learningContentCopyrightOwnerLambdaQueryWrapper = Wrappers.<LearningContentCopyrightOwner>lambdaQuery().eq(LearningContentCopyrightOwner::getCopyrightOwnerId, id);
        final List<LearningContentCopyrightOwner> learningContentCopyrightOwnerList = this.learningContentCopyrightOwnerService.list(learningContentCopyrightOwnerLambdaQueryWrapper);
        if (learningContentCopyrightOwnerList != null && !learningContentCopyrightOwnerList.isEmpty()) {
liqin's avatar
liqin committed
354
            final Map<String, List<String>> collect = learningContentCopyrightOwnerList.stream().collect(Collectors.groupingBy(LearningContentCopyrightOwner::getLearningContentId, Collectors.mapping(LearningContentCopyrightOwner::getCopyrightOwnerId, Collectors.toList())));
liqin's avatar
liqin committed
355
            collect.forEach((k, v) -> {
liqin's avatar
liqin committed
356 357
                if (v.size() == 1) {
                    this.learningContentService.removeById(k);
liqin's avatar
liqin committed
358 359 360
                    this.learningContentBoardService.remove(Wrappers.<LearningContentBoard>lambdaUpdate().eq(LearningContentBoard::getLearningContentId, k));
                    this.learningContentBoardCatService.remove(Wrappers.<LearningContentBoardCat>lambdaUpdate().eq(LearningContentBoardCat::getLearningContentId, k));
                    this.learningContentCopyrightOwnerService.remove(Wrappers.<LearningContentCopyrightOwner>lambdaUpdate().eq(LearningContentCopyrightOwner::getLearningContentId, k));
liqin's avatar
liqin committed
361 362
                }
            });
liqin's avatar
liqin committed
363 364
            LambdaUpdateWrapper<LearningContentCopyrightOwner> learningContentCopyrightOwnerLambdaUpdateWrapper = Wrappers.<LearningContentCopyrightOwner>lambdaUpdate().eq(LearningContentCopyrightOwner::getCopyrightOwnerId, id);
            this.learningContentCopyrightOwnerService.remove(learningContentCopyrightOwnerLambdaUpdateWrapper);
liqin's avatar
liqin committed
365
        }
liqin's avatar
liqin committed
366

liqin's avatar
liqin committed
367 368 369
        return getSuccessResult();
    }

liqin's avatar
liqin committed
370 371
}