Commit f7229779 authored by nie'hong's avatar nie'hong

修改-新建展板除名称外可为空

parent 181cd6fc
......@@ -75,12 +75,12 @@ public class ExhibitionBoard implements Serializable {
@ApiModelProperty("展板内容图片URL")
@TableField("cover")
@NotBlank(message = "展板图片URL不能为空", groups = {Add.class, Update.class})
// @NotBlank(message = "展板图片URL不能为空", groups = {Add.class, Update.class})
private String cover;
@ApiModelProperty("展板内容二维码URL")
@TableField("qrcode_url")
@NotBlank(message = "展板二维码URL不能为空", groups = {Add.class, Update.class})
// @NotBlank(message = "展板二维码URL不能为空", groups = {Add.class, Update.class})
private String qrcodeUrl;
@ApiModelProperty("展板内容简介")
......
......@@ -145,7 +145,7 @@ public class AssetController extends BaseController {
for (Asset asset : assetList) {
ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
FastDFSUtils.downloadFile(asset.getFileUrlCrypto(), byteOutputStream);
map.put(asset.getId(), new ByteArrayInputStream(byteOutputStream.toByteArray()));
map.put(asset.getFileNameCrypto(), new ByteArrayInputStream(byteOutputStream.toByteArray()));
}
ZipUtil.zip(response.getOutputStream(), map.keySet().toArray(new String[0]), map.values().toArray(new InputStream[0]));
}
......
......@@ -27,15 +27,14 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -73,6 +72,7 @@ public class ExhibitionBoardController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("exhibition:board:save")
@ApiOperation(value = "添加展板", notes = "添加展板")
@MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.ADD)
@Transactional
public Map<String, Object> saveExhibitionBoard(@Validated(value = {Add.class}) ExhibitionBoard exhibitionBoard) {
final LambdaQueryWrapper<ExhibitionBoard> lambdaQueryWrapper = Wrappers.<ExhibitionBoard>lambdaQuery().eq(ExhibitionBoard::getName, exhibitionBoard.getName().trim());
final int count = this.exhibitionBoardService.count(lambdaQueryWrapper);
......@@ -81,14 +81,23 @@ public class ExhibitionBoardController extends BaseController {
}
TUser user = getcurUser();
final List<String> audioIdList = exhibitionBoard.getAudioIdList();
if (audioIdList == null || audioIdList.isEmpty()) {
return getFailResult("400", "导览音频文件必须上传");
// 6.24 需求变更:新建展板除名称以外其余都可为空
List<String> audioIdList = exhibitionBoard.getAudioIdList();
if (CollectionUtil.isEmpty(exhibitionBoard.getAudioIdList())) {
audioIdList = Collections.emptyList();
}
final List<String> datumIdList = exhibitionBoard.getDatumIdList();
if (datumIdList == null || datumIdList.isEmpty()) {
return getFailResult("400", "参考资料文件必须上传");
// if (audioIdList == null || audioIdList.isEmpty()) {
// return getFailResult("400", "导览音频文件必须上传");
// }
List<String> datumIdList = exhibitionBoard.getDatumIdList();
if (CollectionUtil.isEmpty(datumIdList)) {
datumIdList = Collections.emptyList();
}
// if (datumIdList == null || datumIdList.isEmpty()) {
// return getFailResult("400", "参考资料文件必须上传");
// }
exhibitionBoard.setAuditStatus(AuditStatusEnum.TBC.name());
exhibitionBoard.setPublished(false);
exhibitionBoard.setDeleted(false);
......@@ -149,6 +158,7 @@ public class ExhibitionBoardController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("exhibition:board:update")
@ApiOperation(value = "修改展板信息", notes = "修改展板信息")
@MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.UPDATE)
@Transactional
public Map<String, Object> updateExhibitionBoard(@Validated(value = {Update.class}) ExhibitionBoard exhibitionBoard) {
final LambdaQueryWrapper<ExhibitionBoard> lambdaQueryWrapper = Wrappers.<ExhibitionBoard>lambdaQuery().eq(ExhibitionBoard::getName, exhibitionBoard.getName().trim());
lambdaQueryWrapper.ne(ExhibitionBoard::getId, exhibitionBoard.getId());
......@@ -156,14 +166,20 @@ public class ExhibitionBoardController extends BaseController {
if (count > 0) {
return getFailResult("400", "名称已存在,请修改名称");
}
final List<String> audioIdList = exhibitionBoard.getAudioIdList();
if (audioIdList == null || audioIdList.isEmpty()) {
return getFailResult("400", "导览音频文件必须上传");
List<String> audioIdList = exhibitionBoard.getAudioIdList();
if (CollectionUtil.isEmpty(audioIdList)) {
audioIdList = Collections.emptyList();
}
final List<String> datumIdList = exhibitionBoard.getDatumIdList();
if (datumIdList == null || datumIdList.isEmpty()) {
return getFailResult("400", "参考资料文件必须上传");
// if (audioIdList == null || audioIdList.isEmpty()) {
// return getFailResult("400", "导览音频文件必须上传");
// }
List<String> datumIdList = exhibitionBoard.getDatumIdList();
if (CollectionUtil.isEmpty(datumIdList)) {
datumIdList = Collections.emptyList();
}
// if (datumIdList == null || datumIdList.isEmpty()) {
// return getFailResult("400", "参考资料文件必须上传");
// }
// 2021-05-31修改前
// removeNotInIds(audioIdList,exhibitionBoard.getId());
......@@ -192,7 +208,9 @@ public class ExhibitionBoardController extends BaseController {
}
// 2021-05-31修改后
audioIdList.addAll(datumIdList);
removeNotInIds(audioIdList, exhibitionBoard.getId());
if (CollectionUtil.isNotEmpty(audioIdList)) {
removeNotInIds(audioIdList, exhibitionBoard.getId());
}
final ExhibitionBoard one = this.exhibitionBoardService.getById(exhibitionBoard.getId());
one.setAuditStatus(AuditStatusEnum.TBC.name());
......@@ -259,31 +277,44 @@ public class ExhibitionBoardController extends BaseController {
lambdaQuery.in(ExhibitionBoard::getId, boardId);
List<ExhibitionBoard> exhibitionBoardList = exhibitionBoardService.list(lambdaQuery);
for (ExhibitionBoard exhibitionBoard : exhibitionBoardList) {
if (exhibitionBoard.getBoardCopyrightOwnerId() != null) {
// 展板版权方信息
if (StringUtils.isNotEmpty(exhibitionBoard.getBoardCopyrightOwnerId())) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getBoardCopyrightOwnerId());
if (copyrightOwner == null) {
exhibitionBoard.setBoardCopyrightOwnerName("对应的展板版权方已被删除");
} else {
exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
}
}else{
exhibitionBoard.setBoardCopyrightOwnerName("无");
}
if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
// 视频版权方信息
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId());
if (copyrightOwner == null) {
exhibitionBoard.setVideoContentCopyrightOwnerName("对应的视频内容版权方已被删除");
} else {
exhibitionBoard.setVideoContentCopyrightOwnerName(copyrightOwner.getName());
}
}else {
exhibitionBoard.setVideoContentCopyrightOwnerName("无");
}
if (exhibitionBoard.getExhibitionBoardCatId() != null) {
// 展板分类信息
if (StringUtils.isNotEmpty(exhibitionBoard.getExhibitionBoardCatId())) {
final ExhibitionBoardCat exhibitionBoardCat = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId());
if (exhibitionBoardCat == null) {
exhibitionBoard.setExhibitionBoardCatName("对应的展板分类已被删除");
} else {
exhibitionBoard.setExhibitionBoardCatName(exhibitionBoardCat.getName());
}
}else {
exhibitionBoard.setExhibitionBoardCatName("无");
}
if (exhibitionBoard.getVideoContentId() != null) {
// 展板对应的视频内容
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentId())) {
String videoContentId = exhibitionBoard.getVideoContentId();
final VideoContent videoContent = this.videoContentService.getById(videoContentId);
if (videoContent == null) {
......@@ -293,6 +324,9 @@ public class ExhibitionBoardController extends BaseController {
final List<Asset> videoList = this.assetService.list(Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId).eq(Asset::getPublished, true));
exhibitionBoard.setVideoList(videoList);
}
}else {
exhibitionBoard.setVideoContentName("无");
exhibitionBoard.setVideoList(Collections.emptyList());
}
}
return getResult(exhibitionBoardList);
......@@ -315,22 +349,31 @@ public class ExhibitionBoardController extends BaseController {
lambdaQueryWrapper.orderByDesc(ExhibitionBoard::getCreateTime);
List<ExhibitionBoard> exhibitionBoardList = exhibitionBoardService.list(lambdaQueryWrapper);
for (ExhibitionBoard exhibitionBoard : exhibitionBoardList) {
if (exhibitionBoard.getBoardCopyrightOwnerId() != null) {
// 展板版权方信息
if (StringUtils.isNotEmpty(exhibitionBoard.getBoardCopyrightOwnerId())) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getBoardCopyrightOwnerId());
if (copyrightOwner == null) {
exhibitionBoard.setBoardCopyrightOwnerName("对应的展板版权方已被删除");
} else {
exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
}
}else{
exhibitionBoard.setBoardCopyrightOwnerName("无");
}
if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
// 展板对应视频版权方信息
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId());
if (copyrightOwner == null) {
exhibitionBoard.setVideoContentCopyrightOwnerName("对应的视频内容版权方已被删除");
} else {
exhibitionBoard.setVideoContentCopyrightOwnerName(copyrightOwner.getName());
}
}else {
exhibitionBoard.setVideoContentCopyrightOwnerName("无");
}
// 展板分类信息
if (exhibitionBoard.getExhibitionBoardCatId() != null) {
final ExhibitionBoardCat exhibitionBoardCat = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId());
if (exhibitionBoardCat == null) {
......@@ -338,8 +381,12 @@ public class ExhibitionBoardController extends BaseController {
} else {
exhibitionBoard.setExhibitionBoardCatName(exhibitionBoardCat.getName());
}
}else {
exhibitionBoard.setExhibitionBoardCatName("无");
}
if (exhibitionBoard.getVideoContentId() != null) {
// 展板视频信息
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentId())) {
String videoContentId = exhibitionBoard.getVideoContentId();
final VideoContent videoContent = this.videoContentService.getById(videoContentId);
if (videoContent == null) {
......@@ -404,14 +451,19 @@ public class ExhibitionBoardController extends BaseController {
ExhibitionBoard::getUpdateTime);
Page<ExhibitionBoard> page = this.exhibitionBoardService.page(getPage(), queryWrapper);
for (ExhibitionBoard exhibitionBoard : page.getRecords()) {
if (exhibitionBoard.getBoardCopyrightOwnerId() != null) {
// 展板版权方信息
if (StringUtils.isNotEmpty(exhibitionBoard.getBoardCopyrightOwnerId())) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getBoardCopyrightOwnerId());
if (copyrightOwner == null) {
exhibitionBoard.setBoardCopyrightOwnerName("对应的展板版权方已被删除");
} else {
exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
}
}else {
exhibitionBoard.setBoardCopyrightOwnerName("无");
}
// 展板视频版权方信息
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId());
if (copyrightOwner == null) {
......@@ -424,14 +476,19 @@ public class ExhibitionBoardController extends BaseController {
exhibitionBoard.setVideoContentName("无");
}
if (exhibitionBoard.getExhibitionBoardCatId() != null) {
// 展板分类信息
if (StringUtils.isNotEmpty(exhibitionBoard.getExhibitionBoardCatId())) {
final ExhibitionBoardCat exhibitionBoardCat = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId());
if (exhibitionBoardCat == null) {
exhibitionBoard.setExhibitionBoardCatName("对应的展板分类已被删除");
} else {
exhibitionBoard.setExhibitionBoardCatName(exhibitionBoardCat.getName());
}
}else {
exhibitionBoard.setExhibitionBoardCatName("无");
}
// 展板对应视频
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentId() )) {
String videoContentId = exhibitionBoard.getVideoContentId();
final VideoContent videoContent = this.videoContentService.getById(videoContentId);
......@@ -459,11 +516,11 @@ public class ExhibitionBoardController extends BaseController {
public Map<String, Object> getById(@PathVariable("id") String id) {
ExhibitionBoard exhibitionBoard = exhibitionBoardService.getById(id);
String exhibitionBoardCatId = exhibitionBoard.getExhibitionBoardCatId();
if (exhibitionBoardCatId != null) {
if (StringUtils.isNotEmpty(exhibitionBoardCatId)) {
exhibitionBoard.setExhibitionBoardCatName(this.exhibitionBoardCatService.getById(exhibitionBoardCatId).getName());
}
String boardCopyrightOwnerId = exhibitionBoard.getBoardCopyrightOwnerId();
if (boardCopyrightOwnerId != null) {
if (StringUtils.isNotEmpty(boardCopyrightOwnerId)) {
exhibitionBoard.setBoardCopyrightOwnerName(this.copyrightOwnerService.getById(boardCopyrightOwnerId).getName());
}
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
......@@ -512,14 +569,14 @@ public class ExhibitionBoardController extends BaseController {
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) {
if (StringUtils.isNotEmpty(exhibitionBoardCatId)) {
exhibitionBoard.setExhibitionBoardCatName(this.exhibitionBoardCatService.getById(exhibitionBoardCatId).getName());
}
String boardCopyrightOwnerId = exhibitionBoard.getBoardCopyrightOwnerId();
if (boardCopyrightOwnerId != null) {
if (StringUtils.isNotEmpty(boardCopyrightOwnerId)) {
exhibitionBoard.setBoardCopyrightOwnerName(this.copyrightOwnerService.getById(boardCopyrightOwnerId).getName());
}
if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setVideoContentCopyrightOwnerName(name);
}
......@@ -543,7 +600,7 @@ public class ExhibitionBoardController extends BaseController {
exhibitionBoard.setAuditHistoryList(auditList);
final String videoContentId = exhibitionBoard.getVideoContentId();
if (videoContentId != null) {
if (StringUtils.isNotEmpty(videoContentId)) {
final VideoContent videoContent = this.videoContentService.getById(videoContentId);
if (videoContent != null) {
exhibitionBoard.setVideoContentName(videoContent.getName());
......
......@@ -520,11 +520,11 @@ public class LearningContentController extends BaseController {
for (ExhibitionBoard exhibitionBoard : exhibitionBoardList) {
String exhibitionBoardCatId = exhibitionBoard.getExhibitionBoardCatId();
if (exhibitionBoardCatId != null) {
if (StringUtils.isNotEmpty(exhibitionBoardCatId)) {
exhibitionBoard.setExhibitionBoardCatName(this.exhibitionBoardCatService.getById(exhibitionBoardCatId).getName());
}
String boardCopyrightOwnerId = exhibitionBoard.getBoardCopyrightOwnerId();
if (boardCopyrightOwnerId != null) {
if (StringUtils.isNotEmpty(boardCopyrightOwnerId)) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(boardCopyrightOwnerId);
if (copyrightOwner != null) {
exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
......@@ -592,6 +592,7 @@ public class LearningContentController extends BaseController {
learningContent.setLearningProjectName(learningProject.getName());
}
// 学习内容的展板版权方
final List<String> copyrightOwnerIdList = learningContent.getCopyrightOwnerIdList();
if (copyrightOwnerIdList != null && !copyrightOwnerIdList.isEmpty()) {
final List<CopyrightOwner> copyrightOwnerList = this.copyrightOwnerService.listByIds(copyrightOwnerIdList);
......@@ -599,6 +600,7 @@ public class LearningContentController extends BaseController {
learningContent.setCopyrightOwnerNameList(copyrightOwnerList.stream().map(CopyrightOwner::getName).collect(Collectors.toList()));
}
// 学习内容的展板分类
final List<String> exhibitionBoardCatIdList = learningContent.getExhibitionBoardCatIdList();
if (exhibitionBoardCatIdList != null && !exhibitionBoardCatIdList.isEmpty()) {
final List<ExhibitionBoardCat> exhibitionBoardCats = this.exhibitionBoardCatService.listByIds(exhibitionBoardCatIdList);
......@@ -606,6 +608,7 @@ public class LearningContentController extends BaseController {
learningContent.setExhibitionBoardCatNameList(exhibitionBoardCats.stream().map(ExhibitionBoardCat::getName).collect(Collectors.toList()));
}
// 学习内容的展板列表
final List<String> exhibitionBoardIdList = learningContent.getExhibitionBoardIdList();
if (exhibitionBoardIdList != null && !exhibitionBoardIdList.isEmpty()) {
final List<ExhibitionBoard> exhibitionBoardList = this.exhibitionBoardService.listByIds(exhibitionBoardIdList);
......@@ -620,13 +623,13 @@ public class LearningContentController extends BaseController {
exhibitionBoard.setExhibitionBoardCatName(this.exhibitionBoardCatService.getById(exhibitionBoardCatId).getName());
}
String boardCopyrightOwnerId = exhibitionBoard.getBoardCopyrightOwnerId();
if (boardCopyrightOwnerId != null) {
if (StringUtils.isNotEmpty(boardCopyrightOwnerId )) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(boardCopyrightOwnerId);
if (copyrightOwner != null) {
exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
}
}
if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId() )) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setVideoContentCopyrightOwnerName(name);
}
......@@ -645,7 +648,7 @@ public class LearningContentController extends BaseController {
exhibitionBoard.setDatumList(datumList);
String videoContentId = exhibitionBoard.getVideoContentId();
if (videoContentId != null) {
if (StringUtils.isNotEmpty(videoContentId)) {
final VideoContent videoContent = this.videoContentService.getOne(Wrappers.<VideoContent>lambdaQuery().eq(VideoContent::getId, videoContentId));
if (videoContent != null) {
assetQueryWrapper.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment