Commit 7a2f8ebd authored by nie'hong's avatar nie'hong

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

parent 91d8305c
......@@ -39,7 +39,7 @@ public class AddressUtil {
* @throws UnsupportedEncodingException
*/
public static String getAddresses(String content, String encodingString) throws UnsupportedEncodingException {
//调用淘宝API
//调用太平洋API
String urlStr = "http://whois.pconline.com.cn/ipJson.jsp?json=true";
String returnStr = getResult(urlStr, content, encodingString);
......@@ -107,8 +107,6 @@ public class AddressUtil {
}
public static Map<String, String> getAddressByIp(String ip) {
// 参数ip
// ip = "122.49.20.247";
// json_result用于接收返回的json数据
String json_result = null;
Map<String, String> map = new HashMap<>();
......
......@@ -13,6 +13,7 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
......@@ -70,8 +71,47 @@ public class LearningProject implements Serializable {
@TableField(exist = false)
private String exhibitionBoardNames;
@ApiModelProperty("主要学习内容")
// 以下字段在新建时使用
@ApiModelProperty("主学习内容名称")
@TableField(exist = false)
private LearningContent majorLearningContent;
private String major;
@ApiModelProperty("主学习内容id")
@TableField(exist = false)
private String majorLearningContentId;
@ApiModelProperty("宣传图")
@TableField(exist = false)
private String cover;
@ApiModelProperty("展板类别")
@TableField(exist = false)
private List<String> exhibitionBoardCatIdList;
@ApiModelProperty("版权方")
@TableField(exist = false)
private List<String> copyrightOwnerIdList;
@ApiModelProperty("展板备选")
@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;
}
......@@ -182,6 +182,39 @@ public class CopyrightOwnerController extends BaseController {
return getResult(copyrightOwnerList);
}
@GetMapping("/getListByLearningProjectId")
@RequiresAuthentication
@ApiOperation(value = "根据学习项目获取版权方列表", notes = "根据学习项目获取版权方列表")
@ApiImplicitParam(name = "id",value = "学习项目主键")
// @MethodLog(operModule = OperModule.DISPLAYCOPYRIGHT, operType = OperType.SELECT)
public Map<String, Object> getListByLearningProjectId(String learningProjectId){
if (StringUtils.isBlank(learningProjectId)) {
return getFailResult("学习项目不能为空");
}
// 获取该项目下的主学习内容
LambdaQueryWrapper lambdaQueryWrapper = Wrappers.<LearningContent>lambdaQuery()
.eq(LearningContent::getLearningProjectId, learningProjectId)
.eq(LearningContent::getIsMajor, true);
LearningContent one = this.learningContentService.getOne(lambdaQueryWrapper);
if (one == null) {
return getFailResult("该学习项目没有主学习内容!");
}
// 获取主学习内容的版权方主键
LambdaQueryWrapper<LearningContentCopyrightOwner> lambdaQuery = Wrappers.<LearningContentCopyrightOwner>lambdaQuery();
lambdaQuery.eq(LearningContentCopyrightOwner::getLearningContentId, one.getId());
lambdaQuery.select(LearningContentCopyrightOwner::getCopyrightOwnerId);
List<String> list = this.learningContentCopyrightOwnerService.listObjs(lambdaQuery, Object::toString);
if (CollectionUtil.isEmpty(list)) {
return getFailResult("该项目主学习内容没有版权方!");
}
// 根据主键获取这些版权方信息
List<CopyrightOwner> copyrightOwners = this.copyrightOwnerService.listByIds(list);
return getResult(copyrightOwners);
}
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
......
......@@ -137,6 +137,41 @@ public class ExhibitionBoardCatController extends BaseController {
return getResult(exhibitionBoardCatList);
}
@PostMapping("/getListByProjectAndCopyright")
@RequiresAuthentication
@ApiOperation(value = "获取学习项目下某个版权方的展板分类", notes = "获取学习项目下某个版权方的展板分类")
@ApiImplicitParams({
@ApiImplicitParam(name = "copyrightIds",value = "版权方主键"),
@ApiImplicitParam(name = "projectId", value = "学习项目主键")
})
@MethodLog(operModule = OperModule.DISPLAYCLASSIFY, operType = OperType.SELECT)
public Map<String, Object> getListByProjectAndCopyright(@RequestParam(value = "copyrightIds")List<String> copyrightIds, String learningProjectId){
if (StringUtils.isBlank(learningProjectId) || org.apache.commons.collections.CollectionUtils.isEmpty(copyrightIds)) {
return getFailResult("请选择项目和版权方!");
}
// 获取版权方展板分类
Map<String, Object> map = this.getExhibitionBoardCatList(copyrightIds);
List<ExhibitionBoardCat> data = (List<ExhibitionBoardCat>) map.get("data");
// 获取该项目主学习内容
LambdaQueryWrapper<LearningContent> eq = Wrappers.<LearningContent>lambdaQuery()
.eq(LearningContent::getLearningProjectId, learningProjectId)
.eq(LearningContent::getIsMajor, true);
LearningContent one = this.learningContentService.getOne(eq);
if (one == null) {
return getFailResult("该项目没有主学习内容!");
}
// 获取该学习内容下的展板分类
LambdaQueryWrapper<LearningContentBoardCat> wrapper = Wrappers.<LearningContentBoardCat>lambdaQuery();
wrapper.eq(LearningContentBoardCat::getLearningContentId, one.getId());
wrapper.select(LearningContentBoardCat::getExhibitionBoardCatId);
List<String> list = this.learningContentBoardCatService.listObjs(wrapper,Object::toString);
List<ExhibitionBoardCat> list1 = this.exhibitionBoardCatService.listByIds(list);
data.retainAll(list1);
return getResult(data);
}
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
......
......@@ -17,6 +17,7 @@ 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.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
......@@ -234,9 +235,12 @@ public class ExhibitionBoardController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("exhibition:board:list")
@ApiOperation(value = "根据学习项目获取展板全部列表(无分页)", notes = "根据学习项目获取展板全部列表(无分页)")
@MethodLog(operModule = OperModule.DISPLAYCONTENT, operType = OperType.SELECT)
public Map<String, Object> getExhibitionBoardList(String learningProjectId) {
public Map<String, Object> getExhibitionBoardList(String learningProjectId, @RequestParam(value = "exhibitionBoardCatIdList") List<String> boardCatIds) {
if (StringUtils.isBlank(learningProjectId)) {
return getFailResult("学习项目为空");
return getFailResult("学习项目不能为空!");
}
if (CollectionUtils.isEmpty(boardCatIds)) {
return getFailResult("请选择展板分类!");
}
// 查询该学习项目的主要学习内容
LambdaQueryWrapper<LearningContent> lambdaQueryWrapper = Wrappers.<LearningContent>lambdaQuery();
......@@ -250,7 +254,11 @@ public class ExhibitionBoardController extends BaseController {
List<LearningContentBoard> list = this.learningContentBoardService.list(learningContentBoardLambdaQueryWrapper);
List<String> boardId = list.stream().map(LearningContentBoard::getExhibitionBoardId).collect(Collectors.toList());
List<ExhibitionBoard> exhibitionBoardList = exhibitionBoardService.listByIds(boardId);
// 查询在指定展板分类下的展板信息
LambdaQueryWrapper<ExhibitionBoard> lambdaQuery = Wrappers.<ExhibitionBoard>lambdaQuery();
lambdaQuery.in(ExhibitionBoard::getExhibitionBoardCatId, boardCatIds);
lambdaQuery.in(ExhibitionBoard::getId, boardId);
List<ExhibitionBoard> exhibitionBoardList = exhibitionBoardService.list(lambdaQuery);
for (ExhibitionBoard exhibitionBoard : exhibitionBoardList) {
if (exhibitionBoard.getBoardCopyrightOwnerId() != null) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getBoardCopyrightOwnerId());
......@@ -604,17 +612,12 @@ public class ExhibitionBoardController extends BaseController {
public Map<String, Object> deleteExhibitionBoard(@PathVariable("id") String id) {
// 查询该展板是否被子学习内容使用
final LambdaQueryWrapper<LearningContentBoard> queryWrapper = Wrappers.lambdaQuery();
// 查询展板对应的学习内容id
queryWrapper.eq(LearningContentBoard::getExhibitionBoardId, id);
queryWrapper.select(LearningContentBoard::getLearningContentId);
List<LearningContentBoard> list = this.learningContentBoardService.list(queryWrapper);
List<String> collect = list.stream().map(LearningContentBoard::getLearningContentId).collect(Collectors.toList());
LambdaQueryWrapper<LearningContent> boardLambdaQueryWrapper = new LambdaQueryWrapper<>();
boardLambdaQueryWrapper.in(LearningContent::getId, collect);
List<LearningContent> learningContents = this.learningContentService.list(boardLambdaQueryWrapper);
for (LearningContent learningContent : learningContents) {
if (!learningContent.getIsMajor()) {
return getFailResult("该展板被子学习内容使用,不能被删除!");
}
List<String> list = this.learningContentBoardService.listObjs(queryWrapper,Object::toString);
if (CollectionUtil.isNotEmpty(list)) {
return getFailResult("该展板被学习内容使用,不能被删除!");
}
TUser user = getcurUser();
......
......@@ -272,6 +272,8 @@ public class LearningContentController extends BaseController {
@MethodLog(operModule = OperModule.LEARNCONTENT, operType = OperType.SELECT)
public Map<String, Object> getLearningContentPageList(GenericPageParam genericPageParam, @RequestParam(value = "learningProjectId", required = false) String learningProjectId) {
LambdaQueryWrapper<LearningContent> queryWrapper = new LambdaQueryWrapper<>();
// 分页查询这里不包括主学习内容
queryWrapper.eq(LearningContent::getIsMajor, false);
List<String> curUserSubOrgIds = getCurUserSubOrgIds();
if (!CollectionUtils.isEmpty(curUserSubOrgIds)){
List<String> list = Arrays.asList("ALL_PLAT");
......
......@@ -6,11 +6,10 @@ 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.LearningContent;
import cn.chnmuseum.party.model.LearningProject;
import cn.chnmuseum.party.service.LearningContentService;
import cn.chnmuseum.party.service.LearningProjectService;
import cn.chnmuseum.party.model.*;
import cn.chnmuseum.party.service.*;
import cn.chnmuseum.party.web.controller.base.BaseController;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -22,6 +21,8 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -49,21 +50,37 @@ public class LearningProjectController extends BaseController {
private LearningContentService learningContentService;
@Autowired
private LearningContentController learningContentController;
@Resource
private LearningContentBoardService learningContentBoardService;
@Resource
private LearningContentBoardCatService learningContentBoardCatService;
@Resource
private LearningContentCopyrightOwnerService learningContentCopyrightOwnerService;
@PostMapping("/save")
@RequiresAuthentication //@RequiresPermissions("learning:project:save")
@ApiOperation(value = "添加", notes = "添加")
@MethodLog(operModule = OperModule.LEARNPROJECT, operType = OperType.ADD)
@Transactional
public Map<String, Object> saveLearningProject(@Validated(value = {Add.class}) LearningProject learningProject) {
// 保存业务节点信息
boolean result = learningProjectService.save(learningProject);
if (!result) {
return getFailResult();
}
// 该学习项目下的主学习内容
LearningContent majorLearningContent = learningProject.getMajorLearningContent();
majorLearningContent.setLearningProjectId(learningProject.getId());
majorLearningContent.setApplicableScope("ALL_PLAT");
LearningContent majorLearningContent = LearningContent.builder()
.learningProjectId(learningProject.getId())
.applicableScope("ALL_PLAT")
.name(learningProject.getMajor())
.cover(learningProject.getCover())
.exhibitionBoardCatIdList(learningProject.getExhibitionBoardCatIdList())
.copyrightOwnerIdList(learningProject.getCopyrightOwnerIdList())
.exhibitionBoardIdList(learningProject.getExhibitionBoardIdList())
.build();
Map<String, Object> resultMap = learningContentController.saveLearningContent(majorLearningContent, true);
if (!resultMap.get("resultCode").equals("200")) {
return getFailResult();
......@@ -81,12 +98,29 @@ public class LearningProjectController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("learning:project:update")
@ApiOperation(value = "修改信息", notes = "修改信息")
@MethodLog(operModule = OperModule.LEARNPROJECT, operType = OperType.UPDATE)
@Transactional
public Map<String, Object> updateLearningProject(@Validated(value = {Update.class}) LearningProject learningProject) {
boolean flag = learningProjectService.updateById(learningProject);
if (flag) {
return getSuccessResult();
if (!flag) {
return getFailResult();
}
// 查询项目的主学习内容
LambdaQueryWrapper<LearningContent> queryWrapper = Wrappers.<LearningContent>lambdaQuery();
queryWrapper.eq(LearningContent::getLearningProjectId, learningProject.getId());
queryWrapper.eq(LearningContent::getIsMajor, true);
LearningContent one = this.learningContentService.getOne(queryWrapper);
if (one == null) {
return getFailResult("该学习项目下没有主学习内容");
}
return getFailResult();
LearningContent learningContent = LearningContent.builder()
.id(one.getId())
.name(learningProject.getMajor())
.copyrightOwnerIdList(learningProject.getCopyrightOwnerIdList())
.cover(learningProject.getCover())
.exhibitionBoardCatIdList(learningProject.getExhibitionBoardCatIdList())
.exhibitionBoardIdList(learningProject.getExhibitionBoardIdList()).build();
this.learningContentController.updateLearningContent(learningContent);
return getSuccessResult();
}
@GetMapping("/getList")
......@@ -149,6 +183,40 @@ public class LearningProjectController extends BaseController {
@MethodLog(operModule = OperModule.LEARNPROJECT, operType = OperType.SELECT)
public Map<String, Object> getById(@PathVariable("id") String id) {
LearningProject learningProject = learningProjectService.getById(id);
// 该项目的主学习内容
LambdaQueryWrapper<LearningContent> lambdaQuery = Wrappers.lambdaQuery();
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);
// 该项目下所有的子学习内容
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