Commit ba85d253 authored by liqin's avatar liqin 💬

bug fixed

parent 7ee932c9
......@@ -55,7 +55,8 @@ public class LearningProject implements Serializable {
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
@ApiModelProperty("相关学习内容")
@TableField(exist = false)
private String learningContentNames;
}
package cn.wisenergy.chnmuseum.party.web.controller;
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.Update;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.LearningContent;
import cn.wisenergy.chnmuseum.party.model.LearningProject;
import cn.wisenergy.chnmuseum.party.service.LearningContentService;
import cn.wisenergy.chnmuseum.party.service.LearningProjectService;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -21,9 +22,9 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* <pre>
......@@ -41,21 +42,8 @@ public class LearningProjectController extends BaseController {
@Resource
private LearningProjectService learningProjectService;
@PostMapping("/batchSave")
@RequiresPermissions("learning:project:batch:save")
@ApiOperation(value = "批量添加", notes = "批量添加")
public Map<String, Object> batchSaveLearningProject(@Validated(value = {Add.class}) List<LearningProject> learningProjectList) {
// 保存业务节点信息
boolean result = learningProjectService.saveBatch(learningProjectList);
// 返回操作结果
if (result) {
return getSuccessResult();
} else {
// 保存失败
return getFailResult();
}
}
@Resource
private LearningContentService learningContentService;
@PostMapping("/save")
@RequiresPermissions("learning:project:save")
......@@ -83,45 +71,20 @@ public class LearningProjectController extends BaseController {
return getFailResult();
}
@PutMapping("/updateAuditStatus/{id}")
@RequiresPermissions("learning:project:update:audit:status")
@ApiOperation(value = "更新审核状态", notes = "更新审核状态")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "status", value = "状态", paramType = "query", dataType = "String")
})
public Map<String, Object> updateStatus(@NotNull(message = "ID不能为空") @PathVariable("id") String id, @RequestParam("status") AuditStatusEnum status) {
UpdateWrapper<LearningProject> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id);
updateWrapper.eq("audit_status", status.name());
boolean flag = learningProjectService.update(updateWrapper);
if (flag) {
return getSuccessResult();
}
return getFailResult();
}
@DeleteMapping("/delete/{id}")
@RequiresPermissions("learning:project:delete")
@ApiOperation(value = "根据ID删除", notes = "根据ID删除")
@ApiOperation(value = "根据ID下架学习项目", notes = "根据ID下架学习项目")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
})
public Map<String, Object> deleteLearningProject(@PathVariable("id") String id) {
boolean result = learningProjectService.removeById(id);
if (result) {
return getSuccessResult();
}
return getFailResult();
}
@GetMapping("/getList")
@RequiresPermissions("learning:project:list")
@ApiOperation(value = "获取全部列表(无分页)", notes = "获取全部列表(无分页)")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "auditStatus", value = "审核状态", paramType = "query", dataType = "String")
})
public Map<String, Object> getLearningProjectList(@RequestParam(value = "auditStatus", defaultValue = "APPROVED_FINAL", required = false) AuditStatusEnum auditStatus) {
public Map<String, Object> getLearningProjectList() {
List<LearningProject> learningProjectList = learningProjectService.list();
return getResult(learningProjectList);
}
......@@ -158,7 +121,13 @@ public class LearningProjectController extends BaseController {
LearningProject::getUpdateTime);
Page<LearningProject> page = this.learningProjectService.page(getPage(), queryWrapper);
for (LearningProject learningProject : page.getRecords()) {
LambdaQueryWrapper<LearningContent> lambdaQueryWrapper = Wrappers.<LearningContent>lambdaQuery()
.eq(LearningContent::getLearningProjectId, learningProject.getId())
.eq(LearningContent::getIsPublished, true);
lambdaQueryWrapper.select(LearningContent::getName);
List<LearningContent> learningContentList = this.learningContentService.list(lambdaQueryWrapper);
String learningContentNames = learningContentList.stream().map(LearningContent::getName).collect(Collectors.joining("、"));
learningProject.setLearningContentNames(learningContentNames);
}
return getResult(page);
}
......
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