ApiNotPrintException 改为 CzgException
This commit is contained in:
@@ -45,15 +45,6 @@ public class CzgControllerAdvice {
|
||||
return CzgResult.failure(CzgRespCode.NOT_LOGIN.getCode(), CzgRespCode.NOT_LOGIN + ":" + ex.getMessage());
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(value = ApiNotPrintException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public CzgResult<Object> apiNotPrintErrorHandler(ApiNotPrintException ex) {
|
||||
// setErrorLog(ex);
|
||||
log.error("校验异常:{}", ex.getMessage());
|
||||
return CzgResult.failure(ex.getMessage());
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(value = HttpMessageNotReadableException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@@ -91,7 +82,8 @@ public class CzgControllerAdvice {
|
||||
*/
|
||||
@ExceptionHandler(CzgException.class)
|
||||
public CzgResult<Object> handleCzgException(CzgException ex) {
|
||||
setErrorLog(ex);
|
||||
// setErrorLog(ex);
|
||||
log.error("CzgException校验异常:{}", ex.getMessage());
|
||||
return CzgResult.failure(ex.getCode(), ex.getMsg());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.czg.handler;
|
||||
|
||||
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.annotation.SaCheckMainShop;
|
||||
import com.czg.annotation.SaStaffCheckPermission;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.sa.StpKit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -28,7 +26,7 @@ public class SaCheckMainShopHandler implements SaAnnotationHandlerInterface<SaCh
|
||||
public void checkMethod(SaCheckMainShop at, Method method) {
|
||||
boolean mainShop = StpKit.USER.isMainShop();
|
||||
if (!mainShop) {
|
||||
throw new ApiNotPrintException("此接口仅主店可操作");
|
||||
throw new CzgException("此接口仅主店可操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.exception.CzgException;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -105,7 +104,7 @@ public class MyStpLogic {
|
||||
StpLogic logic = getLogic();
|
||||
logic.login(id);
|
||||
if (loginType.equals(LoginType.MANAGER) && shopId == null) {
|
||||
throw new ApiNotPrintException("管理端登录必须传递店铺id");
|
||||
throw new CzgException("管理端登录必须传递店铺id");
|
||||
}
|
||||
SaSession session = logic.getSession().set("userId", id).set("isAdmin", isAdmin).set("isManager", loginType.equals(LoginType.MANAGER))
|
||||
.set("platForm", platForm)
|
||||
@@ -234,7 +233,7 @@ public class MyStpLogic {
|
||||
// }
|
||||
|
||||
if (defaultValue.length == 0 && shopId == null) {
|
||||
throw new ApiNotPrintException(errType == 0 ? "shopId获取失败" : "客户端请求头未携带shopId");
|
||||
throw new CzgException(errType == 0 ? "shopId获取失败" : "客户端请求头未携带shopId");
|
||||
}
|
||||
return shopId == null ? defaultVal : shopId;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.czg.market.service;
|
||||
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkConsumeCashbackDTO;
|
||||
import com.czg.market.dto.MkConsumeDiscountDTO;
|
||||
import com.czg.market.vo.MkConsumeCashbackVO;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.market.entity.MkConsumeCashback;
|
||||
@@ -18,7 +17,7 @@ import java.math.BigDecimal;
|
||||
public interface MkConsumeCashbackService extends IService<MkConsumeCashback> {
|
||||
MkConsumeCashbackVO detail(Long shopId);
|
||||
|
||||
Boolean edit(Long shopId, MkConsumeCashbackDTO consumeDiscountDTO) throws ApiNotPrintException;
|
||||
Boolean edit(Long shopId, MkConsumeCashbackDTO consumeDiscountDTO) throws CzgException;
|
||||
|
||||
/**
|
||||
* 消费返现
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.czg.market.service;
|
||||
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkConsumeDiscountDTO;
|
||||
import com.czg.market.vo.MkConsumeDiscountVO;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
@@ -16,5 +16,5 @@ public interface MkConsumeDiscountService extends IService<MkConsumeDiscount> {
|
||||
|
||||
MkConsumeDiscountVO detail(Long shopId);
|
||||
|
||||
Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) throws ApiNotPrintException;
|
||||
Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) throws CzgException;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.czg.market.service;
|
||||
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MemberConfigDTO;
|
||||
import com.czg.market.dto.MemberLevelDTO;
|
||||
import com.czg.market.vo.*;
|
||||
@@ -26,7 +26,7 @@ public interface TbMemberConfigService extends IService<TbMemberConfig> {
|
||||
|
||||
Boolean edit(Long shopId, MemberConfigDTO memberDTO);
|
||||
|
||||
Boolean addLevel(Long shopId, MemberLevelDTO levelDTO) throws ApiNotPrintException;
|
||||
Boolean addLevel(Long shopId, MemberLevelDTO levelDTO) throws CzgException;
|
||||
|
||||
Boolean editLevel(Long shopId, MemberLevelDTO levelDTO);
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
|
||||
|
||||
package com.czg.exception;
|
||||
|
||||
import com.czg.resp.CzgRespCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
*
|
||||
* @author admin admin@cashier.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class ApiNotPrintException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
public ApiNotPrintException(String msg) {
|
||||
super(msg);
|
||||
this.code = CzgRespCode.FAILURE.getCode();
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ApiNotPrintException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
this.code = CzgRespCode.FAILURE.getCode();
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user