parent
f6d20219a5
commit
615c0558d9
@ -0,0 +1,24 @@
|
|||||||
|
package com.mashibing.api.advice;
|
||||||
|
|
||||||
|
import com.mashibing.api.util.R;
|
||||||
|
import com.mashibing.api.vo.ResultVO;
|
||||||
|
import com.mashibing.common.exception.ApiException;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-20 17:10
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestControllerAdvice
|
||||||
|
public class ApiExceptionHandler {
|
||||||
|
|
||||||
|
@ExceptionHandler(ApiException.class)
|
||||||
|
public ResultVO apiException(ApiException ex){
|
||||||
|
return R.error(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,19 @@
|
|||||||
package com.mashibing.api.client;
|
package com.mashibing.api.client;
|
||||||
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dch
|
* @author dch
|
||||||
* @create 2024-03-19 23:56
|
* @create 2024-03-20 11:54
|
||||||
*/
|
*/
|
||||||
@FeignClient(value="beacon-cache")
|
@FeignClient("beacon-cache")
|
||||||
public class BeaconCacheClient {
|
public interface BeaconCacheClient {
|
||||||
|
|
||||||
|
@GetMapping("/cache/hgetall/{key}")
|
||||||
|
Map hGetAll(@PathVariable(value = "key")String key);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package com.mashibing.api.enums;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author dch
|
|
||||||
* @create 2024-03-19 0:24
|
|
||||||
* * 一些响应信息中code和msg的对应
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
public enum SmsCodeEnum {
|
|
||||||
PARAMETER_ERROR(-10, "参数不合法!");
|
|
||||||
|
|
||||||
private Integer code;
|
|
||||||
private String msg;
|
|
||||||
|
|
||||||
SmsCodeEnum(Integer code, String msg) {
|
|
||||||
this.code = code;
|
|
||||||
this.msg = msg;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,12 @@
|
|||||||
package com.mashibing.api.filter;
|
package com.mashibing.api.filter;
|
||||||
|
|
||||||
|
import com.mashibing.common.model.StandardSubmit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dch
|
* @author dch
|
||||||
* @create 2024-03-18 23:18
|
* @create 2024-03-18 23:18
|
||||||
*/
|
*/
|
||||||
public interface CheckFilter {
|
public interface CheckFilter {
|
||||||
|
|
||||||
void check(Object obj);
|
void check(StandardSubmit submit);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.mashibing.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-20 12:05
|
||||||
|
*/
|
||||||
|
public interface CacheConstant {
|
||||||
|
|
||||||
|
String CLIENT_BUSINESS = "client_business:";
|
||||||
|
|
||||||
|
String CLIENT_SIGN = "client_sign:";
|
||||||
|
|
||||||
|
String CLIENT_TEMPLATE = "client_template:";
|
||||||
|
|
||||||
|
String CLIENT_BALANCE = "client_balance:";
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.mashibing.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-20 12:17
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum ExceptionEnums {
|
||||||
|
|
||||||
|
ERROR_APIKEY(-1,"非法的apikey"),
|
||||||
|
IP_NOT_WHITE(-2,"请求的ip不在白名单内"),
|
||||||
|
ERROR_SIGN(-3,"无可用签名"),
|
||||||
|
ERROR_TEMPLATE(-4,"无可用模板"),
|
||||||
|
ERROR_MOBILE(-5,"手机号格式不正确"),
|
||||||
|
BALANCE_NOT_ENOUGH(-6,"手客户余额不足"),
|
||||||
|
PARAMETER_ERROR(-10, "参数不合法!"),
|
||||||
|
;
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
ExceptionEnums(Integer code, String msg) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.mashibing.common.exception;
|
||||||
|
|
||||||
|
import com.mashibing.common.enums.ExceptionEnums;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dch
|
||||||
|
* @create 2024-03-20 12:15
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class ApiException extends RuntimeException {
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
public ApiException(String message, Integer code) {
|
||||||
|
super(message);
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ApiException(ExceptionEnums enums) {
|
||||||
|
super(enums.getMsg());
|
||||||
|
this.code = enums.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue