ExhibitionBoardController.java 24.9 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
import cn.chnmuseum.party.common.enums.*;
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.validator.groups.Add;
import cn.chnmuseum.party.common.validator.groups.Update;
import cn.chnmuseum.party.common.vo.GenericPageParam;
import cn.chnmuseum.party.model.*;
import cn.chnmuseum.party.service.*;
import cn.chnmuseum.party.web.controller.base.BaseController;
liqin's avatar
liqin committed
13
import com.alibaba.fastjson.JSONObject;
liqin's avatar
liqin committed
14 15 16 17 18 19 20 21 22
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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
23
import org.apache.shiro.authz.annotation.RequiresAuthentication;
liqin's avatar
liqin committed
24 25 26 27
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

/**
liqin's avatar
liqin committed
34
 * <pre>
liqin's avatar
liqin committed
35
 * 展板 前端控制器
liqin's avatar
liqin committed
36
 * </pre>
liqin's avatar
liqin committed
37 38
 *
 * @author Danny Lee
liqin's avatar
liqin committed
39
 * @since 2021-03-19
liqin's avatar
liqin committed
40
 */
liqin's avatar
liqin committed
41
@Slf4j
liqin's avatar
liqin committed
42
@RestController
liqin's avatar
liqin committed
43 44
@RequestMapping("/exhibitionBoard")
@Api(tags = {"展板操作接口"})
liqin's avatar
liqin committed
45 46
public class ExhibitionBoardController extends BaseController {

liqin's avatar
liqin committed
47 48
    @Resource
    private ExhibitionBoardService exhibitionBoardService;
liqin's avatar
liqin committed
49 50 51 52
    @Resource
    private ExhibitionBoardCatService exhibitionBoardCatService;
    @Resource
    private CopyrightOwnerService copyrightOwnerService;
liqin's avatar
liqin committed
53
    @Resource
liqin's avatar
liqin committed
54 55
    private VideoContentService videoContentService;
    @Resource
liqin's avatar
liqin committed
56
    private AuditService auditService;
liqin's avatar
liqin committed
57 58
    @Resource
    private AssetService assetService;
liqin's avatar
liqin committed
59 60

    @PostMapping("/save")
wzp's avatar
wzp committed
61
    @RequiresAuthentication  //@RequiresPermissions("exhibition:board:save")
liqin's avatar
liqin committed
62
    @ApiOperation(value = "添加展板", notes = "添加展板")
wzp's avatar
wzp committed
63
    @MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.ADD)
liqin's avatar
liqin committed
64
    public Map<String, Object> saveExhibitionBoard(@Validated(value = {Add.class}) ExhibitionBoard exhibitionBoard) {
liqin's avatar
liqin committed
65 66 67 68 69 70
        final LambdaQueryWrapper<ExhibitionBoard> lambdaQueryWrapper = Wrappers.<ExhibitionBoard>lambdaQuery().eq(ExhibitionBoard::getName, exhibitionBoard.getName().trim());
        final int count = this.exhibitionBoardService.count(lambdaQueryWrapper);
        if (count > 0) {
            return getFailResult("400", "名称已存在,请修改名称");
        }

wzp's avatar
wzp committed
71
        TUser user = getcurUser();
liqin's avatar
liqin committed
72 73 74
        final List<String> audioIdList = exhibitionBoard.getAudioIdList();
        if (audioIdList == null || audioIdList.isEmpty()) {
            return getFailResult("400", "导览音频文件必须上传");
liqin's avatar
liqin committed
75
        }
liqin's avatar
liqin committed
76 77 78
        final List<String> datumIdList = exhibitionBoard.getDatumIdList();
        if (datumIdList == null || datumIdList.isEmpty()) {
            return getFailResult("400", "参考资料文件必须上传");
liqin's avatar
liqin committed
79 80 81
        }
        exhibitionBoard.setAuditStatus(AuditStatusEnum.TBC.name());
        exhibitionBoard.setPublished(false);
wzp's avatar
wzp committed
82
        exhibitionBoard.setDeleted(false);
liqin's avatar
liqin committed
83 84 85 86
        // 保存业务节点信息
        boolean result = exhibitionBoardService.save(exhibitionBoard);
        // 返回操作结果
        if (result) {
liqin's avatar
liqin committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100
            for (String audioId : audioIdList) {
                final Asset asset = this.assetService.getById(audioId);
                asset.setFileType(FileTypeEnum.AUDIO.name());
                asset.setFileCat(FileCatEnum.EXHIBITION_BOARD_AUDIO.name());
                asset.setRefItemId(exhibitionBoard.getId());
                this.assetService.updateById(asset);
            }
            for (String datumId : datumIdList) {
                final Asset asset = this.assetService.getById(datumId);
                asset.setFileCat(FileCatEnum.EXHIBITION_BOARD_DATUM.name());
                asset.setRefItemId(exhibitionBoard.getId());
                this.assetService.updateById(asset);
            }

liqin's avatar
liqin committed
101 102
            final Audit audit = Audit.builder()
                    .content(exhibitionBoard.getName())
liqin's avatar
liqin committed
103
                    .name(exhibitionBoard.getName())
liqin's avatar
liqin committed
104
                    .refItemId(exhibitionBoard.getId())
wzp's avatar
wzp committed
105
                    .userId(user.getId())
liqin's avatar
liqin committed
106 107
                    .type(AuditTypeEnum.EXHIBITION_BOARD.name())
                    .operation(AuditOperationEnum.ADD.name())
liqin's avatar
liqin committed
108
                    .status(AuditStatusEnum.TBC.name())
liqin's avatar
liqin committed
109 110
                    .level(AuditStatusEnum.TBC.name())
                    .build();
liqin's avatar
liqin committed
111
            this.auditService.save(audit);
liqin's avatar
liqin committed
112 113 114 115 116 117 118 119
            return getSuccessResult();
        } else {
            // 保存失败
            return getFailResult();
        }
    }

    @PutMapping("/update")
wzp's avatar
wzp committed
120
    @RequiresAuthentication  //@RequiresPermissions("exhibition:board:update")
liqin's avatar
liqin committed
121
    @ApiOperation(value = "修改展板信息", notes = "修改展板信息")
wzp's avatar
wzp committed
122
    @MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.UPDATE)
liqin's avatar
liqin committed
123
    public Map<String, Object> updateExhibitionBoard(@Validated(value = {Update.class}) ExhibitionBoard exhibitionBoard) {
liqin's avatar
liqin committed
124 125 126
        final ExhibitionBoard one = this.exhibitionBoardService.getById(exhibitionBoard.getId());
        one.setAuditStatus(AuditStatusEnum.TBC.name());
        this.exhibitionBoardService.updateById(one);
liqin's avatar
liqin committed
127

liqin's avatar
liqin committed
128 129 130 131 132 133 134 135 136 137 138 139
        final Audit audit = Audit.builder()
                .content(exhibitionBoard.getName())
                .refItemId(exhibitionBoard.getId())
                .userId(getcurUser().getId())
                .type(AuditTypeEnum.EXHIBITION_BOARD.name())
                .operation(AuditOperationEnum.EDIT.name())
                .status(AuditStatusEnum.TBC.name())
                .level(AuditStatusEnum.TBC.name())
                .modelData(JSONObject.toJSONString(exhibitionBoard))
                .build();
        this.auditService.save(audit);
        return getSuccessResult();
liqin's avatar
liqin committed
140 141
    }

wzp's avatar
wzp committed
142
    @PostMapping("/getList")
wzp's avatar
wzp committed
143
    @RequiresAuthentication  //@RequiresPermissions("exhibition:board:list")
liqin's avatar
liqin committed
144
    @ApiOperation(value = "获取展板全部列表(无分页)", notes = "获取展板全部列表(无分页)")
wzp's avatar
wzp committed
145
    @MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.SELECT)
liqin's avatar
liqin committed
146 147 148
    public Map<String, Object> getExhibitionBoardList(
            @RequestParam(value = "exhibitionBoardCatIdList", required = false) List<String> exhibitionBoardCatIdList,
            @RequestParam(value = "boardCopyrightOwnerIdList", required = false) List<String> boardCopyrightOwnerIdList) {
wzp's avatar
wzp committed
149
        final LambdaQueryWrapper<ExhibitionBoard> lambdaQueryWrapper = Wrappers.<ExhibitionBoard>lambdaQuery().eq(ExhibitionBoard::getPublished, true);
liqin's avatar
liqin committed
150 151 152 153 154 155
        if (exhibitionBoardCatIdList != null && !exhibitionBoardCatIdList.isEmpty()) {
            lambdaQueryWrapper.in(ExhibitionBoard::getExhibitionBoardCatId, exhibitionBoardCatIdList);
        }
        if (boardCopyrightOwnerIdList != null && !boardCopyrightOwnerIdList.isEmpty()) {
            lambdaQueryWrapper.in(ExhibitionBoard::getBoardCopyrightOwnerId, boardCopyrightOwnerIdList);
        }
liqin's avatar
liqin committed
156
        lambdaQueryWrapper.orderByDesc(ExhibitionBoard::getCreateTime);
wzp's avatar
wzp committed
157
        List<ExhibitionBoard> exhibitionBoardList = exhibitionBoardService.list(lambdaQueryWrapper);
liqin's avatar
liqin committed
158
        for (ExhibitionBoard exhibitionBoard : exhibitionBoardList) {
liqin's avatar
liqin committed
159
            if (exhibitionBoard.getBoardCopyrightOwnerId() != null) {
liqin's avatar
liqin committed
160 161 162 163 164 165
                final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getBoardCopyrightOwnerId());
                if (copyrightOwner == null) {
                    exhibitionBoard.setBoardCopyrightOwnerName("对应的展板版权方已被删除");
                } else {
                    exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
                }
liqin's avatar
liqin committed
166
            }
liqin's avatar
liqin committed
167
            if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
liqin's avatar
liqin committed
168 169 170 171 172 173
                final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId());
                if (copyrightOwner == null) {
                    exhibitionBoard.setVideoContentCopyrightOwnerName("对应的视频内容版权方已被删除");
                } else {
                    exhibitionBoard.setVideoContentCopyrightOwnerName(copyrightOwner.getName());
                }
liqin's avatar
liqin committed
174
            }
liqin's avatar
liqin committed
175
            if (exhibitionBoard.getExhibitionBoardCatId() != null) {
liqin's avatar
liqin committed
176 177 178 179 180 181
                final ExhibitionBoardCat exhibitionBoardCat = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId());
                if (exhibitionBoardCat == null) {
                    exhibitionBoard.setExhibitionBoardCatName("对应的展板分类已被删除");
                } else {
                    exhibitionBoard.setExhibitionBoardCatName(exhibitionBoardCat.getName());
                }
liqin's avatar
liqin committed
182
            }
liqin's avatar
liqin committed
183 184 185 186 187 188 189 190 191 192 193
            if (exhibitionBoard.getVideoContentId() != null) {
                String videoContentId = exhibitionBoard.getVideoContentId();
                final VideoContent videoContent = this.videoContentService.getById(videoContentId);
                if (videoContent == null) {
                    exhibitionBoard.setVideoList(Collections.emptyList());
                } else {
                    exhibitionBoard.setVideoContentName(videoContent.getName());
                    final List<Asset> videoList = this.assetService.list(Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId));
                    exhibitionBoard.setVideoList(videoList);
                }
            }
liqin's avatar
liqin committed
194
        }
liqin's avatar
liqin committed
195 196 197 198 199 200 201 202 203 204 205 206
        return getResult(exhibitionBoardList);
    }

    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "nameOrCode", value = "名称或编码", paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "copyrightOwner", 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
207
    @RequiresAuthentication  //@RequiresPermissions("exhibition:board:page")
liqin's avatar
liqin committed
208
    @ApiOperation(value = "获取展板分页列表", notes = "获取展板分页列表")
wzp's avatar
wzp committed
209
    @MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.SELECT)
liqin's avatar
liqin committed
210 211 212 213 214 215 216
    public Map<String, Object> getExhibitionBoardPageList(GenericPageParam genericPageParam) {
        LambdaQueryWrapper<ExhibitionBoard> queryWrapper = new LambdaQueryWrapper<>();
        // 对名称或编码模糊查询
        if (StringUtils.isNotBlank(genericPageParam.getNameOrCode())) {
            queryWrapper.like(ExhibitionBoard::getName, genericPageParam.getNameOrCode());
        }
        // 对版权方模糊查询
liqin's avatar
liqin committed
217
        if (StringUtils.isNotBlank(genericPageParam.getBoardCopyrightOwnerId())) {
liqin's avatar
liqin committed
218
            queryWrapper.eq(ExhibitionBoard::getBoardCopyrightOwnerId, genericPageParam.getBoardCopyrightOwnerId());
liqin's avatar
liqin committed
219
        }
liqin's avatar
liqin committed
220 221 222 223
        // 对版权方模糊查询
        if (StringUtils.isNotBlank(genericPageParam.getExhibitionBoardCatId())) {
            queryWrapper.eq(ExhibitionBoard::getExhibitionBoardCatId, genericPageParam.getExhibitionBoardCatId());
        }
liqin's avatar
liqin committed
224 225 226 227 228 229 230 231 232 233 234
        // 根据创建时间区间检索
        if (genericPageParam.getStartDate() != null && genericPageParam.getEndDate() != null) {
            queryWrapper.ge(ExhibitionBoard::getCreateTime, genericPageParam.getStartDate().atTime(0, 0, 0))
                    .le(ExhibitionBoard::getCreateTime, genericPageParam.getEndDate().atTime(23, 59, 59));
        }
        // 设置排序规则
        queryWrapper.orderByDesc(ExhibitionBoard::getCreateTime);
        // 设置查询内容
        queryWrapper.select(
                ExhibitionBoard::getId,
                ExhibitionBoard::getName,
liqin's avatar
liqin committed
235 236
                ExhibitionBoard::getRemarks,
                ExhibitionBoard::getQrcodeUrl,
liqin's avatar
liqin committed
237 238
                ExhibitionBoard::getAuditStatus,
                ExhibitionBoard::getPublished,
liqin's avatar
liqin committed
239
                ExhibitionBoard::getDeleted,
liqin's avatar
liqin committed
240
                ExhibitionBoard::getVideoContentCopyrightOwnerId,
liqin's avatar
liqin committed
241
                ExhibitionBoard::getExhibitionBoardCatId,
liqin's avatar
liqin committed
242 243
                ExhibitionBoard::getBoardCopyrightOwnerId,
                ExhibitionBoard::getVideoContentId,
liqin's avatar
liqin committed
244 245 246 247
                ExhibitionBoard::getCreateTime,
                ExhibitionBoard::getUpdateTime);
        Page<ExhibitionBoard> page = this.exhibitionBoardService.page(getPage(), queryWrapper);
        for (ExhibitionBoard exhibitionBoard : page.getRecords()) {
liqin's avatar
liqin committed
248
            if (exhibitionBoard.getBoardCopyrightOwnerId() != null) {
liqin's avatar
liqin committed
249 250 251 252 253 254
                final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getBoardCopyrightOwnerId());
                if (copyrightOwner == null) {
                    exhibitionBoard.setBoardCopyrightOwnerName("对应的展板版权方已被删除");
                } else {
                    exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
                }
liqin's avatar
liqin committed
255
            }
liqin's avatar
liqin committed
256
            if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
liqin's avatar
liqin committed
257 258 259 260 261 262
                final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId());
                if (copyrightOwner == null) {
                    exhibitionBoard.setVideoContentCopyrightOwnerName("对应的视频内容版权方已被删除");
                } else {
                    exhibitionBoard.setVideoContentCopyrightOwnerName(copyrightOwner.getName());
                }
liqin's avatar
liqin committed
263
            }
liqin's avatar
liqin committed
264
            if (exhibitionBoard.getExhibitionBoardCatId() != null) {
liqin's avatar
liqin committed
265 266 267 268 269 270
                final ExhibitionBoardCat exhibitionBoardCat = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId());
                if (exhibitionBoardCat == null) {
                    exhibitionBoard.setExhibitionBoardCatName("对应的展板分类已被删除");
                } else {
                    exhibitionBoard.setExhibitionBoardCatName(exhibitionBoardCat.getName());
                }
liqin's avatar
liqin committed
271
            }
liqin's avatar
liqin committed
272
            if (exhibitionBoard.getVideoContentId() != null) {
liqin's avatar
liqin committed
273 274
                String videoContentId = exhibitionBoard.getVideoContentId();
                final VideoContent videoContent = this.videoContentService.getById(videoContentId);
liqin's avatar
liqin committed
275
                if (videoContent == null) {
liqin's avatar
liqin committed
276
                    exhibitionBoard.setVideoContentName("对应的视频内容已被删除");
liqin's avatar
liqin committed
277 278
                } else {
                    exhibitionBoard.setVideoContentName(videoContent.getName());
liqin's avatar
liqin committed
279
                    final List<Asset> videoList = this.assetService.list(Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId));
liqin's avatar
liqin committed
280
                    exhibitionBoard.setVideoList(videoList);
liqin's avatar
liqin committed
281
                }
liqin's avatar
liqin committed
282
            }
liqin's avatar
liqin committed
283 284 285 286 287 288 289 290 291
        }
        return getResult(page);
    }

    @ApiOperation(value = "获取展板详情", notes = "获取展板详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path")
    })
    @GetMapping("/get/{id}")
wzp's avatar
wzp committed
292
    @RequiresAuthentication  //@RequiresPermissions("exhibition:board:get:id")
wzp's avatar
wzp committed
293
    @MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.SELECT)
liqin's avatar
liqin committed
294 295
    public Map<String, Object> getById(@PathVariable("id") String id) {
        ExhibitionBoard exhibitionBoard = exhibitionBoardService.getById(id);
liqin's avatar
liqin committed
296 297 298 299 300 301 302 303
        String exhibitionBoardCatId = exhibitionBoard.getExhibitionBoardCatId();
        if (exhibitionBoardCatId != null) {
            exhibitionBoard.setExhibitionBoardCatName(this.exhibitionBoardCatService.getById(exhibitionBoardCatId).getName());
        }
        String boardCopyrightOwnerId = exhibitionBoard.getBoardCopyrightOwnerId();
        if (boardCopyrightOwnerId != null) {
            exhibitionBoard.setBoardCopyrightOwnerName(this.copyrightOwnerService.getById(boardCopyrightOwnerId).getName());
        }
liqin's avatar
liqin committed
304 305 306 307
        if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
            String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
            exhibitionBoard.setVideoContentCopyrightOwnerName(name);
        }
liqin's avatar
liqin committed
308

liqin's avatar
liqin committed
309 310 311 312
        LambdaQueryWrapper<Asset> assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId());
        assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_AUDIO.name());
        final List<Asset> audioList = this.assetService.list(assetQueryWrapper);
        exhibitionBoard.setAudioList(audioList);
liqin's avatar
liqin committed
313
        exhibitionBoard.setAudioIdList(audioList.stream().map(Asset::getId).collect(Collectors.toList()));
liqin's avatar
liqin committed
314

liqin's avatar
liqin committed
315 316 317 318 319
        assetQueryWrapper.clear();
        assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId());
        assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name());
        final List<Asset> datumList = this.assetService.list(assetQueryWrapper);
        exhibitionBoard.setDatumList(datumList);
liqin's avatar
liqin committed
320
        exhibitionBoard.setDatumIdList(datumList.stream().map(Asset::getId).collect(Collectors.toList()));
liqin's avatar
liqin committed
321

liqin's avatar
liqin committed
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
        final String videoContentId = exhibitionBoard.getVideoContentId();
        if (videoContentId != null) {
            final VideoContent videoContent = this.videoContentService.getById(videoContentId);
            exhibitionBoard.setVideoContentName(videoContent.getName());

            assetQueryWrapper.clear();
            assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId);
            assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.VIDEO_CONTENT.name());
            final List<Asset> videoList = this.assetService.list(assetQueryWrapper);
            exhibitionBoard.setVideoList(videoList);
        }
        return getResult(exhibitionBoard);
    }

    @ApiOperation(value = "获取展板详情(审核详情使用)", notes = "获取展板详情(审核详情使用)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "审核ID", dataType = "String", paramType = "path", required = true)
    })
    @GetMapping("/getAudit/{id}")
    @RequiresAuthentication  //@RequiresPermissions("video:content:get:id")
    @MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.SELECT)
    public Map<String, Object> getAuditInfoById(@PathVariable("auditId") String auditId) {
        final ExhibitionBoard exhibitionBoard = JSONObject.parseObject(this.auditService.getById(auditId).getModelData(), ExhibitionBoard.class);
        String exhibitionBoardCatId = exhibitionBoard.getExhibitionBoardCatId();
        if (exhibitionBoardCatId != null) {
            exhibitionBoard.setExhibitionBoardCatName(this.exhibitionBoardCatService.getById(exhibitionBoardCatId).getName());
        }
        String boardCopyrightOwnerId = exhibitionBoard.getBoardCopyrightOwnerId();
        if (boardCopyrightOwnerId != null) {
            exhibitionBoard.setBoardCopyrightOwnerName(this.copyrightOwnerService.getById(boardCopyrightOwnerId).getName());
        }
        if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
            String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
            exhibitionBoard.setVideoContentCopyrightOwnerName(name);
        }

        LambdaQueryWrapper<Asset> assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId());
        assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_AUDIO.name());
        final List<Asset> audioList = this.assetService.list(assetQueryWrapper);
        if (audioList != null && !audioList.isEmpty()) {
            exhibitionBoard.setAudioList(audioList);
            exhibitionBoard.setAudioIdList(audioList.stream().map(Asset::getId).collect(Collectors.toList()));
        }

        assetQueryWrapper.clear();
        assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId());
        assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name());
        final List<Asset> datumList = this.assetService.list(assetQueryWrapper);
        if (datumList != null && !datumList.isEmpty()) {
            exhibitionBoard.setDatumList(datumList);
            exhibitionBoard.setDatumIdList(datumList.stream().map(Asset::getId).collect(Collectors.toList()));
        }

        final LambdaQueryWrapper<Audit> auditQueryWrapper = Wrappers.<Audit>lambdaQuery().eq(Audit::getRefItemId, exhibitionBoard.getId());
liqin's avatar
liqin committed
376 377 378 379 380 381 382 383 384 385 386 387
        auditQueryWrapper.select(Audit::getContent);
        auditQueryWrapper.select(Audit::getType);
        auditQueryWrapper.select(Audit::getOperation);
        auditQueryWrapper.select(Audit::getStatus);
        auditQueryWrapper.select(Audit::getFirstTime);
        auditQueryWrapper.select(Audit::getFirstRemarks);
        auditQueryWrapper.select(Audit::getSecondTime);
        auditQueryWrapper.select(Audit::getSecondTime);
        auditQueryWrapper.select(Audit::getLevel);
        final List<Audit> auditList = this.auditService.list(auditQueryWrapper);
        exhibitionBoard.setAuditHistoryList(auditList);

liqin's avatar
liqin committed
388 389 390
        final String videoContentId = exhibitionBoard.getVideoContentId();
        if (videoContentId != null) {
            final VideoContent videoContent = this.videoContentService.getById(videoContentId);
liqin's avatar
liqin committed
391 392 393 394 395 396 397 398
            if (videoContent != null) {
                exhibitionBoard.setVideoContentName(videoContent.getName());
            } else {
                exhibitionBoard.setVideoContentName("相关视频内容已被删除");
            }
            final LambdaQueryWrapper<Asset> lambdaQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId);
            lambdaQueryWrapper.eq(Asset::getFileCat, FileCatEnum.VIDEO_CONTENT.name());
            final List<Asset> videoList = this.assetService.list(lambdaQueryWrapper);
liqin's avatar
liqin committed
399
            exhibitionBoard.setVideoList(videoList);
liqin's avatar
liqin committed
400
        }
liqin's avatar
liqin committed
401 402 403
        return getResult(exhibitionBoard);
    }

liqin's avatar
liqin committed
404 405 406
    @ApiOperation(value = "上架/下架展板内容", notes = "上架/下架展板内容")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path"),
liqin's avatar
liqin committed
407
            @ApiImplicitParam(name = "isPublish", value = "是否上架", dataType = "boolean", paramType = "query", allowableValues = "True, False")
liqin's avatar
liqin committed
408 409
    })
    @PutMapping("/publish/{id}")
wzp's avatar
wzp committed
410
    @RequiresAuthentication  //@RequiresPermissions("exhibition:board:publish")
wzp's avatar
wzp committed
411
    @MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.UPPER)
liqin's avatar
liqin committed
412
    public Map<String, Object> enableExhibitionBoard(@PathVariable("id") String id, @RequestParam("isPublish") Boolean isPublish) {
wzp's avatar
wzp committed
413
        TUser user = getcurUser();
liqin's avatar
liqin committed
414
        final ExhibitionBoard exhibitionBoard = this.exhibitionBoardService.getById(id);
liqin's avatar
liqin committed
415
        final Audit audit = Audit.builder()
wzp's avatar
wzp committed
416
                .userId(user.getId())
liqin's avatar
liqin committed
417 418
                .content(exhibitionBoard.getName())
                .name(exhibitionBoard.getName())
liqin's avatar
liqin committed
419
                .refItemId(id)
liqin's avatar
liqin committed
420
                .type(AuditTypeEnum.EXHIBITION_BOARD.name())
wzp's avatar
wzp committed
421
                .operation(isPublish ? AuditOperationEnum.UPPER.name() : AuditOperationEnum.LOWER.name())
liqin's avatar
liqin committed
422 423
                .status(AuditStatusEnum.TBC.name())
                .level(AuditStatusEnum.TBC.name())
liqin's avatar
liqin committed
424
                .build();
liqin's avatar
liqin committed
425
        this.auditService.save(audit);
liqin's avatar
liqin committed
426
        this.exhibitionBoardService.updateById(ExhibitionBoard.builder().id(id).auditStatus(AuditStatusEnum.TBC.name()).build());
liqin's avatar
liqin committed
427 428 429
        return getSuccessResult();
    }

liqin's avatar
liqin committed
430 431 432 433 434 435 436 437 438
    @DeleteMapping("/delete/{id}")
    @RequiresAuthentication  //@RequiresPermissions("exhibition:board:delete")
    @ApiOperation(value = "根据ID删除展板", notes = "根据ID删除展板")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
    })
    @MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.DELETE)
    public Map<String, Object> deleteExhibitionBoard(@PathVariable("id") String id) {
        TUser user = getcurUser();
liqin's avatar
liqin committed
439
        final ExhibitionBoard exhibitionBoard = this.exhibitionBoardService.getById(id);
liqin's avatar
liqin committed
440
        final Audit audit = Audit.builder()
liqin's avatar
liqin committed
441 442
                .content(exhibitionBoard.getName())
                .name(exhibitionBoard.getName())
liqin's avatar
liqin committed
443 444 445 446 447 448 449 450 451 452 453 454 455 456
                .userId(user.getId())
                .refItemId(id)
                .type(AuditTypeEnum.EXHIBITION_BOARD.name())
                .operation(AuditOperationEnum.REMOVE.name())
                .status(AuditStatusEnum.TBC.name())
                .level(AuditStatusEnum.TBC.name())
                .build();
        final boolean result = this.auditService.save(audit);
        if (result) {
            return getSuccessResult();
        }
        return getFailResult();
    }

liqin's avatar
liqin committed
457 458
}