额外参数处理

master
cheney 2 years ago
parent e6b8893c28
commit c7d5171a3d
  1. 8
      src/main/java/com/huoran/iasf/common/exception/handler/RestExceptionHandler.java
  2. 2
      src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java
  3. 2
      src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java

@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
@ -113,4 +114,11 @@ public class RestExceptionHandler {
return R.getResult(BaseResponseCode.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getCode(), builder.toString());
}
@ExceptionHandler
@ResponseStatus(HttpStatus.NOT_FOUND)
public R handle(ValidationException e) {
log.error("Exception,exception:{}", e, e);
return new R(404, e.getMessage());
}
}

@ -92,7 +92,7 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn
@Override
public List<SysColumn> listWithTreeMenuVisible(PaginationColumnReqVO column) {
if (column.getRole()!=null&&column.getRole().equals("admin") || ObjectUtil.isNotNull(column.isIsadmin()) && column.isIsadmin()){
if (column.getRole()!=null||column.getRole().equals("admin") || ObjectUtil.isNotNull(column.isIsadmin()) || column.isIsadmin()){
throw new IllegalArgumentException("参数名不能包含admin");
}
//查询所有栏目

@ -75,7 +75,7 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
@Override
public R newlyPublishedArticles(PageContentReqVO reqVO) {
if (reqVO.getRole()!=null&&reqVO.getRole().equals("admin") || ObjectUtil.isNotNull(reqVO.isIsadmin()) && reqVO.isIsadmin()){
if (reqVO.getRole()!=null||reqVO.getRole().equals("admin") || ObjectUtil.isNotNull(reqVO.isIsadmin()) || reqVO.isIsadmin()){
throw new IllegalArgumentException("参数名不能包含admin");
}
Page<PageContentRespVO> page = new Page<PageContentRespVO>(reqVO.getPageNum(), reqVO.getPageSize());

Loading…
Cancel
Save