Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-standard-interfaces-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 39ebe000
authored
Apr 25, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增设备组合验证接口
1 parent
2d70bfea
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
5 deletions
src/main/java/cn/com/glsx/stdinterface/api/VehicleServiceClient.java
src/main/java/cn/com/glsx/stdinterface/dto/DevicesComposeVerifyBO.java
src/main/java/cn/com/glsx/stdinterface/factory/VehicleServiceFallbackFactory.java
src/main/java/cn/com/glsx/stdinterface/fallback/VehicleServiceFallbackImpl.java
src/main/java/cn/com/glsx/stdinterface/api/VehicleServiceClient.java
View file @
39ebe00
package
cn
.
com
.
glsx
.
stdinterface
.
api
;
package
cn
.
com
.
glsx
.
stdinterface
.
api
;
import
cn.com.glsx.stdinterface.dto.*
;
import
cn.com.glsx.stdinterface.dto.DevicesComposeVerifyBO
;
import
cn.com.glsx.stdinterface.factory.StatisticsInStoreFallbackFactory
;
import
cn.com.glsx.stdinterface.dto.VehicleDto
;
import
cn.com.glsx.stdinterface.factory.VehicleServiceFallbackFactory
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
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.GetMapping
;
...
@@ -9,9 +10,8 @@ import org.springframework.web.bind.annotation.PostMapping;
...
@@ -9,9 +10,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
@FeignClient
(
name
=
"ne-shield-standard-interfaces"
,
path
=
"/nesi/vehicle"
,
fallbackFactory
=
VehicleServiceFallbackFactory
.
class
,
decode404
=
true
)
@FeignClient
(
name
=
"ne-shield-standard-interfaces"
,
path
=
"/nesi/vehicle"
,
fallbackFactory
=
StatisticsInStoreFallbackFactory
.
class
,
decode404
=
true
)
public
interface
VehicleServiceClient
{
public
interface
VehicleServiceClient
{
/**
/**
...
@@ -23,4 +23,13 @@ public interface VehicleServiceClient {
...
@@ -23,4 +23,13 @@ public interface VehicleServiceClient {
@GetMapping
(
value
=
"/bysn"
)
@GetMapping
(
value
=
"/bysn"
)
public
R
<
VehicleDto
>
getVehicleBySn
(
@RequestParam
String
sn
);
public
R
<
VehicleDto
>
getVehicleBySn
(
@RequestParam
String
sn
);
/**
* 验证设备组合接口
*
* @param verifyBO
* @return
*/
@PostMapping
(
value
=
"/verifyDevicesCompose"
)
public
R
verifyDevicesCompose
(
@RequestBody
DevicesComposeVerifyBO
verifyBO
);
}
}
src/main/java/cn/com/glsx/stdinterface/dto/DevicesComposeVerifyBO.java
0 → 100644
View file @
39ebe00
package
cn
.
com
.
glsx
.
stdinterface
.
dto
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
import
java.util.List
;
@Data
public
class
DevicesComposeVerifyBO
{
/**
* 工单id
*/
private
Long
workOrderId
;
/**
* 车辆id
*/
@NotNull
private
Long
vehicleId
;
/**
* 设备列表
*/
private
List
<
SimpleDeviceItem
>
devices
;
}
src/main/java/cn/com/glsx/stdinterface/factory/VehicleServiceFallbackFactory.java
0 → 100644
View file @
39ebe00
package
cn
.
com
.
glsx
.
stdinterface
.
factory
;
import
cn.com.glsx.stdinterface.api.VehicleServiceClient
;
import
cn.com.glsx.stdinterface.fallback.VehicleServiceFallbackImpl
;
import
feign.hystrix.FallbackFactory
;
public
class
VehicleServiceFallbackFactory
implements
FallbackFactory
<
VehicleServiceClient
>
{
@Override
public
VehicleServiceClient
create
(
Throwable
throwable
)
{
VehicleServiceFallbackImpl
fallback
=
new
VehicleServiceFallbackImpl
();
fallback
.
setCause
(
throwable
);
return
fallback
;
}
}
src/main/java/cn/com/glsx/stdinterface/fallback/VehicleServiceFallbackImpl.java
0 → 100644
View file @
39ebe00
package
cn
.
com
.
glsx
.
stdinterface
.
fallback
;
import
cn.com.glsx.stdinterface.api.VehicleServiceClient
;
import
cn.com.glsx.stdinterface.dto.DevicesComposeVerifyBO
;
import
cn.com.glsx.stdinterface.dto.VehicleDto
;
import
com.glsx.plat.core.web.R
;
import
lombok.Setter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
@Slf4j
@Component
public
class
VehicleServiceFallbackImpl
implements
VehicleServiceClient
{
@Setter
private
Throwable
cause
;
@Override
public
R
<
VehicleDto
>
getVehicleBySn
(
String
sn
)
{
log
.
warn
(
"getVehicleBySn 熔断啦 {}"
,
cause
.
getMessage
());
return
R
.
ok
(
"服务异常"
);
}
@Override
public
R
verifyDevicesCompose
(
DevicesComposeVerifyBO
verifyBO
)
{
log
.
warn
(
"verifyDevicesCompose 熔断啦 {}"
,
cause
.
getMessage
());
return
R
.
ok
(
"服务异常"
);
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment