微服务拆分2

highway
zhaoxiaolin 1 year ago
parent 3c4917cb28
commit b2e861f314

@ -0,0 +1,28 @@
package com.op.system.api;
import com.op.common.core.constant.ServiceNameConstants;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.domain.R;
import com.op.system.api.factory.RemotePlanFallbackFactory;
import com.op.system.api.model.SapProOrder;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
*
*
* @author OP
*/
@FeignClient(contextId = "remotePlanService", value = ServiceNameConstants.PLAN_SERVICE, fallbackFactory = RemotePlanFallbackFactory.class)
public interface RemotePlanService {
@PostMapping("/order/sapAddOrder")
public R<Boolean> sapAddOrder(@RequestBody SapProOrder sapProOrder);
}

@ -0,0 +1,25 @@
package com.op.system.api;
import com.op.common.core.constant.ServiceNameConstants;
import com.op.common.core.domain.R;
import com.op.system.api.factory.RemoteTechnologyFallbackFactory;
import com.op.system.api.model.SapProOrder;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
*
*
* @author OP
*/
@FeignClient(contextId = "remoteTechnologyService", value = ServiceNameConstants.TECH_SERVICE, fallbackFactory = RemoteTechnologyFallbackFactory.class)
public interface RemoteTechnologyService {
@PostMapping("/order/sapAddOrder")
public R<Boolean> sapAddOrder(@RequestBody SapProOrder sapProOrder);
}

@ -0,0 +1,35 @@
package com.op.system.api.factory;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.domain.R;
import com.op.system.api.RemotePlanService;
import com.op.system.api.model.SapProOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
*
* @author OP
*/
@Component
public class RemotePlanFallbackFactory implements FallbackFactory<RemotePlanService> {
private static final Logger log = LoggerFactory.getLogger(RemotePlanFallbackFactory.class);
@Override
public RemotePlanService create(Throwable throwable) {
log.error("Plan服务调用失败:{}", throwable.getMessage());
return new RemotePlanService() {
@Override
public R<Boolean> sapAddOrder(SapProOrder sapProOrder) {
return R.fail("新增SAP订单失败:" + throwable.getMessage());
}
};
}
}

@ -0,0 +1,32 @@
package com.op.system.api.factory;
import com.op.common.core.domain.R;
import com.op.system.api.RemoteTechnologyService;
import com.op.system.api.model.SapProOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
/**
*
*
* @author OP
*/
@Component
public class RemoteTechnologyFallbackFactory implements FallbackFactory<RemoteTechnologyService> {
private static final Logger log = LoggerFactory.getLogger(RemoteTechnologyFallbackFactory.class);
@Override
public RemoteTechnologyService create(Throwable throwable) {
log.error("Technology服务调用失败:{}", throwable.getMessage());
return new RemoteTechnologyService() {
@Override
public R<Boolean> sapAddOrder(SapProOrder sapProOrder) {
return R.fail("新增SAP订单失败:" + throwable.getMessage());
}
};
}
}

@ -2,3 +2,5 @@ com.op.system.api.factory.RemoteUserFallbackFactory
com.op.system.api.factory.RemoteLogFallbackFactory com.op.system.api.factory.RemoteLogFallbackFactory
com.op.system.api.factory.RemoteFileFallbackFactory com.op.system.api.factory.RemoteFileFallbackFactory
com.op.system.api.factory.RemoteMesFallbackFactory com.op.system.api.factory.RemoteMesFallbackFactory
com.op.system.api.factory.RemotePlanFallbackFactory
com.op.system.api.factory.RemoteTechnologyFallbackFactory

@ -35,4 +35,12 @@ public class ServiceNameConstants {
* SAPserviceid * SAPserviceid
*/ */
public static final String SAP_SERVICE = "op-sap"; public static final String SAP_SERVICE = "op-sap";
/**
* serviceid
*/
public static final String PLAN_SERVICE = "op-plan";
/**
* serviceid
*/
public static final String TECH_SERVICE = "op-technology";
} }

Loading…
Cancel
Save