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

liqin's avatar
liqin committed
3
import cn.wisenergy.chnmuseum.party.common.enums.CopyrightOwnerTypeEnum;
wzp's avatar
wzp committed
4 5 6
import cn.wisenergy.chnmuseum.party.common.log.MethodLog;
import cn.wisenergy.chnmuseum.party.common.log.OperModule;
import cn.wisenergy.chnmuseum.party.common.log.OperType;
liqin's avatar
liqin committed
7
import cn.wisenergy.chnmuseum.party.common.util.TimeUtils;
liqin's avatar
liqin committed
8 9 10
import cn.wisenergy.chnmuseum.party.common.validator.groups.Add;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
liqin's avatar
liqin committed
11 12
import cn.wisenergy.chnmuseum.party.model.*;
import cn.wisenergy.chnmuseum.party.service.*;
liqin's avatar
liqin committed
13
import cn.wisenergy.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 72 73
    @Resource
    private AuditService auditService;
    @Resource
    private AssetService assetService;
liqin's avatar
liqin committed
74

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

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

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

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

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

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

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

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

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

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

liqin's avatar
liqin committed
284 285 286 287 288 289
    @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
290
    @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.DELETE)
liqin's avatar
liqin committed
291 292
    public Map<String, Object> deleteCopyrightOwner(@PathVariable("id") String id) {
        this.copyrightOwnerService.removeById(id);
liqin's avatar
liqin committed
293

liqin's avatar
liqin committed
294 295 296 297 298
        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
299

liqin's avatar
liqin committed
300 301 302 303 304 305
        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.auditService.remove(Wrappers.<Audit>lambdaUpdate().in(Audit::getRefItemId, videoContentIdList));
            this.assetService.remove(Wrappers.<Asset>lambdaUpdate().in(Asset::getRefItemId, videoContentIdList));
liqin's avatar
liqin committed
306

liqin's avatar
liqin committed
307 308 309 310 311 312
            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.auditService.remove(Wrappers.<Audit>lambdaUpdate().in(Audit::getRefItemId, ExhibitionBoardIdList));
                this.assetService.remove(Wrappers.<Asset>lambdaUpdate().in(Asset::getRefItemId, ExhibitionBoardIdList));
liqin's avatar
liqin committed
313

liqin's avatar
liqin committed
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 350 351 352 353 354
                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.auditService.remove(Wrappers.<Audit>lambdaUpdate().in(Audit::getRefItemId, 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
355

liqin's avatar
liqin committed
356 357 358
        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
359
            final Map<String, List<String>> collect = learningContentCopyrightOwnerList.stream().collect(Collectors.groupingBy(LearningContentCopyrightOwner::getLearningContentId, Collectors.mapping(LearningContentCopyrightOwner::getCopyrightOwnerId, Collectors.toList())));
liqin's avatar
liqin committed
360
            collect.forEach((k, v) -> {
liqin's avatar
liqin committed
361 362
                if (v.size() == 1) {
                    this.learningContentService.removeById(k);
liqin's avatar
liqin committed
363 364 365
                    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
366 367
                }
            });
liqin's avatar
liqin committed
368 369
            LambdaUpdateWrapper<LearningContentCopyrightOwner> learningContentCopyrightOwnerLambdaUpdateWrapper = Wrappers.<LearningContentCopyrightOwner>lambdaUpdate().eq(LearningContentCopyrightOwner::getCopyrightOwnerId, id);
            this.learningContentCopyrightOwnerService.remove(learningContentCopyrightOwnerLambdaUpdateWrapper);
liqin's avatar
liqin committed
370
        }
liqin's avatar
liqin committed
371

liqin's avatar
liqin committed
372 373 374
        return getSuccessResult();
    }

liqin's avatar
liqin committed
375 376
}