CopyrightOwnerController.java 26 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;
14
import cn.hutool.core.collection.CollectionUtil;
liqin's avatar
liqin committed
15 16 17 18 19 20 21 22 23 24
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
25
import org.apache.shiro.authz.annotation.RequiresAuthentication;
liqin's avatar
liqin committed
26 27 28 29
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

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

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

liqin's avatar
liqin committed
74
    @PostMapping("/save")
wzp's avatar
wzp committed
75
    @RequiresAuthentication  //@RequiresPermissions("copyright:owner:save")
liqin's avatar
liqin committed
76
    @ApiOperation(value = "添加版权方", notes = "添加版权方")
wzp's avatar
wzp committed
77
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.ADD)
liqin's avatar
liqin committed
78
    public Map<String, Object> saveCopyrightOwner(@Validated(value = {Add.class}) CopyrightOwner copyrightOwner) {
liqin's avatar
liqin committed
79 80 81 82 83 84
        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
85
        boolean result = copyrightOwnerService.save(copyrightOwner);
liqin's avatar
liqin committed
86

liqin's avatar
liqin committed
87 88 89 90 91 92
        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
93 94 95
                        .copyrightOwnerId(copyrightOwner.getId())
                        .build());
            }
liqin's avatar
liqin committed
96
            this.copyrightOwnerVideoContentCatService.saveBatch(copyrightOwnerVideoContentCatList);
liqin's avatar
liqin committed
97 98
        }

liqin's avatar
liqin committed
99 100 101 102 103 104 105 106 107 108 109 110
        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
111 112 113 114 115 116 117 118 119 120
        // 返回操作结果
        if (result) {
            return getSuccessResult();
        } else {
            // 保存失败
            return getFailResult();
        }
    }

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

liqin's avatar
liqin committed
134 135 136 137
        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
138

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

        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
164 165 166 167 168 169
        if (flag) {
            return getSuccessResult();
        }
        return getFailResult();
    }

liqin's avatar
liqin committed
170 171 172
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "copyrightOwnerType", value = "版权方类型", paramType = "query", dataType = "String", required = true)
    })
liqin's avatar
liqin committed
173
    @GetMapping("/getList")
wzp's avatar
wzp committed
174
    @RequiresAuthentication  //@RequiresPermissions("copyright:owner:list")
liqin's avatar
liqin committed
175
    @ApiOperation(value = "获取版权方全部列表(无分页)", notes = "获取版权方全部列表(无分页)")
wzp's avatar
wzp committed
176
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.SELECT)
liqin's avatar
liqin committed
177 178
    public Map<String, Object> getCopyrightOwnerList(@RequestParam("copyrightOwnerType") CopyrightOwnerTypeEnum copyrightOwnerTypeEnum) {
        LambdaQueryWrapper<CopyrightOwner> lambdaQueryWrapper = Wrappers.<CopyrightOwner>lambdaQuery().eq(CopyrightOwner::getOwnerType, copyrightOwnerTypeEnum.name());
179
        lambdaQueryWrapper.le(CopyrightOwner::getExpireDateStart, TimeUtils.getDateTimeOfTimestamp(System.currentTimeMillis()).toLocalDate()).ge(CopyrightOwner::getExpireDateEnd, TimeUtils.getDateTimeOfTimestamp(System.currentTimeMillis()).toLocalDate());
liqin's avatar
liqin committed
180
        lambdaQueryWrapper.orderByDesc(CopyrightOwner::getCreateTime);
liqin's avatar
liqin committed
181
        List<CopyrightOwner> copyrightOwnerList = copyrightOwnerService.list(lambdaQueryWrapper);
liqin's avatar
liqin committed
182 183 184 185 186 187
        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
188
            @ApiImplicitParam(name = "ownerType", value = "版权方类型", paramType = "query", dataType = "String", required = true, allowableValues = "VIDEO_CONTENT, EXHIBITION_BOARD"),
liqin's avatar
liqin committed
189 190 191 192 193
            @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
194
    @RequiresAuthentication  //@RequiresPermissions("copyright:owner:page")
liqin's avatar
liqin committed
195
    @ApiOperation(value = "获取版权方分页列表", notes = "获取版权方分页列表")
wzp's avatar
wzp committed
196
    @MethodLog(operModule = OperModule.VIDEOCOPYRIGHT, operType = OperType.SELECT)
liqin's avatar
liqin committed
197 198
    public Map<String, Object> getCopyrightOwnerPageList(GenericPageParam genericPageParam) {
        LambdaQueryWrapper<CopyrightOwner> queryWrapper = new LambdaQueryWrapper<>();
liqin's avatar
liqin committed
199
        queryWrapper.eq(CopyrightOwner::getOwnerType, genericPageParam.getOwnerType());
liqin's avatar
liqin committed
200 201 202 203 204 205
        // 对名称或编码模糊查询
        if (StringUtils.isNotBlank(genericPageParam.getNameOrCode())) {
            queryWrapper.like(CopyrightOwner::getName, genericPageParam.getNameOrCode());
        }
        // 根据创建时间区间检索
        if (genericPageParam.getStartDate() != null && genericPageParam.getEndDate() != null) {
liqin's avatar
liqin committed
206 207
            queryWrapper.ge(CopyrightOwner::getExpireDateStart, genericPageParam.getStartDate().atTime(0, 0, 0))
                    .le(CopyrightOwner::getExpireDateEnd, genericPageParam.getEndDate().atTime(23, 59, 59));
liqin's avatar
liqin committed
208 209 210 211 212 213 214
        }
        // 设置排序规则
        queryWrapper.orderByDesc(CopyrightOwner::getCreateTime);
        // 设置查询内容
        queryWrapper.select(
                CopyrightOwner::getId,
                CopyrightOwner::getName,
liqin's avatar
liqin committed
215
                CopyrightOwner::getOwnerType,
liqin's avatar
liqin committed
216 217 218
                CopyrightOwner::getExpireDateStart,
                CopyrightOwner::getExpireDateEnd,
                CopyrightOwner::getRemarks,
liqin's avatar
liqin committed
219 220 221 222
                CopyrightOwner::getCreateTime,
                CopyrightOwner::getUpdateTime);
        Page<CopyrightOwner> page = this.copyrightOwnerService.page(getPage(), queryWrapper);
        for (CopyrightOwner copyrightOwner : page.getRecords()) {
liqin's avatar
liqin committed
223 224 225
            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
226
                    final List<String> idList = copyrightOwnerVideoContentCatList.stream().map(CopyrightOwnerVideoContentCat::getVideoContentCatId).distinct().collect(Collectors.toList());
liqin's avatar
liqin committed
227 228 229
                    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
230
                }
liqin's avatar
liqin committed
231
            } else if (CopyrightOwnerTypeEnum.EXHIBITION_BOARD.name().equals(genericPageParam.getOwnerType())) {
liqin's avatar
liqin committed
232 233 234 235 236 237
                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
238
                }
liqin's avatar
liqin committed
239
            }
liqin's avatar
liqin committed
240 241 242 243 244 245 246 247 248
        }
        return getResult(page);
    }

    @ApiOperation(value = "获取版权方详情", notes = "获取版权方详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path")
    })
    @GetMapping("/get/{id}")
wzp's avatar
wzp committed
249
    @RequiresAuthentication  //@RequiresPermissions("copyright:owner:get:id")
wzp's avatar
wzp committed
250
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.DETAILS)
liqin's avatar
liqin committed
251 252
    public Map<String, Object> getById(@PathVariable("id") String id) {
        CopyrightOwner copyrightOwner = copyrightOwnerService.getById(id);
liqin's avatar
liqin committed
253
        String ownerType = copyrightOwner.getOwnerType();
liqin's avatar
liqin committed
254 255 256 257 258 259 260
        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
261
                if (!videoContentCatList.isEmpty()) {
liqin's avatar
liqin committed
262 263
                    final List<String> videoContentCatNameList = videoContentCatList.stream().map(VideoContentCat::getName).collect(Collectors.toList());
                    copyrightOwner.setVideoContentCatNameList(videoContentCatNameList);
liqin's avatar
liqin committed
264 265 266
                }
            }
        }
liqin's avatar
liqin committed
267 268 269 270 271 272 273 274 275 276 277 278
        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
279

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

liqin's avatar
liqin committed
283 284 285 286 287 288
    @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
289
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.DELETE)
liqin's avatar
liqin committed
290
    public Map<String, Object> deleteCopyrightOwner(@PathVariable("id") String id) {
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
        // 版权方有对应展板信息,则不能被删除
        LambdaQueryWrapper<ExhibitionBoard> exhibitionBoardLambdaQueryWrapper1 = new LambdaQueryWrapper<>();
        exhibitionBoardLambdaQueryWrapper1.eq(ExhibitionBoard::getBoardCopyrightOwnerId, id);
        List<ExhibitionBoard> list = this.exhibitionBoardService.list();
        if (CollectionUtil.isNotEmpty(list)) {
            return getFailResult("该版权方有关联展板信息,无法删除");
        }
        // 版权方有对应视频信息,无法删除
        LambdaQueryWrapper<VideoContent> videoContentLambdaQueryWrapper1 = new LambdaQueryWrapper<>();
        videoContentLambdaQueryWrapper1.eq(VideoContent::getVideoContentCopyrightOwnerId, id);
        List<VideoContent> list1 = this.videoContentService.list(videoContentLambdaQueryWrapper1);
        if (CollectionUtil.isNotEmpty(list1)) {
            return getFailResult("该版权方有关联视频信息,无法删除!");
        }

liqin's avatar
liqin committed
306
        this.copyrightOwnerService.removeById(id);
liqin's avatar
liqin committed
307

liqin's avatar
liqin committed
308 309 310 311 312
        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
313

liqin's avatar
liqin committed
314 315 316 317 318
        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
319

liqin's avatar
liqin committed
320 321 322 323 324
            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
325

liqin's avatar
liqin committed
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
                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
366

liqin's avatar
liqin committed
367 368 369
        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
370
            final Map<String, List<String>> collect = learningContentCopyrightOwnerList.stream().collect(Collectors.groupingBy(LearningContentCopyrightOwner::getLearningContentId, Collectors.mapping(LearningContentCopyrightOwner::getCopyrightOwnerId, Collectors.toList())));
liqin's avatar
liqin committed
371
            collect.forEach((k, v) -> {
liqin's avatar
liqin committed
372 373
                if (v.size() == 1) {
                    this.learningContentService.removeById(k);
liqin's avatar
liqin committed
374 375 376
                    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
377 378
                }
            });
liqin's avatar
liqin committed
379 380
            LambdaUpdateWrapper<LearningContentCopyrightOwner> learningContentCopyrightOwnerLambdaUpdateWrapper = Wrappers.<LearningContentCopyrightOwner>lambdaUpdate().eq(LearningContentCopyrightOwner::getCopyrightOwnerId, id);
            this.learningContentCopyrightOwnerService.remove(learningContentCopyrightOwnerLambdaUpdateWrapper);
liqin's avatar
liqin committed
381
        }
liqin's avatar
liqin committed
382

liqin's avatar
liqin committed
383 384 385
        return getSuccessResult();
    }

liqin's avatar
liqin committed
386 387
}