开放添加报警记录接口调用

vehicle-liyongjie
李永杰 2024-04-06 16:23:35 +08:00
parent fc291b12f0
commit b51d8fad5d
5 changed files with 57 additions and 6 deletions

View File

@ -23,7 +23,8 @@ public class ServiceNameConstants
public static final String FILE_SERVICE = "muyu-file";
/**
* serviceid
* serviceid
*/
public static final String BUSINESS_SERVICE = "muyu-business";
}

View File

@ -11,11 +11,6 @@
<artifactId>muyu-business-remote</artifactId>
<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>

View File

@ -0,0 +1,23 @@
package com.muyu.business.remote;
import com.muyu.business.domain.req.*;
import com.muyu.business.remote.factory.*;
import com.muyu.common.core.constant.*;
import com.muyu.common.core.domain.*;
import org.springframework.cloud.openfeign.*;
import org.springframework.web.bind.annotation.*;
/**
*
*
* @Author LiYonJie
* @Date 2024/4/6
*/
@FeignClient(contextId = "remoteAlarmLogsService", value = ServiceNameConstants.BUSINESS_SERVICE, fallbackFactory = RemoteAlarmLogsFallbackFactory.class)
public interface RemoteAlarmLogsService {
/**
*
*/
@PostMapping
public Result add(@RequestBody AlarmLogsAddReq alarmLogsAddReq, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
}

View File

@ -0,0 +1,31 @@
package com.muyu.business.remote.factory;
import com.muyu.business.domain.req.*;
import com.muyu.business.remote.*;
import com.muyu.common.core.domain.*;
import org.slf4j.*;
import org.springframework.cloud.openfeign.*;
import org.springframework.stereotype.*;
/**
*
*
* @Author LiYonJie
* @Date 2024/4/6
*/
@Component
public class RemoteAlarmLogsFallbackFactory implements FallbackFactory<RemoteAlarmLogsService> {
private static final Logger log = LoggerFactory.getLogger(RemoteAlarmLogsFallbackFactory.class);
@Override
public RemoteAlarmLogsService create(Throwable throwable) {
log.error("报警日志调用失败:【{}】", throwable.getMessage());
return new RemoteAlarmLogsService() {
@Override
public Result add(AlarmLogsAddReq alarmLogsAddReq, String source) {
return Result.error("报存报警日志失败:" + throwable.getMessage());
}
};
}
}

View File

@ -0,0 +1 @@
com.muyu.business.remote.factory.RemoteAlarmLogsFallbackFactory