Commit 17382f5e authored by liqin's avatar liqin 💬

bug fixed

parent dde621e0
......@@ -73,7 +73,7 @@ public class GlobalExceptionAdvisor {
@ExceptionHandler(BindException.class)
@ResponseBody
public cn.wisenergy.chnmuseum.party.common.validator.HttpResult handle(BindException ex) {
String message = ex.getBindingResult().getAllErrors().stream().map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining(" \n "));
String message1 = ex.getBindingResult().getAllErrors().stream().map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining(" \n "));
// BindingResult bindingResult = ex.getBindingResult();
// StringBuilder errMsg = new StringBuilder(bindingResult.getFieldErrors().size() * 16);
// errMsg.append("Invalid request:");
......@@ -84,8 +84,13 @@ public class GlobalExceptionAdvisor {
// FieldError error = bindingResult.getFieldErrors().get(i);
// errMsg.append(error.getField()).append(":").append(error.getDefaultMessage());
// }
return new cn.wisenergy.chnmuseum.party.common.validator.HttpResult("400", message);
//throw new InterfaceException(RESPONSE_CODE_ENUM.PARAM_NOT_VALID.getCode(), errMsg.toString());
String message = Splitter.onPattern("\r\n|\n|\r").trimResults().splitToList(ex.getLocalizedMessage()).get(1);
String substring = message.substring(message.indexOf("on field"), message.indexOf("rejected value"));
if (substring.toUpperCase().contains("REMARKS")) {
return new cn.wisenergy.chnmuseum.party.common.validator.HttpResult("400", "备注" + message1, "");
}
return new cn.wisenergy.chnmuseum.party.common.validator.HttpResult("400", message1, "");
}
//处理请求参数格式错误 @RequestParam上validate失败后抛出的异常是javax.validation.ConstraintViolationException
......
......@@ -18,6 +18,12 @@ public class HttpResult {
this.message = message;
}
public HttpResult(String resultCode, String message, Object data) {
this.resultCode = resultCode;
this.message = message;
this.data = data;
}
public HttpResult(String resultCode, Object data) {
this.resultCode = resultCode;
this.data = data;
......
......@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
......@@ -62,6 +63,7 @@ public class CopyrightOwner implements Serializable {
@ApiModelProperty("备注")
@TableField("remarks")
@Length(max = 6)
private String remarks;
@ApiModelProperty("是否已删除")
......
......@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
......@@ -69,6 +70,7 @@ public class ExhibitionBoard implements Serializable {
@ApiModelProperty("简介")
@TableField("remarks")
@NotBlank(message = "简介不能为空", groups = {Add.class, Update.class})
@Length(min = 1, max = 2000)
private String remarks;
@ApiModelProperty("视频内容版权方ID")
......
......@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
......@@ -44,6 +45,7 @@ public class ExhibitionBoardCat implements Serializable {
@ApiModelProperty("备注")
@TableField("remarks")
@Length(max = 200)
private String remarks;
@ApiModelProperty("是否已删除")
......
......@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
......@@ -49,6 +50,7 @@ public class VideoContentCat implements Serializable {
@ApiModelProperty("备注")
@TableField("remarks")
@Length(max = 200)
private String remarks;
@ApiModelProperty("是否已删除")
......
......@@ -123,13 +123,13 @@ public class ExhibitionBoardCatController extends BaseController {
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "copyrightOwnerId", value = "展板内容版权方ID", paramType = "query", dataType = "String")
})
@GetMapping("/getList")
@PostMapping("/getList")
@RequiresAuthentication //@RequiresPermissions("exhibition:board:cat:list")
@ApiOperation(value = "获取展板分类全部列表(无分页)", notes = "获取展板分类全部列表(无分页)")
public Map<String, Object> getExhibitionBoardCatList(@RequestParam(value = "copyrightOwnerId", required = false) String copyrightOwnerId) {
public Map<String, Object> getExhibitionBoardCatList(@RequestParam(value = "copyrightOwnerIdList", required = false) List<String> copyrightOwnerIdList) {
final LambdaQueryWrapper<ExhibitionBoardCat> exhibitionBoardCatLambdaQueryWrapper = Wrappers.<ExhibitionBoardCat>lambdaQuery().orderByDesc(ExhibitionBoardCat::getCreateTime);
if (StringUtils.isNotBlank(copyrightOwnerId)) {
final LambdaQueryWrapper<CopyrightOwnerBoardCat> queryWrapper = Wrappers.<CopyrightOwnerBoardCat>lambdaQuery().eq(CopyrightOwnerBoardCat::getCopyrightOwnerId, copyrightOwnerId);
if (copyrightOwnerIdList != null && !copyrightOwnerIdList.isEmpty()) {
final LambdaQueryWrapper<CopyrightOwnerBoardCat> queryWrapper = Wrappers.<CopyrightOwnerBoardCat>lambdaQuery().in(CopyrightOwnerBoardCat::getCopyrightOwnerId, copyrightOwnerIdList);
queryWrapper.select(CopyrightOwnerBoardCat::getBoardCatId);
final List<String> boardCatIdList = this.copyrightOwnerBoardCatService.listObjs(queryWrapper, Object::toString);
exhibitionBoardCatLambdaQueryWrapper.in(ExhibitionBoardCat::getId, boardCatIdList);
......
......@@ -67,7 +67,6 @@ public class LearningContentController extends BaseController {
@Resource
private AssetService assetService;
@PostMapping("/save")
@RequiresAuthentication //@RequiresPermissions("learning:content:save")
@ApiOperation(value = "添加学习内容", notes = "添加学习内容")
......@@ -202,12 +201,16 @@ public class LearningContentController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("learning:content:list")
@ApiOperation(value = "获取学习内容全部列表(无分页)", notes = "获取学习内容全部列表(无分页)")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "auditStatus", value = "审核状态", paramType = "query", dataType = "String")
@ApiImplicitParam(name = "auditStatus", value = "审核状态", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "learningProjectId", value = "学习项目ID", paramType = "query", dataType = "String")
})
public Map<String, Object> getLearningContentList(@RequestParam(value = "auditStatus", defaultValue = "APPROVED_FINAL", required = false) AuditStatusEnum auditStatus) {
public Map<String, Object> getLearningContentList(@RequestParam(value = "auditStatus", defaultValue = "APPROVED_FINAL", required = false) AuditStatusEnum auditStatus,
@RequestParam(value = "learningProjectId", required = false) String learningProjectId) {
final LambdaQueryWrapper<LearningContent> lambdaQueryWrapper = Wrappers.<LearningContent>lambdaQuery().eq(LearningContent::getAuditStatus, auditStatus.name());
lambdaQueryWrapper.eq(LearningContent::getPublished, true);
lambdaQueryWrapper.eq(LearningContent::getDeleted, false);
if (StringUtils.isNotBlank(learningProjectId)) {
lambdaQueryWrapper.eq(LearningContent::getLearningProjectId, learningProjectId);
}
List<LearningContent> learningContentList = learningContentService.list(lambdaQueryWrapper);
return getResult(learningContentList);
}
......
......@@ -18,14 +18,12 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* <pre>
......@@ -123,12 +121,10 @@ public class LearningProjectController extends BaseController {
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::getPublished, true);
.eq(LearningContent::getLearningProjectId, learningProject.getId());
lambdaQueryWrapper.select(LearningContent::getName);
List<LearningContent> learningContentList = this.learningContentService.list(lambdaQueryWrapper);
String learningContentNames = learningContentList.stream().map(LearningContent::getName).collect(Collectors.joining("、"));
learningProject.setLearningContentNames(learningContentNames);
List<String> learningContentNameList = this.learningContentService.listObjs(lambdaQueryWrapper, Object::toString);
learningProject.setLearningContentNames(String.join("、", learningContentNameList));
}
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