AuditServiceImpl.java 27.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 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 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
package cn.chnmuseum.party.service.impl;

import cn.chnmuseum.party.common.enums.*;
import cn.chnmuseum.party.common.mvc.InterfaceException;
import cn.chnmuseum.party.mapper.AssetMapper;
import cn.chnmuseum.party.mapper.AuditMapper;
import cn.chnmuseum.party.model.*;
import cn.chnmuseum.party.service.*;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;

/**
 * <pre>
 * 学习内容信息 服务实现类
 * </pre>
 *
 * @author Danny Lee
 * @since 2021-03-26
 */
@Slf4j
@Service
public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements AuditService {

    @Resource
    private AuditMapper auditMapper;

    @Resource
    private AssetMapper assetMapper;

    @Resource
    private TUserServiceImpl userService;

    @Resource
    private VideoContentService videoContentService;

    @Resource
    private ExhibitionBoardService exhibitionBoardService;

    @Resource
    private LearningContentService learningContentService;

    @Resource
    private LearningContentBoardService learningContentBoardService;

    @Resource
    private LearningContentBoardCatService learningContentBoardCatService;

    @Resource
    private LearningContentCopyrightOwnerService learningContentCopyrightOwnerService;

    @Override
    public Page<Audit> getUserList(Page<Audit> page, TUser user) {
        return page.setRecords(auditMapper.getUserList(page, user));
    }

    /**
     * 分页查询
     */
    @Override
    public Page<Audit> pageList(String name, AuditStatusEnum status, AuditStatusEnum auditStatusLevel, AuditTypeEnum type, Page<Object> page, String id) {
        //分页
        Page<Audit> auditPage = new Page<>();
        auditPage.setCurrent(page.getCurrent());
        auditPage.setSize(page.getSize());
        //条件
        QueryWrapper<Audit> ew = new QueryWrapper<Audit>();
        if (null != auditStatusLevel) {
            ew.eq("a.level", auditStatusLevel.name());
        }
        if (StringUtils.isNotBlank(name)) {
            ew.and(i -> i.like("b.name", name).or().like("c.user_name", name));
        }
        if (status != null) {
            ew.eq(status != null, "a.status", status.name());
        }
        //暂时注掉
        ew.eq("a.type", type.name())
                .or(new Consumer<QueryWrapper<Audit>>() {
                    @Override
                    public void accept(QueryWrapper<Audit> auditQueryWrapper) {
                        auditQueryWrapper.eq("audit_id", id).eq("a.type", type.name());
                        if (StringUtils.isNotBlank(name)) {
                            auditQueryWrapper.and(i -> i.like("b.name", name).or().like("c.user_name", name));
                        }
                        if (status != null) {
                            auditQueryWrapper.eq(status != null, "a.status", status.name());
                        }
                    }
                })
                .orderByDesc("a.create_time", "a.id");
        //

        return pageByType(ew, name, type, auditPage);
    }

    /**
     * 分别查询
     */
    private Page<Audit> pageByType(QueryWrapper<Audit> ew, String name, AuditTypeEnum type, Page<Audit> auditPage) {
        Page<Audit> selectPage = null;
        switch (type) {
            case LEARNING_CONTENT:
                selectPage = auditMapper.getLearningContentPage(auditPage, ew);
                break;
            case EXHIBITION_BOARD:
                selectPage = auditMapper.getExhibitionBoardPage(auditPage, ew);
                break;
            case ACCOUNT:
                break;
            case VIDEO_CONTENT:
                selectPage = auditMapper.getVideoContentPage(auditPage, ew);
            default:
        }
        //
        return selectPage;
    }

    /**
     * 根据id更新审核信息
     */
    @Override
    public boolean updateAuditAllById(Audit audit) {
        //审核层级,初审 和 复审
        AuditStatusEnum auditStatusLevel = AuditStatusEnum.valueOf(audit.getLevel());
        boolean update;
        switch (auditStatusLevel) {
            case TBC:
                update = updateOnTBC(audit);
                return update;
            case TBCA:
                update = updateOnTBCA(audit);
                return update;
            default:
                throw new InterfaceException("level参数不正确");
        }
    }

    @Override
    public Audit selectOne(String id, String type) {
        UpdateWrapper<Audit> wrapper = new UpdateWrapper<>();
        if (StringUtils.isNotBlank(id)) {
            wrapper.eq("ref_item_id", id);
        }
        if (StringUtils.isNotBlank(type)) {
            wrapper.eq("type", type);
        }
        wrapper.orderByDesc("create_time").last("limit 1");
        return getOne(wrapper);
    }

    /**
     * 初审级别的修改情况
     */
    private boolean updateOnTBC(Audit audit) {
        audit.setFirstTime(LocalDateTime.now());
        String status = audit.getStatus();
        AuditStatusEnum auditStatusEnum = AuditStatusEnum.valueOf(status);
        //初审 通过时,修改状态为待复审
        if (AuditStatusEnum.APPROVED_FINAL.equals(auditStatusEnum)) {
            audit.setStatus(AuditStatusEnum.TBCA.name());
            audit.setLevel(AuditStatusEnum.TBCA.name());
        }
        if (!AuditStatusEnum.REFUSED.equals(auditStatusEnum)) {
            audit.setFirstRemarks("");
        }
        audit.setSecondRemarks("");
        //通过与不通过时 都修改
        boolean updateRefItemByRefItemId = updateRefItemByRefItemId(audit);
        int update = auditMapper.updateById(audit);
        return updateRefItemByRefItemId && update >= 1;
        //初审驳回时,不做状态修改
//        int update = auditMapper.updateById(audit);
//        return update >= 1;
    }

    /**
     * 复审级别的修改情况
     */
    private boolean updateOnTBCA(Audit audit) {
        audit.setSecondTime(LocalDateTime.now());
        String status = audit.getStatus();
        AuditStatusEnum auditStatusEnum = AuditStatusEnum.valueOf(status);
        if (!AuditStatusEnum.REFUSED.equals(auditStatusEnum)) {
            audit.setSecondRemarks("");
        }
        audit.setFirstRemarks("");
        //复审通过时,
//        boolean updateRefItemByRefItemId = true;
//        if (AuditStatusEnum.APPROVED_FINAL.equals(auditStatusEnum)) {
//            //修改对应审核项中的信息
//            updateRefItemByRefItemId = updateRefItemByRefItemId(audit);
//        }

        //通过与不通过时 都修改
        boolean updateRefItemByRefItemId = updateRefItemByRefItemId(audit);
        int update = auditMapper.updateById(audit);
        return updateRefItemByRefItemId && update >= 1;
    }

    /**
     * 根据审核项ID 修改 审核项表中的信息
     */
    private boolean updateRefItemByRefItemId(Audit audit) {
        String type = audit.getType();
        AuditTypeEnum auditTypeEnum = AuditTypeEnum.valueOf(type);
        boolean update;
        switch (auditTypeEnum) {
            case VIDEO_CONTENT:
                update = fillVideoContentByAudit(audit);
                break;
//            case ACCOUNT:
//                break;
            case EXHIBITION_BOARD:
                update = fillExhibitionBoardByAudit(audit);
                break;
            case LEARNING_CONTENT:
                update = fillLearningContentByAudit(audit);
                break;
            default:
                throw new InterfaceException("type参数不正确");
        }
        return update;
    }

    /**
     * 根据审核操作 填充VideoContent属性用于更改
     */
    public boolean fillVideoContentByAudit(Audit audit) {
        final String videoContentId = audit.getRefItemId();
        VideoContent videoContent = new VideoContent();
        videoContent.setId(videoContentId);
        videoContent.setAuditStatus(audit.getStatus());
        //当审核级别为复审,审核状态为通过是,会修改审核项其它表中的 发布与删除字段,不是此情况下是直接修改审核状态
        boolean continueFill = AuditStatusEnum.APPROVED_FINAL.name().equals(audit.getStatus()) && AuditStatusEnum.TBCA.name().equals(audit.getLevel());
        if (!continueFill) {
            return this.videoContentService.updateById(videoContent);
        }
        String operation = audit.getOperation();
        AuditOperationEnum auditOperationEnum = AuditOperationEnum.valueOf(operation);
        boolean update = false;
        switch (auditOperationEnum) {
            case ENABLE:
                videoContent.setPublished(true);
                update = this.videoContentService.updateById(videoContent);
                break;
            case DISABLE:
                videoContent.setPublished(false);
                update = this.videoContentService.updateById(videoContent);
                break;
            case REMOVE:
                final LambdaQueryWrapper<ExhibitionBoard> queryWrapper = Wrappers.<ExhibitionBoard>lambdaQuery().eq(ExhibitionBoard::getVideoContentId, videoContentId).select(ExhibitionBoard::getId);
                final List<String> exhibitionBoardIdList = this.exhibitionBoardService.listObjs(queryWrapper, Object::toString);
                if (exhibitionBoardIdList != null && !exhibitionBoardIdList.isEmpty()) {
                    this.exhibitionBoardService.removeByIds(exhibitionBoardIdList);
                    this.assetMapper.delete(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> deleteWrapper1 = Wrappers.<LearningContentBoard>lambdaUpdate().in(LearningContentBoard::getExhibitionBoardId, exhibitionBoardIdList);
                        this.learningContentBoardService.remove(deleteWrapper1);
                    }
                }
                this.assetMapper.delete(Wrappers.<Asset>lambdaUpdate().in(Asset::getRefItemId, videoContentId));
                update = this.videoContentService.removeById(videoContentId);
                break;
            case ADD:
                this.assetMapper.update(Asset.builder().published(true).build(), Wrappers.<Asset>lambdaUpdate().eq(Asset::getRefItemId, videoContentId));
                videoContent.setPublished(true);
                update = this.videoContentService.updateById(videoContent);
                break;
            case EDIT:
                final String data = this.auditMapper.selectById(audit.getId()).getModelData();
                final VideoContent one = JSONObject.parseObject(data, VideoContent.class);
                final List<String> videoFileIdList = one.getVideoFileIdList();
                if (videoFileIdList != null && !videoFileIdList.isEmpty()) {
                    final LambdaQueryWrapper<Asset> assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId);
                    assetQueryWrapper.eq(Asset::getPublished, true);
                    final List<Asset> assetList = this.assetMapper.selectList(assetQueryWrapper);
                    final Map<String, String> collect = assetList.stream().collect(Collectors.toMap(Asset::getId, Asset::getFileUrl));
                    for (String videoFileId : videoFileIdList) {
                        final Asset asset = this.assetMapper.selectById(videoFileId);
                        asset.setThumbnail(videoContent.getThumbnail());
                        asset.setFileType(FileTypeEnum.VIDEO.name());
                        asset.setFileCat(FileCatEnum.VIDEO_CONTENT.name());
                        asset.setRefItemId(videoContentId);
                        asset.setPublished(true);
                        this.assetMapper.updateById(asset);
                        if (StringUtils.isBlank(videoContent.getName())) {
                            videoContent.setName(asset.getVideoContentName());
                            this.videoContentService.updateById(videoContent);
                        }
                        collect.remove(videoFileId);
                    }
                    if (!collect.isEmpty()) {
                        this.assetMapper.deleteBatchIds(collect.keySet());
                    }
                }
                one.setAuditStatus(audit.getStatus());
                update = this.videoContentService.updateById(one);
                break;
            default:
        }
        return update;
    }

    /**
     * 根据审核操作 填充ExhibitionBoard属性用于更改
     */
    public boolean fillExhibitionBoardByAudit(Audit audit) {
        final String exhibitionBoardId = audit.getRefItemId();
        ExhibitionBoard exhibitionBoard = new ExhibitionBoard();
        exhibitionBoard.setId(exhibitionBoardId);
        exhibitionBoard.setAuditStatus(audit.getStatus());
        //当审核级别为复审,审核状态为通过是,会修改审核项其它表中的 发布与删除字段,不是此情况下是直接修改审核状态
        boolean continueFill = AuditStatusEnum.APPROVED_FINAL.name().equals(audit.getStatus()) && AuditStatusEnum.TBCA.name().equals(audit.getLevel());
        if (!continueFill) {
            return this.exhibitionBoardService.updateById(exhibitionBoard);
        }
        String operation = audit.getOperation();
        AuditOperationEnum auditOperationEnum = AuditOperationEnum.valueOf(operation);
        boolean update = false;
        switch (auditOperationEnum) {
            case UPPER:
                exhibitionBoard.setPublished(true);
                update = this.exhibitionBoardService.updateById(exhibitionBoard);
                break;
            case LOWER:
                exhibitionBoard.setPublished(false);
                update = this.exhibitionBoardService.updateById(exhibitionBoard);
                break;
            case REMOVE:
                final LambdaQueryWrapper<LearningContentBoard> learningContentBoardLambdaQueryWrapper = Wrappers.<LearningContentBoard>lambdaQuery().eq(LearningContentBoard::getExhibitionBoardCatId, exhibitionBoardId);
                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().eq(LearningContentBoard::getExhibitionBoardId, exhibitionBoardId);
                    this.learningContentBoardService.remove(learningContentBoardLambdaUpdateWrapper);
                }
                this.assetMapper.delete(Wrappers.<Asset>lambdaUpdate().eq(Asset::getRefItemId, exhibitionBoardId));
                update = this.exhibitionBoardService.removeById(exhibitionBoardId);
                break;
            case ADD:
                this.assetMapper.update(Asset.builder().published(true).build(), Wrappers.<Asset>lambdaUpdate().eq(Asset::getRefItemId, exhibitionBoardId));
                exhibitionBoard.setPublished(true);
                update = this.exhibitionBoardService.updateById(exhibitionBoard);
                break;
            case EDIT:
                final String data = this.auditMapper.selectById(audit.getId()).getModelData();
                final ExhibitionBoard one = JSONObject.parseObject(data, ExhibitionBoard.class);
                final List<String> audioIdList = one.getAudioIdList();
                if (audioIdList != null && !audioIdList.isEmpty()) {
                    final LambdaQueryWrapper<Asset> assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoardId);
                    assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_AUDIO.name());
                    assetQueryWrapper.eq(Asset::getPublished, true);
                    final List<Asset> assetList = this.assetMapper.selectList(assetQueryWrapper);
                    final Map<String, String> collect = assetList.stream().collect(Collectors.toMap(Asset::getId, Asset::getFileUrl));
                    for (String audioId : audioIdList) {
                        final Asset asset = this.assetMapper.selectById(audioId);
                        asset.setFileType(FileTypeEnum.AUDIO.name());
                        asset.setFileCat(FileCatEnum.EXHIBITION_BOARD_AUDIO.name());
                        asset.setRefItemId(exhibitionBoardId);
                        asset.setPublished(true);
                        this.assetMapper.updateById(asset);
                        collect.remove(audioId);
                    }
                    if (!collect.isEmpty()) {
                        this.assetMapper.deleteBatchIds(collect.keySet());
                    }
                }
                final List<String> datumIdList = one.getDatumIdList();
                if (datumIdList != null && !datumIdList.isEmpty()) {
                    final LambdaQueryWrapper<Asset> assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoardId);
                    assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name());
                    assetQueryWrapper.eq(Asset::getPublished, true);
                    final List<Asset> assetList = this.assetMapper.selectList(assetQueryWrapper);
                    final Map<String, String> collect = assetList.stream().collect(Collectors.toMap(Asset::getId, Asset::getFileUrl));
                    for (String datumId : datumIdList) {
                        final Asset asset = this.assetMapper.selectById(datumId);
                        asset.setFileCat(FileCatEnum.EXHIBITION_BOARD_DATUM.name());
                        asset.setRefItemId(exhibitionBoardId);
                        asset.setPublished(true);
                        this.assetMapper.updateById(asset);
                        collect.remove(datumId);
                    }
                    if (!collect.isEmpty()) {
                        this.assetMapper.deleteBatchIds(collect.keySet());
                    }
                }
                one.setAuditStatus(audit.getStatus());
                update = this.exhibitionBoardService.updateById(one);
                break;
            default:
        }
        return update;
    }

    /**
     * 根据审核操作 填充LearningContent属性用于更改
     */
    public boolean fillLearningContentByAudit(Audit audit) {
        final String learningContentId = audit.getRefItemId();
        LearningContent learningContent = new LearningContent();
        learningContent.setAuditStatus(audit.getStatus());
        learningContent.setId(learningContentId);
        //当审核级别为复审,审核状态为通过是,会修改审核项其它表中的 发布与删除字段,不是此情况下是直接修改审核状态
        boolean continueFill = AuditStatusEnum.APPROVED_FINAL.name().equals(audit.getStatus()) && AuditStatusEnum.TBCA.name().equals(audit.getLevel());
        if (!continueFill) {
            return this.learningContentService.updateById(learningContent);
        }
        String operation = audit.getOperation();
        AuditOperationEnum auditOperationEnum = AuditOperationEnum.valueOf(operation);
        boolean update = false;
        switch (auditOperationEnum) {
            case ENABLE:
                learningContent.setPublished(true);
                update = this.learningContentService.updateById(learningContent);
                break;
            case DISABLE:
                learningContent.setPublished(false);
                update = this.learningContentService.updateById(learningContent);
                break;
            case REMOVE:
                this.learningContentBoardService.remove(Wrappers.<LearningContentBoard>lambdaUpdate().eq(LearningContentBoard::getLearningContentId, learningContentId));
                this.learningContentBoardCatService.remove(Wrappers.<LearningContentBoardCat>lambdaUpdate().eq(LearningContentBoardCat::getLearningContentId, learningContentId));
                this.learningContentCopyrightOwnerService.remove(Wrappers.<LearningContentCopyrightOwner>lambdaUpdate().eq(LearningContentCopyrightOwner::getLearningContentId, learningContentId));
                update = this.learningContentService.removeById(learningContentId);
                break;
            case ADD:
                learningContent.setPublished(true);
                update = this.learningContentService.updateById(learningContent);
                break;
            case EDIT:
                final String data = this.auditMapper.selectById(audit.getId()).getModelData();
                final LearningContent one = JSONObject.parseObject(data, LearningContent.class);
                final List<String> exhibitionBoardCatIdList = one.getExhibitionBoardCatIdList();
                if (exhibitionBoardCatIdList != null && !exhibitionBoardCatIdList.isEmpty()) {
                    LambdaUpdateWrapper<LearningContentBoardCat> lambdaUpdateWrapper = Wrappers.<LearningContentBoardCat>lambdaUpdate().eq(LearningContentBoardCat::getLearningContentId, learningContentId);
                    this.learningContentBoardCatService.remove(lambdaUpdateWrapper);

                    for (String exhibitionBoardCatId : exhibitionBoardCatIdList) {
                        LearningContentBoardCat learningContentBoardCat = LearningContentBoardCat.builder().exhibitionBoardCatId(exhibitionBoardCatId).learningContentId(learningContentId).build();
                        this.learningContentBoardCatService.save(learningContentBoardCat);
                    }
                }
                final List<String> copyrightOwnerIdList = one.getCopyrightOwnerIdList();
                if (copyrightOwnerIdList != null && !copyrightOwnerIdList.isEmpty()) {
                    LambdaUpdateWrapper<LearningContentCopyrightOwner> lambdaUpdateWrapper = Wrappers.<LearningContentCopyrightOwner>lambdaUpdate().eq(LearningContentCopyrightOwner::getLearningContentId, learningContentId);
                    this.learningContentCopyrightOwnerService.remove(lambdaUpdateWrapper);

                    for (String copyrightOwnerId : copyrightOwnerIdList) {
                        LearningContentCopyrightOwner contentCopyrightOwner = LearningContentCopyrightOwner.builder().copyrightOwnerId(copyrightOwnerId).learningContentId(learningContentId).build();
                        this.learningContentCopyrightOwnerService.save(contentCopyrightOwner);
                    }
                }
                final List<String> exhibitionBoardIdList = one.getExhibitionBoardIdList();
                if (exhibitionBoardIdList != null && !exhibitionBoardIdList.isEmpty()) {
                    LambdaUpdateWrapper<LearningContentBoard> lambdaUpdateWrapper = Wrappers.<LearningContentBoard>lambdaUpdate().eq(LearningContentBoard::getLearningContentId, learningContentId);
                    this.learningContentBoardService.remove(lambdaUpdateWrapper);

                    for (String exhibitionBoardId : exhibitionBoardIdList) {
                        LearningContentBoard learningContentBoard = LearningContentBoard.builder()
                                .learningContentId(learningContentId)
                                .exhibitionBoardCatId(this.exhibitionBoardService.getById(exhibitionBoardId).getExhibitionBoardCatId())
                                .exhibitionBoardId(exhibitionBoardId)
                                .build();
                        this.learningContentBoardService.save(learningContentBoard);
                    }
                }
                one.setAuditStatus(audit.getStatus());
                update = this.learningContentService.updateById(one);
                break;
            default:
        }
        return update;
    }

    /**
     * 根据审核项数据插入审核记录
     *
     * @param refItemId     审核项ID
     * @param content       审核内容
     * @param typeEnum      审核类型
     * @param operationEnum 操作类型
     */
    @Override
    public boolean saveByRefItemInfo(String refItemId, String content, AuditTypeEnum typeEnum, AuditOperationEnum operationEnum) {
        Audit audit = new Audit();
        //
        audit.setRefItemId(refItemId);
        audit.setContent(content);
        audit.setType(typeEnum.name());
        audit.setOperation(operationEnum.name());
        //
        audit.setLevel(AuditStatusEnum.TBC.name());
        audit.setStatus(AuditStatusEnum.TBC.name());
        audit.setCreateTime(LocalDateTime.now());
        //
        Object principal = SecurityUtils.getSubject().getPrincipal();
        if (principal instanceof TUser) {
            TUser user = (TUser) principal;
            audit.setUserId(user.getId());
            audit.setUserName(user.getUserName());
            audit.setOrganId(user.getOrgId());
            audit.setOrgName(user.getOrgName());
        }
        //保存
        int insert = auditMapper.insert(audit);
        return insert >= 1;
    }

}