Commit ba85d253 authored by liqin's avatar liqin 💬

bug fixed

parent 7ee932c9
...@@ -15,7 +15,7 @@ import java.time.LocalDateTime; ...@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
/** /**
* <p> * <p>
* *
* </p> * </p>
* *
* @author Danny Lee * @author Danny Lee
...@@ -40,22 +40,23 @@ public class LearningProject implements Serializable { ...@@ -40,22 +40,23 @@ public class LearningProject implements Serializable {
@ApiModelProperty("学习项目名称") @ApiModelProperty("学习项目名称")
@TableField("name") @TableField("name")
@NotBlank(message = "学习项目名称不能为空", groups = {Add.class, Update.class}) @NotBlank(message = "学习项目名称不能为空", groups = {Add.class, Update.class})
private String name; private String name;
@ApiModelProperty("备注") @ApiModelProperty("备注")
@TableField("remarks") @TableField("remarks")
private String remarks; private String remarks;
@ApiModelProperty("创建日期") @ApiModelProperty("创建日期")
@TableField(value = "create_time", fill = FieldFill.INSERT) @TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime; private LocalDateTime createTime;
@ApiModelProperty("更新日期") @ApiModelProperty("更新日期")
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime; private LocalDateTime updateTime;
@ApiModelProperty("相关学习内容")
@TableField(exist = false)
private String learningContentNames;
} }
package cn.wisenergy.chnmuseum.party.web.controller; 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.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.LearningProject; 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.service.LearningProjectService;
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.UpdateWrapper; 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;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -21,9 +22,9 @@ import org.springframework.validation.annotation.Validated; ...@@ -21,9 +22,9 @@ 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.NotNull;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* <pre> * <pre>
...@@ -41,21 +42,8 @@ public class LearningProjectController extends BaseController { ...@@ -41,21 +42,8 @@ public class LearningProjectController extends BaseController {
@Resource @Resource
private LearningProjectService learningProjectService; private LearningProjectService learningProjectService;
@Resource
@PostMapping("/batchSave") private LearningContentService learningContentService;
@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();
}
}
@PostMapping("/save") @PostMapping("/save")
@RequiresPermissions("learning:project:save") @RequiresPermissions("learning:project:save")
...@@ -83,45 +71,20 @@ public class LearningProjectController extends BaseController { ...@@ -83,45 +71,20 @@ public class LearningProjectController extends BaseController {
return getFailResult(); 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}") @DeleteMapping("/delete/{id}")
@RequiresPermissions("learning:project:delete") @RequiresPermissions("learning:project: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")
}) })
public Map<String, Object> deleteLearningProject(@PathVariable("id") String id) { public Map<String, Object> deleteLearningProject(@PathVariable("id") String id) {
boolean result = learningProjectService.removeById(id); return getSuccessResult();
if (result) {
return getSuccessResult();
}
return getFailResult();
} }
@GetMapping("/getList") @GetMapping("/getList")
@RequiresPermissions("learning:project:list") @RequiresPermissions("learning:project:list")
@ApiOperation(value = "获取全部列表(无分页)", notes = "获取全部列表(无分页)") @ApiOperation(value = "获取全部列表(无分页)", notes = "获取全部列表(无分页)")
@ApiImplicitParams(value = { public Map<String, Object> getLearningProjectList() {
@ApiImplicitParam(name = "auditStatus", value = "审核状态", paramType = "query", dataType = "String")
})
public Map<String, Object> getLearningProjectList(@RequestParam(value = "auditStatus", defaultValue = "APPROVED_FINAL", required = false) AuditStatusEnum auditStatus) {
List<LearningProject> learningProjectList = learningProjectService.list(); List<LearningProject> learningProjectList = learningProjectService.list();
return getResult(learningProjectList); return getResult(learningProjectList);
} }
...@@ -158,7 +121,13 @@ public class LearningProjectController extends BaseController { ...@@ -158,7 +121,13 @@ public class LearningProjectController extends BaseController {
LearningProject::getUpdateTime); LearningProject::getUpdateTime);
Page<LearningProject> page = this.learningProjectService.page(getPage(), queryWrapper); Page<LearningProject> page = this.learningProjectService.page(getPage(), queryWrapper);
for (LearningProject learningProject : page.getRecords()) { 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); 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