Commit 0a698da7 authored by nie'hong's avatar nie'hong

修改bug

parent 2e53c8a0
package cn.chnmuseum.party.common.util;
import cn.hutool.core.collection.CollectionUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* @description:
* @author: nh
* @create: 2021-06-16 09:40
**/
public class ListUtil {
/**
* 比较两个list的值,不比较顺序
* @return
*/
public static boolean compareValue(List list1, List list2){
if (CollectionUtil.isEmpty(list1) || CollectionUtil.isEmpty(list2)) {
return false;
}
Collections.sort(list1);
Collections.sort(list2);
return list1.equals(list2);
}
}
...@@ -575,6 +575,7 @@ public class ExhibitionBoardController extends BaseController { ...@@ -575,6 +575,7 @@ public class ExhibitionBoardController extends BaseController {
if (CollectionUtil.isNotEmpty(collect)) { if (CollectionUtil.isNotEmpty(collect)) {
LambdaQueryWrapper<LearningContent> learningContentLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<LearningContent> learningContentLambdaQueryWrapper = new LambdaQueryWrapper<>();
learningContentLambdaQueryWrapper.in(LearningContent::getId, collect); learningContentLambdaQueryWrapper.in(LearningContent::getId, collect);
learningContentLambdaQueryWrapper.eq(LearningContent::getIsMajor, false);
List<LearningContent> list1 = this.learningContentService.list(learningContentLambdaQueryWrapper); List<LearningContent> list1 = this.learningContentService.list(learningContentLambdaQueryWrapper);
for (LearningContent learningContent : list1) { for (LearningContent learningContent : list1) {
if (learningContent.getPublished()) { if (learningContent.getPublished()) {
...@@ -609,7 +610,7 @@ public class ExhibitionBoardController extends BaseController { ...@@ -609,7 +610,7 @@ public class ExhibitionBoardController extends BaseController {
}) })
@MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.DELETE) @MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.DELETE)
public Map<String, Object> deleteExhibitionBoard(@PathVariable("id") String id) { public Map<String, Object> deleteExhibitionBoard(@PathVariable("id") String id) {
// 查询该展板是否被学习内容使用 // 查询该展板是否被学习内容使用
final LambdaQueryWrapper<LearningContentBoard> queryWrapper = Wrappers.lambdaQuery(); final LambdaQueryWrapper<LearningContentBoard> queryWrapper = Wrappers.lambdaQuery();
// 查询展板对应的学习内容id // 查询展板对应的学习内容id
queryWrapper.eq(LearningContentBoard::getExhibitionBoardId, id); queryWrapper.eq(LearningContentBoard::getExhibitionBoardId, id);
......
...@@ -3,6 +3,7 @@ package cn.chnmuseum.party.web.controller; ...@@ -3,6 +3,7 @@ package cn.chnmuseum.party.web.controller;
import cn.chnmuseum.party.common.log.MethodLog; import cn.chnmuseum.party.common.log.MethodLog;
import cn.chnmuseum.party.common.log.OperModule; import cn.chnmuseum.party.common.log.OperModule;
import cn.chnmuseum.party.common.log.OperType; import cn.chnmuseum.party.common.log.OperType;
import cn.chnmuseum.party.common.util.ListUtil;
import cn.chnmuseum.party.common.util.TimeUtils; import cn.chnmuseum.party.common.util.TimeUtils;
import cn.chnmuseum.party.common.validator.groups.Add; import cn.chnmuseum.party.common.validator.groups.Add;
import cn.chnmuseum.party.common.validator.groups.Update; import cn.chnmuseum.party.common.validator.groups.Update;
...@@ -21,6 +22,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -21,6 +22,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.hibernate.validator.constraints.Length;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -28,6 +30,7 @@ import org.springframework.validation.annotation.Validated; ...@@ -28,6 +30,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -72,7 +75,12 @@ public class LearningProjectController extends BaseController { ...@@ -72,7 +75,12 @@ public class LearningProjectController extends BaseController {
@MethodLog(operModule = OperModule.LEARNPROJECT, operType = OperType.ADD) @MethodLog(operModule = OperModule.LEARNPROJECT, operType = OperType.ADD)
@Transactional @Transactional
public Map<String, Object> saveLearningProject(@Validated(value = {Add.class}) LearningProject learningProject) { public Map<String, Object> saveLearningProject(@Validated(value = {Add.class}) LearningProject learningProject) {
LambdaQueryWrapper<LearningProject> lambdaQuery = Wrappers.lambdaQuery();
lambdaQuery.eq(LearningProject::getName, learningProject.getName());
LearningProject one = learningProjectService.getOne(lambdaQuery);
if (one != null) {
return getFailResult("学习项目名称已存在!");
}
// 保存业务节点信息 // 保存业务节点信息
boolean result = learningProjectService.save(learningProject); boolean result = learningProjectService.save(learningProject);
if (!result) { if (!result) {
...@@ -109,10 +117,28 @@ public class LearningProjectController extends BaseController { ...@@ -109,10 +117,28 @@ public class LearningProjectController extends BaseController {
@MethodLog(operModule = OperModule.LEARNPROJECT, operType = OperType.UPDATE) @MethodLog(operModule = OperModule.LEARNPROJECT, operType = OperType.UPDATE)
@Transactional @Transactional
public Map<String, Object> updateLearningProject(@Validated(value = {Update.class}) LearningProject learningProject) { public Map<String, Object> updateLearningProject(@Validated(value = {Update.class}) LearningProject learningProject) {
boolean flag = learningProjectService.updateById(learningProject); // 是否重名
if (!flag) { LambdaQueryWrapper<LearningProject> lambdaQuery1 = Wrappers.<LearningProject>lambdaQuery();
return getFailResult(); lambdaQuery1.eq(LearningProject::getName, learningProject.getName()).ne(LearningProject::getId, learningProject.getId());
LearningProject one1 = learningProjectService.getOne(lambdaQuery1);
if (one1 != null) {
return getFailResult("学习项目名已存在!");
}
StringBuilder resultMsg = new StringBuilder();
// 查询学习项目原有信息
LearningProject project = learningProjectService.getById(learningProject.getId());
// 项目基本信息被修改
if (!project.getName().equals(learningProject.getName()) || !project.getRemarks().equals(learningProject.getRemarks())) {
boolean flag = learningProjectService.updateById(learningProject);
if (!flag) {
return getFailResult();
}
resultMsg.append("项目信息修改成功,");
}else {
resultMsg.append("未修改项目信息,");
} }
// 查询项目的主学习内容 // 查询项目的主学习内容
LambdaQueryWrapper<LearningContent> queryWrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<LearningContent> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(LearningContent::getLearningProjectId, learningProject.getId()); queryWrapper.eq(LearningContent::getLearningProjectId, learningProject.getId());
...@@ -121,10 +147,25 @@ public class LearningProjectController extends BaseController { ...@@ -121,10 +147,25 @@ public class LearningProjectController extends BaseController {
if (one == null) { if (one == null) {
return getFailResult("该学习项目下没有主学习内容"); return getFailResult("该学习项目下没有主学习内容");
} }
// 判断是否修改主学习内容
String learningProjectMajorName = learningProject.getMajor();
String cover = learningProject.getCover();
List<String> copyrightOwnerIdList = learningProject.getCopyrightOwnerIdList();
List<String> exhibitionBoardCatIdList = learningProject.getExhibitionBoardCatIdList();
List<String> exhibitionBoardIdList = learningProject.getExhibitionBoardIdList();
if (one.getName().equals(learningProjectMajorName)
&& one.getCover().equals(cover)
&& ListUtil.compareValue(copyrightOwnerIdList, one.getCopyrightOwnerIdList())
&& ListUtil.compareValue(exhibitionBoardCatIdList, one.getExhibitionBoardCatIdList())
&& ListUtil.compareValue(exhibitionBoardIdList, one.getExhibitionBoardIdList())) {
resultMsg.append("未修改项目主学习内容信息。");
return getSuccessResult(resultMsg.toString());
}
// 查询该学习项目的子学习内容版权方、展板分类、展板 // 查询该学习项目的子学习内容版权方、展板分类、展板
LambdaQueryWrapper<LearningContent> lambdaQueryWrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<LearningContent> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(LearningContent::getLearningProjectId, learningProject.getId()); lambdaQueryWrapper.eq(LearningContent::getLearningProjectId, learningProject.getId());
// lambdaQueryWrapper.eq(LearningContent::getIsMajor, false); lambdaQueryWrapper.eq(LearningContent::getIsMajor, false);
lambdaQueryWrapper.select(LearningContent::getId); lambdaQueryWrapper.select(LearningContent::getId);
List<String> list = this.learningContentService.listObjs(lambdaQueryWrapper, Object::toString); List<String> list = this.learningContentService.listObjs(lambdaQueryWrapper, Object::toString);
if (CollectionUtil.isNotEmpty(list)) { if (CollectionUtil.isNotEmpty(list)) {
...@@ -208,6 +249,10 @@ public class LearningProjectController extends BaseController { ...@@ -208,6 +249,10 @@ public class LearningProjectController extends BaseController {
.exhibitionBoardCatIdList(learningProject.getExhibitionBoardCatIdList()) .exhibitionBoardCatIdList(learningProject.getExhibitionBoardCatIdList())
.exhibitionBoardIdList(learningProject.getExhibitionBoardIdList()).build(); .exhibitionBoardIdList(learningProject.getExhibitionBoardIdList()).build();
Map<String, Object> map = this.learningContentController.updateLearningContent(learningContent); Map<String, Object> map = this.learningContentController.updateLearningContent(learningContent);
resultMsg.append("修改学习内容已提交,待审核!");
if (map.get("resultCode").equals("200")) {
map.replace("message",resultMsg);
}
return map; return map;
} }
...@@ -302,6 +347,13 @@ public class LearningProjectController extends BaseController { ...@@ -302,6 +347,13 @@ public class LearningProjectController extends BaseController {
}) })
@MethodLog(operModule = OperModule.LEARNPROJECT, operType = OperType.DELETE) @MethodLog(operModule = OperModule.LEARNPROJECT, operType = OperType.DELETE)
public Map<String, Object> deleteLearningProject(@PathVariable("id") String id) { public Map<String, Object> deleteLearningProject(@PathVariable("id") String id) {
// 项目下的学习内容id
// LambdaQueryWrapper<LearningContent> queryWrapper = Wrappers.<LearningContent>lambdaQuery();
// queryWrapper.eq(LearningContent::getLearningProjectId, id);
// queryWrapper.select(LearningContent::getId);
// List<String> list = this.learningContentService.listObjs(queryWrapper, Object::toString);
// 删除
// this.learningContentBoardService.remove(Wrappers.<LearningContentBoard>lambdaUpdate().in(LearningContentBoard::getLearningContentId, list));
//按照王亭亭的要求 删除学习项目,不删除学习内容 所以注释掉下面一行代码 //按照王亭亭的要求 删除学习项目,不删除学习内容 所以注释掉下面一行代码
// this.learningContentService.remove(Wrappers.<LearningContent>lambdaUpdate().eq(LearningContent::getLearningProjectId, id)); // this.learningContentService.remove(Wrappers.<LearningContent>lambdaUpdate().eq(LearningContent::getLearningProjectId, id));
int count = this.learningContentService.count(Wrappers.<LearningContent>lambdaUpdate().eq(LearningContent::getLearningProjectId, id).last("LIMIT 1")); int count = this.learningContentService.count(Wrappers.<LearningContent>lambdaUpdate().eq(LearningContent::getLearningProjectId, id).last("LIMIT 1"));
......
...@@ -184,11 +184,13 @@ public class VideoContentCatController extends BaseController { ...@@ -184,11 +184,13 @@ public class VideoContentCatController extends BaseController {
@MethodLog(operModule = OperModule.VIDEOCLASSIFY, operType = OperType.DELETE) @MethodLog(operModule = OperModule.VIDEOCLASSIFY, operType = OperType.DELETE)
public Map<String, Object> deleteVideoContentCat(@PathVariable("id") String id) { public Map<String, Object> deleteVideoContentCat(@PathVariable("id") String id) {
// 该视频分类正在被使用时,不能被删除 // 该视频分类正在被使用时,不能被删除
final LambdaUpdateWrapper<CopyrightOwnerVideoContentCat> updateWrapper1 = Wrappers.<CopyrightOwnerVideoContentCat>lambdaUpdate().eq(CopyrightOwnerVideoContentCat::getVideoContentCatId, id); LambdaQueryWrapper<CopyrightOwnerVideoContentCat> lambdaQueryWrapper1 = Wrappers.<CopyrightOwnerVideoContentCat>lambdaQuery().eq(CopyrightOwnerVideoContentCat::getVideoContentCatId, id);
List<CopyrightOwnerVideoContentCat> list = this.copyrightOwnerVideoContentCatService.list(updateWrapper1); List<CopyrightOwnerVideoContentCat> list = this.copyrightOwnerVideoContentCatService.list(lambdaQueryWrapper1);
if (CollectionUtil.isNotEmpty(list)) { if (CollectionUtil.isNotEmpty(list)) {
return getFailResult("该视频分类正在被使用,不能删除"); return getFailResult("该视频分类正在被使用,不能删除");
} }
final LambdaUpdateWrapper<CopyrightOwnerVideoContentCat> updateWrapper1 = Wrappers.<CopyrightOwnerVideoContentCat>lambdaUpdate().eq(CopyrightOwnerVideoContentCat::getVideoContentCatId, id);
// 删除视频分类信息 // 删除视频分类信息
this.videoContentCatService.removeById(id); this.videoContentCatService.removeById(id);
// 删除版权方和视频分类对应信息 // 删除版权方和视频分类对应信息
......
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