Commit be434022 authored by liqin's avatar liqin 💬

bug fixed

parent fdcf0567
...@@ -3,11 +3,7 @@ package cn.wisenergy.chnmuseum.party.common.mybatis; ...@@ -3,11 +3,7 @@ package cn.wisenergy.chnmuseum.party.common.mybatis;
public class MysqlGenerator { public class MysqlGenerator {
private static final String[] tableNames = new String[]{ private static final String[] tableNames = new String[]{
"learning_content", "learning_content_board"
"learning_content_board",
"learning_content_board_cat",
"learning_content_copyright_owner",
"learning_project"
}; };
// private static final String projectPath = "D:\\develop\\Project\\chnmuseum-party"; // private static final String projectPath = "D:\\develop\\Project\\chnmuseum-party";
private static final String projectPath = "/opt/ss"; private static final String projectPath = "/opt/ss";
......
...@@ -12,6 +12,7 @@ import javax.validation.constraints.NotBlank; ...@@ -12,6 +12,7 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* <p> * <p>
...@@ -82,4 +83,34 @@ public class LearningContent implements Serializable { ...@@ -82,4 +83,34 @@ public class LearningContent implements Serializable {
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime; private LocalDateTime updateTime;
@ApiModelProperty("展板分类ID列表")
@TableField(exist = false)
@NotNull(message = "展板分类ID列表不能为空", groups = {Add.class})
private List<String> exhibitionBoardCatIdList;
@ApiModelProperty("版权方ID列表")
@TableField(exist = false)
@NotNull(message = "版权方ID列表不能为空", groups = {Add.class})
private List<String> copyrightOwnerIdList;
@ApiModelProperty("展板内容ID列表")
@TableField(exist = false)
private List<String> exhibitionBoardIdList;
@ApiModelProperty("展板分类名称列表")
@TableField(exist = false)
private List<String> exhibitionBoardCatNameList;
@ApiModelProperty("版权方名称列表")
@TableField(exist = false)
private List<String> copyrightOwnerNameList;
@ApiModelProperty("学习项目名称")
@TableField(exist = false)
private String learningProjectName;
@ApiModelProperty("所含展板数量(列表使用)")
@TableField(exist = false)
private Integer exhibitionBoardCount;
} }
...@@ -41,15 +41,21 @@ public class LearningContentBoard implements Serializable { ...@@ -41,15 +41,21 @@ public class LearningContentBoard implements Serializable {
@ApiModelProperty("学习内容ID") @ApiModelProperty("学习内容ID")
@TableField("learning_content_id") @TableField("learning_content_id")
@NotBlank(message = "学习内容ID不能为空", groups = {Add.class, Update.class}) @NotBlank(message = "学习内容ID不能为空", groups = {Add.class, Update.class})
private String learningContentId; private String learningContentId;
@ApiModelProperty("展板ID") @ApiModelProperty("展板ID")
@TableField("exhibition_board_id") @TableField("exhibition_board_id")
@NotBlank(message = "展板ID不能为空", groups = {Add.class, Update.class}) @NotBlank(message = "展板ID不能为空", groups = {Add.class, Update.class})
private String exhibitionBoardId; private String exhibitionBoardId;
@ApiModelProperty("展板名称")
@TableField(exist = false)
@NotBlank(message = "展板ID不能为空", groups = {Add.class, Update.class})
private String exhibitionBoardName;
@ApiModelProperty("排序顺序")
@TableField("sortorder")
private Integer sortorder;
} }
...@@ -4,13 +4,11 @@ import cn.wisenergy.chnmuseum.party.common.enums.AuditStatusEnum; ...@@ -4,13 +4,11 @@ import cn.wisenergy.chnmuseum.party.common.enums.AuditStatusEnum;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Add; import cn.wisenergy.chnmuseum.party.common.validator.groups.Add;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Update; import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam; import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.LearningContent; import cn.wisenergy.chnmuseum.party.model.*;
import cn.wisenergy.chnmuseum.party.service.LearningContentBoardCatService; import cn.wisenergy.chnmuseum.party.service.*;
import cn.wisenergy.chnmuseum.party.service.LearningContentBoardService;
import cn.wisenergy.chnmuseum.party.service.LearningContentCopyrightOwnerService;
import cn.wisenergy.chnmuseum.party.service.LearningContentService;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -49,23 +47,36 @@ public class LearningContentController extends BaseController { ...@@ -49,23 +47,36 @@ public class LearningContentController extends BaseController {
private LearningContentBoardService learningContentBoardService; private LearningContentBoardService learningContentBoardService;
@Resource @Resource
private LearningContentCopyrightOwnerService learningContentCopyrightOwnerService; private LearningContentCopyrightOwnerService learningContentCopyrightOwnerService;
@Resource
private LearningProjectService learningProjectService;
@PostMapping("/save") @PostMapping("/save")
@RequiresPermissions("learning:content:save") @RequiresPermissions("learning:content:save")
@ApiOperation(value = "添加学习内容", notes = "添加学习内容") @ApiOperation(value = "添加学习内容", notes = "添加学习内容")
public Map<String, Object> saveLearningContent(@Validated(value = {Add.class}) LearningContent learningContent) { public Map<String, Object> saveLearningContent(@Validated(value = {Add.class}) LearningContent learningContent) {
learningContent.setAuditStatus(AuditStatusEnum.TBC.name());
learningContent.setIsPublished(false);
// 保存业务节点信息 // 保存业务节点信息
boolean result = learningContentService.save(learningContent); boolean result = learningContentService.save(learningContent);
final String learningContentId = learningContent.getId();
final List<String> exhibitionBoardCatIdList = learningContent.getExhibitionBoardCatIdList();
for (String exhibitionBoardCatId : exhibitionBoardCatIdList) {
LearningContentBoardCat learningContentBoardCat = LearningContentBoardCat.builder().exhibitionBoardCatId(exhibitionBoardCatId).learningContentId(learningContentId).build();
this.learningContentBoardCatService.save(learningContentBoardCat);
}
final List<String> copyrightOwnerIdList = learningContent.getCopyrightOwnerIdList();
for (String copyrightOwnerId : copyrightOwnerIdList) {
LearningContentCopyrightOwner contentCopyrightOwner = LearningContentCopyrightOwner.builder().copyrightOwnerId(copyrightOwnerId).learningContentId(learningContentId).build();
this.learningContentCopyrightOwnerService.save(contentCopyrightOwner);
}
final List<String> exhibitionBoardIdList = learningContent.getExhibitionBoardIdList();
for (String exhibitionBoardId : exhibitionBoardIdList) {
LearningContentBoard learningContentBoard = LearningContentBoard.builder().exhibitionBoardId(exhibitionBoardId).learningContentId(learningContentId).build();
this.learningContentBoardService.save(learningContentBoard);
}
// 返回操作结果 // 返回操作结果
if (result) { if (result) {
...@@ -80,6 +91,44 @@ public class LearningContentController extends BaseController { ...@@ -80,6 +91,44 @@ public class LearningContentController extends BaseController {
@RequiresPermissions("learning:content:update") @RequiresPermissions("learning:content:update")
@ApiOperation(value = "修改学习内容信息", notes = "修改学习内容信息") @ApiOperation(value = "修改学习内容信息", notes = "修改学习内容信息")
public Map<String, Object> updateLearningContent(@Validated(value = {Update.class}) LearningContent learningContent) { public Map<String, Object> updateLearningContent(@Validated(value = {Update.class}) LearningContent learningContent) {
learningContent.setAuditStatus(AuditStatusEnum.TBC.name());
learningContent.setIsPublished(false);
// 保存业务节点信息
final String learningContentId = learningContent.getId();
final List<String> exhibitionBoardCatIdList = learningContent.getExhibitionBoardCatIdList();
if (exhibitionBoardCatIdList != null && !exhibitionBoardCatIdList.isEmpty()) {
LambdaUpdateWrapper<LearningContentBoardCat> lambdaUpdateWrapper = Wrappers.<LearningContentBoardCat>lambdaUpdate().eq(LearningContentBoardCat::getLearningContentId, learningContentId);
this.learningContentBoardCatService.remove(lambdaUpdateWrapper);
for (String exhibitionBoardCatId : exhibitionBoardCatIdList) {
LearningContentBoardCat learningContentBoardCat = LearningContentBoardCat.builder().exhibitionBoardCatId(exhibitionBoardCatId).learningContentId(learningContentId).build();
this.learningContentBoardCatService.save(learningContentBoardCat);
}
}
final List<String> copyrightOwnerIdList = learningContent.getCopyrightOwnerIdList();
if (copyrightOwnerIdList != null && !copyrightOwnerIdList.isEmpty()) {
LambdaUpdateWrapper<LearningContentCopyrightOwner> lambdaUpdateWrapper = Wrappers.<LearningContentCopyrightOwner>lambdaUpdate().eq(LearningContentCopyrightOwner::getLearningContentId, learningContentId);
this.learningContentCopyrightOwnerService.remove(lambdaUpdateWrapper);
for (String copyrightOwnerId : copyrightOwnerIdList) {
LearningContentCopyrightOwner contentCopyrightOwner = LearningContentCopyrightOwner.builder().copyrightOwnerId(copyrightOwnerId).learningContentId(learningContentId).build();
this.learningContentCopyrightOwnerService.save(contentCopyrightOwner);
}
}
final List<String> exhibitionBoardIdList = learningContent.getExhibitionBoardIdList();
if (exhibitionBoardIdList != null && !exhibitionBoardIdList.isEmpty()) {
LambdaUpdateWrapper<LearningContentBoard> lambdaUpdateWrapper = Wrappers.<LearningContentBoard>lambdaUpdate().eq(LearningContentBoard::getLearningContentId, learningContentId);
this.learningContentBoardService.remove(lambdaUpdateWrapper);
for (String exhibitionBoardId : exhibitionBoardIdList) {
LearningContentBoard learningContentBoard = LearningContentBoard.builder().exhibitionBoardId(exhibitionBoardId).learningContentId(learningContentId).build();
this.learningContentBoardService.save(learningContentBoard);
}
}
boolean flag = learningContentService.updateById(learningContent); boolean flag = learningContentService.updateById(learningContent);
if (flag) { if (flag) {
return getSuccessResult(); return getSuccessResult();
...@@ -89,7 +138,7 @@ public class LearningContentController extends BaseController { ...@@ -89,7 +138,7 @@ public class LearningContentController extends BaseController {
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
@RequiresPermissions("learning:content:delete") @RequiresPermissions("learning:content:delete")
@ApiOperation(value = "根据ID删除学习内容", notes = "根据ID删除学习内容") @ApiOperation(value = "根据ID下架学习内容", notes = "根据ID下架学习内容")
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String") @ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
}) })
...@@ -144,7 +193,9 @@ public class LearningContentController extends BaseController { ...@@ -144,7 +193,9 @@ public class LearningContentController extends BaseController {
LearningContent::getUpdateTime); LearningContent::getUpdateTime);
Page<LearningContent> page = this.learningContentService.page(getPage(), queryWrapper); Page<LearningContent> page = this.learningContentService.page(getPage(), queryWrapper);
for (LearningContent learningContent : page.getRecords()) { for (LearningContent learningContent : page.getRecords()) {
LambdaQueryWrapper<LearningContentBoard> lambdaQueryWrapper = Wrappers.<LearningContentBoard>lambdaQuery().eq(LearningContentBoard::getLearningContentId, learningContent.getId());
int exhibitionBoardCount = this.learningContentBoardService.count(lambdaQueryWrapper);
learningContent.setExhibitionBoardCount(exhibitionBoardCount);
} }
return getResult(page); return getResult(page);
} }
...@@ -157,6 +208,10 @@ public class LearningContentController extends BaseController { ...@@ -157,6 +208,10 @@ public class LearningContentController extends BaseController {
@RequiresPermissions("learning:content:get:id") @RequiresPermissions("learning:content:get:id")
public Map<String, Object> getById(@PathVariable("id") String id) { public Map<String, Object> getById(@PathVariable("id") String id) {
LearningContent learningContent = learningContentService.getById(id); LearningContent learningContent = learningContentService.getById(id);
LearningProject learningProject = this.learningProjectService.getById(learningContent.getLearningProjectId());
if (learningProject != null) {
learningContent.setLearningProjectName(learningProject.getName());
}
return getResult(learningContent); return getResult(learningContent);
} }
......
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