Merge remote-tracking branch 'origin/dev_price' into dev_price

zyy_db
anthonywj 2 years ago
commit d17110bcaf

@ -9,7 +9,7 @@ import lombok.Getter;
public enum ResultEnum {
SUCCESS(20000, "success"),
NOT_NETWORK(1, "系统繁忙,请稍后再试。"),
NOT_NETWORK(500, "系统繁忙,请稍后再试。"),
LOGIN_VERIFY_FALL(2, "登录失效"),
PARAM_VERIFY_FALL(3, "参数验证错误"),
AUTH_FAILED(4, "权限验证失败"),

@ -33,7 +33,7 @@ public class ResultVOUtils {
* @param data data
* @return {@link BaseResponse}
*/
public static BaseResponse success(String msg,Object data) {
public static BaseResponse success(String msg, Object data) {
BaseResponse<Object> baseResponse = new BaseResponse<>();
baseResponse.setCode(ResultEnum.SUCCESS.getCode());
baseResponse.setMessage(msg);
@ -122,6 +122,16 @@ public class ResultVOUtils {
return error(resultEnum.getCode(), message);
}
/**
*
*
* @param message
* @return {@link BaseResponse}
*/
public static BaseResponse error(String message) {
return error(ResultEnum.NOT_NETWORK.getCode(), message);
}
/**
* PageHelper
*

@ -7,7 +7,7 @@ import lombok.Getter;
*
*/
@Getter
public class JsonException extends RuntimeException{
public class JsonException extends RuntimeException {
private Integer code;
@ -25,4 +25,9 @@ public class JsonException extends RuntimeException{
super(message);
this.code = code;
}
public JsonException(String message) {
super(message);
this.code = ResultEnum.NOT_NETWORK.getCode();
}
}

@ -7,6 +7,7 @@ import com.glxp.api.common.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@ -34,12 +35,21 @@ public class GlobalExceptionHandler {
}
@ExceptionHandler({BindException.class})
public BaseResponse handlerBindException(BindException e) {
log.error(e.getMessage(), e);
boolean bindingFailure = e.getFieldError().isBindingFailure();
if(bindingFailure){
if (bindingFailure) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, e.getBindingResult().getFieldError().getDefaultMessage());
}
@ExceptionHandler({MethodArgumentNotValidException.class})
public BaseResponse handlerBindException(MethodArgumentNotValidException e) {
log.error(e.getMessage(), e);
boolean bindingFailure = e.getBindingResult().getFieldError().isBindingFailure();
if (bindingFailure) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, e.getBindingResult().getFieldError().getDefaultMessage());

@ -1,13 +1,11 @@
package com.glxp.api.service;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.dao.BaseMapperPlus;
import org.apache.poi.ss.formula.functions.T;
import java.util.List;
public class CustomServiceImpl<M extends BaseMapperPlus<M,T, T>, T> extends ServiceImpl<M, T> implements CustomService<T>{
public class CustomServiceImpl<M extends BaseMapperPlus<M, T, T>, T> extends ServiceImpl<M, T> implements CustomService<T> {
@Override
public int insertIgnore(T entity) {
return baseMapper.insertIgnore(entity);

Loading…
Cancel
Save