去除 common 中的 errorDecode
This commit is contained in:
@ -5,7 +5,6 @@ import java.util.Optional;
|
|||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
import com.chinaunicom.mall.ebtp.common.bizmessage.config.BizMessageClientConfig;
|
|
||||||
import com.chinaunicom.mall.ebtp.common.bizmessage.entity.MessageRaw;
|
import com.chinaunicom.mall.ebtp.common.bizmessage.entity.MessageRaw;
|
||||||
import com.chinaunicom.mall.ebtp.common.bizmessage.entity.MessageResult;
|
import com.chinaunicom.mall.ebtp.common.bizmessage.entity.MessageResult;
|
||||||
import com.chinaunicom.mall.ebtp.common.bizmessage.fallback.BizMessageClientFallback;
|
import com.chinaunicom.mall.ebtp.common.bizmessage.fallback.BizMessageClientFallback;
|
||||||
@ -15,7 +14,7 @@ import com.chinaunicom.mall.ebtp.common.bizmessage.fallback.BizMessageClientFall
|
|||||||
*
|
*
|
||||||
* @author ajaxfan
|
* @author ajaxfan
|
||||||
*/
|
*/
|
||||||
@FeignClient(name = "biz-message-client", url = "${core-service-ebtp-extend.biz.message}", configuration = BizMessageClientConfig.class, fallback = BizMessageClientFallback.class)
|
@FeignClient(name = "biz-message-client", url = "${core-service-ebtp-extend.biz.message}", fallback = BizMessageClientFallback.class)
|
||||||
public interface BizMessageFeignClient {
|
public interface BizMessageFeignClient {
|
||||||
|
|
||||||
@PostMapping(value = "/v1/producer/")
|
@PostMapping(value = "/v1/producer/")
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package com.chinaunicom.mall.ebtp.common.bizmessage.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import com.chinaunicom.mall.ebtp.common.bizmessage.error.BizMessageErrorDecoder;
|
|
||||||
|
|
||||||
import feign.codec.ErrorDecoder;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class BizMessageClientConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ErrorDecoder bizMessageErrorDecoder() {
|
|
||||||
return new BizMessageErrorDecoder();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package com.chinaunicom.mall.ebtp.common.bizmessage.error;
|
|
||||||
|
|
||||||
import feign.Response;
|
|
||||||
import feign.codec.ErrorDecoder;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务端异常映射
|
|
||||||
*
|
|
||||||
* @author Ajaxfan
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class BizMessageErrorDecoder implements ErrorDecoder {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Exception decode(String methodKey, Response response) {
|
|
||||||
String message = response.body().toString();
|
|
||||||
log.error("Publish Message error: {}", message);
|
|
||||||
|
|
||||||
return new Exception(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.chinaunicom.mall.ebtp.common.bizmessage.exception;
|
|
||||||
|
|
||||||
public class BadRequestException extends Exception {
|
|
||||||
private static final long serialVersionUID = -5514128965548804194L;
|
|
||||||
|
|
||||||
public BadRequestException() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public BadRequestException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BadRequestException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "BadRequestException: " + getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.chinaunicom.mall.ebtp.common.bizmessage.exception;
|
|
||||||
|
|
||||||
public class NotFoundException extends Exception {
|
|
||||||
private static final long serialVersionUID = 562465843254417453L;
|
|
||||||
|
|
||||||
public NotFoundException() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotFoundException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotFoundException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "NotFoundException: " + getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user