Compare commits
3 Commits
b198ad115c
...
615c0558d9
Author | SHA1 | Date |
---|---|---|
|
615c0558d9 | 2 years ago |
|
f6d20219a5 | 2 years ago |
|
b98af4be36 | 2 years ago |
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4" />
|
@ -1,11 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Encoding">
|
<component name="Encoding">
|
||||||
<file url="file://$PROJECT_DIR$/beacon-api/beacon-common/src/main/java" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/beacon-api/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/beacon-api/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/beacon-api/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/beacon-api/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/beacon-cache/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/beacon-common/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/beacon-common/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/beacon-test/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -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