App用户消息配置迁移
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
package com.njcn.cssystem.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.cssystem.api.fallback.AppInfoSetFeignClientFallbackFactory;
|
||||
import com.njcn.cssystem.pojo.po.AppInfoSet;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_SYSTEM_BOOT, path = "/appInfoSet", fallbackFactory = AppInfoSetFeignClientFallbackFactory.class,contextId = "appInfoSet")
|
||||
|
||||
public interface AppInfoSetFeignClient {
|
||||
|
||||
@PostMapping("/add")
|
||||
HttpResult<String> add(@RequestBody AppInfoSet appInfoSet);
|
||||
|
||||
@PostMapping("/queryByUserId")
|
||||
HttpResult<AppInfoSet> queryByUserId();
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.njcn.cssystem.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.cssystem.api.AppInfoSetFeignClient;
|
||||
import com.njcn.cssystem.pojo.po.AppInfoSet;
|
||||
import com.njcn.cssystem.utils.CsSystemEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/10 20:09
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AppInfoSetFeignClientFallbackFactory implements FallbackFactory<AppInfoSetFeignClient> {
|
||||
@Override
|
||||
public AppInfoSetFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = CsSystemEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new AppInfoSetFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<String> add(AppInfoSet appInfoSet) {
|
||||
log.error("{}异常,降级处理,异常为:{}","新增用户消息推送配置",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<AppInfoSet> queryByUserId() {
|
||||
log.error("{}异常,降级处理,异常为:{}","查看用户消息推送配置",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user