Commit 4969fe17 authored by nie'hong's avatar nie'hong

增加主学习内容,修改学习项目、学习内容新建的逻辑

parent 7a2f8ebd
......@@ -96,20 +96,6 @@ public class LearningProject implements Serializable {
@TableField(exist = false)
private List<String> exhibitionBoardIdList;
// 以下字段在修改项目时使用
@ApiModelProperty("项目的子学习内容所使用展板")
@TableField(exist = false)
private List<String> minorLearningContentBoard;
@ApiModelProperty("项目的子学习内容所使用展板分类")
@TableField(exist = false)
private List<String> minorLearningContentCatBoard;
@ApiModelProperty("项目的子学习内容所使用展板版权方")
@TableField(exist = false)
private List<String> minorLearningContentCopyright;
@ApiModelProperty("项目的主学习内容对象")
@TableField(exist = false)
private LearningContent majorLearning;
......
......@@ -187,7 +187,7 @@ public class CopyrightOwnerController extends BaseController {
@ApiOperation(value = "根据学习项目获取版权方列表", notes = "根据学习项目获取版权方列表")
@ApiImplicitParam(name = "id",value = "学习项目主键")
// @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.SELECT)
public Map<String, Object> getListByLearningProjectId(String learningProjectId){
public Map<String, Object> getListByLearningProjectId(String learningProjectId, CopyrightOwnerTypeEnum copyrightOwnerType){
if (StringUtils.isBlank(learningProjectId)) {
return getFailResult("学习项目不能为空");
}
......@@ -210,7 +210,11 @@ public class CopyrightOwnerController extends BaseController {
}
// 根据主键获取这些版权方信息
List<CopyrightOwner> copyrightOwners = this.copyrightOwnerService.listByIds(list);
LambdaQueryWrapper<CopyrightOwner> copyrightOwnerLambdaQueryWrapper = Wrappers.<CopyrightOwner>lambdaQuery();
copyrightOwnerLambdaQueryWrapper.in(CopyrightOwner::getId, list);
copyrightOwnerLambdaQueryWrapper.le(CopyrightOwner::getExpireDateStart, TimeUtils.getDateTimeOfTimestamp(System.currentTimeMillis()).toLocalDate()).ge(CopyrightOwner::getExpireDateEnd, TimeUtils.getDateTimeOfTimestamp(System.currentTimeMillis()).toLocalDate());
copyrightOwnerLambdaQueryWrapper.eq(CopyrightOwner::getOwnerType, copyrightOwnerType);
List<CopyrightOwner> copyrightOwners = this.copyrightOwnerService.list(copyrightOwnerLambdaQueryWrapper);
return getResult(copyrightOwners);
}
......
......@@ -3,6 +3,7 @@ package cn.chnmuseum.party.web.controller;
import cn.chnmuseum.party.common.log.MethodLog;
import cn.chnmuseum.party.common.log.OperModule;
import cn.chnmuseum.party.common.log.OperType;
import cn.chnmuseum.party.common.util.TimeUtils;
import cn.chnmuseum.party.common.validator.groups.Add;
import cn.chnmuseum.party.common.validator.groups.Update;
import cn.chnmuseum.party.common.vo.GenericPageParam;
......@@ -56,6 +57,13 @@ public class LearningProjectController extends BaseController {
private LearningContentBoardCatService learningContentBoardCatService;
@Resource
private LearningContentCopyrightOwnerService learningContentCopyrightOwnerService;
@Resource
private CopyrightOwnerService copyrightOwnerService;
@Resource
private ExhibitionBoardCatService exhibitionBoardCatService;
@Resource
private ExhibitionBoardService exhibitionBoardService;
@PostMapping("/save")
@RequiresAuthentication //@RequiresPermissions("learning:project:save")
......@@ -112,6 +120,62 @@ public class LearningProjectController extends BaseController {
if (one == null) {
return getFailResult("该学习项目下没有主学习内容");
}
// 查询该学习项目的子学习内容版权方、展板分类、展板
LambdaQueryWrapper<LearningContent> lambdaQueryWrapper = Wrappers.<LearningContent>lambdaQuery();
lambdaQueryWrapper.eq(LearningContent::getLearningProjectId, learningProject.getId());
lambdaQueryWrapper.eq(LearningContent::getIsMajor, false);
lambdaQueryWrapper.select(LearningContent::getId);
List<String> list = this.learningContentService.listObjs(lambdaQueryWrapper, Object::toString);
if (CollectionUtil.isNotEmpty(list)) {
// 查询子学习内容的版权方
LambdaQueryWrapper<LearningContentCopyrightOwner> query = Wrappers.<LearningContentCopyrightOwner>lambdaQuery();
query.in(LearningContentCopyrightOwner::getLearningContentId, list);
query.select(LearningContentCopyrightOwner::getCopyrightOwnerId);
List<String> list1 = this.learningContentCopyrightOwnerService.listObjs(query, Object::toString);
// 修改主内容的版权信息中删除了子学习内容的版权信息
if (CollectionUtil.isNotEmpty(list1) && !learningProject.getCopyrightOwnerIdList().containsAll(list1)) {
list1.removeAll(learningProject.getCopyrightOwnerIdList());
// 查询子学习内容中被删除的版权方信息
List<CopyrightOwner> copyrightOwners = this.copyrightOwnerService.listByIds(list1);
StringBuilder stringBuilder = new StringBuilder();
copyrightOwners.forEach(s -> stringBuilder.append(s.getName()+ "、"));
return getFailResult("展板版权方:" + stringBuilder + "。被子学习内容使用,不能被删除,更新失败!");
}
// 查询子学习内容的展板分类
LambdaQueryWrapper<LearningContentBoardCat> query1 = Wrappers.<LearningContentBoardCat>lambdaQuery();
query1.in(LearningContentBoardCat::getLearningContentId, list);
query1.select(LearningContentBoardCat::getExhibitionBoardCatId);
List<String> list2 = this.learningContentBoardCatService.listObjs(query1, Object::toString);
// 主学习内容展板分类不能完全子学习内容的展板分类
if (CollectionUtil.isNotEmpty(list2) && !learningProject.getExhibitionBoardCatIdList().containsAll(list2)) {
// 差集
list2.removeAll(learningProject.getExhibitionBoardCatIdList());
// 查询被删除的展板分类信息
List<ExhibitionBoardCat> learningContentBoardCats = this.exhibitionBoardCatService.listByIds(list2);
StringBuilder stringBuilder = new StringBuilder();
learningContentBoardCats.forEach(s -> stringBuilder.append(s.getName()));
return getFailResult("展板类别:" + stringBuilder + "。被子学习内容使用,不能被删除,更新失败");
}
// 查询子学习内容的展板
LambdaQueryWrapper<LearningContentBoard> query2 = Wrappers.<LearningContentBoard>lambdaQuery();
query2.in(LearningContentBoard::getLearningContentId, list);
query2.select(LearningContentBoard::getExhibitionBoardId);
List<String> list3 = this.learningContentBoardService.listObjs(query2, Object::toString);
// 修改主要学习内容时删除了子学习内容所使用展板
if (CollectionUtil.isNotEmpty(list3) && !learningProject.getExhibitionBoardIdList().containsAll(list3)) {
// 差集
list3.retainAll(learningProject.getExhibitionBoardIdList());
// 查询被删除的展板信息
List<ExhibitionBoard> exhibitionBoards = this.exhibitionBoardService.listByIds(list3);
StringBuilder stringBuilder = new StringBuilder();
exhibitionBoards.forEach(s -> stringBuilder.append(s.getName()));
return getFailResult("展板:" + stringBuilder + "。被子学习内容使用,不能被删除,更新失败!");
}
}
LearningContent learningContent = LearningContent.builder()
.id(one.getId())
.name(learningProject.getMajor())
......@@ -188,35 +252,13 @@ public class LearningProjectController extends BaseController {
lambdaQuery.eq(LearningContent::getLearningProjectId, id);
lambdaQuery.eq(LearningContent::getIsMajor, true);
LearningContent majorLearningContent = this.learningContentService.getOne(lambdaQuery);
Map<String, Object> map = this.learningContentController.getById(majorLearningContent.getId());
LearningContent data = (LearningContent) map.get("data");
learningProject.setMajorLearning(data);
if (majorLearningContent != null) {
Map<String, Object> map = this.learningContentController.getById(majorLearningContent.getId());
LearningContent data = (LearningContent) map.get("data");
learningProject.setMajorLearning(data);
}
// 该项目下所有的子学习内容
lambdaQuery.clear();
lambdaQuery.eq(LearningContent::getLearningProjectId, id);
lambdaQuery.eq(LearningContent::getIsMajor, false);
lambdaQuery.select(LearningContent::getId);
List<String> contentIds = this.learningContentService.listObjs(lambdaQuery,Object::toString);
// 子学习内容所使用展板,展板分类,展板版权方
if (CollectionUtil.isNotEmpty(contentIds)) {
// 展板
LambdaQueryWrapper<LearningContentBoard> in = Wrappers.<LearningContentBoard>lambdaQuery().in(LearningContentBoard::getLearningContentId, contentIds);
in.select(LearningContentBoard::getExhibitionBoardId);
List<String> contentBoards = this.learningContentBoardService.listObjs(in, Object::toString);
learningProject.setMinorLearningContentBoard(contentBoards);
// 展板分类
LambdaQueryWrapper<LearningContentBoardCat> catLambdaQueryWrapper = Wrappers.<LearningContentBoardCat>lambdaQuery().in(LearningContentBoardCat::getLearningContentId, contentIds);
catLambdaQueryWrapper.select(LearningContentBoardCat::getExhibitionBoardCatId);
List<String> list = this.learningContentBoardCatService.listObjs(catLambdaQueryWrapper, Object::toString);
learningProject.setMinorLearningContentCatBoard(list);
// 展板版权方
LambdaQueryWrapper<LearningContentCopyrightOwner> lambdaQueryWrapper = Wrappers.<LearningContentCopyrightOwner>lambdaQuery().in(LearningContentCopyrightOwner::getLearningContentId, contentIds);
lambdaQueryWrapper.select(LearningContentCopyrightOwner::getCopyrightOwnerId);
List<String> list1 = this.learningContentCopyrightOwnerService.listObjs(lambdaQueryWrapper, Object::toString);
learningProject.setMinorLearningContentCopyright(list1);
}
return getResult(learningProject);
}
......
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