|
|
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.MapperFeature;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.zsElectric.boot.charging.service.ChargingReceptionService;
|
|
|
+import com.zsElectric.boot.common.annotation.ApiRateLimit;
|
|
|
import com.zsElectric.boot.common.annotation.Log;
|
|
|
import com.zsElectric.boot.common.constant.ConnectivityConstants;
|
|
|
import com.zsElectric.boot.common.enums.LogModuleEnum;
|
|
|
@@ -31,6 +32,15 @@ public class LinkDataController {
|
|
|
|
|
|
private final JwtTokenUtil jwtTokenUtil;
|
|
|
|
|
|
+
|
|
|
+// @ApiRateLimit(
|
|
|
+// prefix = "third_party:query_token", // Redis key前缀
|
|
|
+// limitType = ApiRateLimit.LimitType.IP, // 限流类型:IP/GLOBAL/USER
|
|
|
+// count = 200, // 时间窗口内允许的最大请求次数
|
|
|
+// time = 60, // 时间窗口大小(秒)
|
|
|
+// message = "获取Token请求过于频繁,请稍后再试" // 限流提示信息
|
|
|
+// )
|
|
|
+
|
|
|
/**
|
|
|
* 获取Token
|
|
|
* Token作为全局唯一凭证,调用各接口时均需要使用,该接口作为双方获取Token的接口,双方均需要实现。
|
|
|
@@ -41,6 +51,7 @@ public class LinkDataController {
|
|
|
@Operation(summary = "获取token")
|
|
|
@PostMapping("/query_token")
|
|
|
@Log(value = "获取token", module = LogModuleEnum.PARKING, params = true, result = true)
|
|
|
+ @ApiRateLimit(prefix = "third_party:query_token", limitType = ApiRateLimit.LimitType.IP, count = 200, time = 60, message = "获取Token请求过于频繁,请稍后再试")
|
|
|
public ResponseParmsEntity getToken(@RequestBody RequestParmsEntity request) throws Exception {
|
|
|
ResponseParmsEntity responseParmsEntity = new ResponseParmsEntity();
|
|
|
try {
|
|
|
@@ -121,6 +132,7 @@ public class LinkDataController {
|
|
|
@Operation(summary = "推送启动充电结果")
|
|
|
@PostMapping("/notification_start_charge_result")
|
|
|
@Log(value = "推送启动充电结果", module = LogModuleEnum.PARKING, params = true, result = true)
|
|
|
+ @ApiRateLimit(prefix = "third_party:start_charge", limitType = ApiRateLimit.LimitType.IP, count = 300, time = 60, message = "启动充电请求过于频繁,请稍后再试")
|
|
|
public ResponseParmsEntity chargeResponse(@RequestBody RequestParmsEntity requestDTO){
|
|
|
return chargingReceptionService.chargeResponse(requestDTO);
|
|
|
}
|
|
|
@@ -131,6 +143,7 @@ public class LinkDataController {
|
|
|
@Operation(summary = "推送充电状态")
|
|
|
@PostMapping("/notification_equip_charge_status")
|
|
|
@Log(value = "推送充电状态", module = LogModuleEnum.PARKING, params = true, result = true)
|
|
|
+ @ApiRateLimit(prefix = "third_party:charge_status", limitType = ApiRateLimit.LimitType.IP, count = 500, time = 60, message = "充电状态推送过于频繁,请稍后再试")
|
|
|
public ResponseParmsEntity chargeStatusResponse(@RequestBody RequestParmsEntity requestDTO){
|
|
|
return chargingReceptionService.chargeStatusResponse(requestDTO);
|
|
|
}
|
|
|
@@ -141,6 +154,7 @@ public class LinkDataController {
|
|
|
@Operation(summary = "推送停止充电结果")
|
|
|
@PostMapping("/notification_stop_charge_result")
|
|
|
@Log(value = "推送停止充电结果", module = LogModuleEnum.PARKING, params = true, result = true)
|
|
|
+ @ApiRateLimit(prefix = "third_party:stop_charge", limitType = ApiRateLimit.LimitType.IP, count = 300, time = 60, message = "停止充电请求过于频繁,请稍后再试")
|
|
|
public ResponseParmsEntity stopChargeResponse(@RequestBody RequestParmsEntity requestDTO){
|
|
|
return chargingReceptionService.stopChargeResponse(requestDTO);
|
|
|
}
|
|
|
@@ -151,6 +165,7 @@ public class LinkDataController {
|
|
|
@Operation(summary = "推送充电订单信息")
|
|
|
@PostMapping("/notification_charge_order_info")
|
|
|
@Log(value = "推送充电订单信息", module = LogModuleEnum.PARKING, params = true, result = true)
|
|
|
+ @ApiRateLimit(prefix = "third_party:charge_order", limitType = ApiRateLimit.LimitType.IP, count = 200, time = 60, message = "订单信息推送过于频繁,请稍后再试")
|
|
|
public ResponseParmsEntity chargeOrderResponse(@RequestBody RequestParmsEntity requestDTO){
|
|
|
return chargingReceptionService.chargeOrderResponse(requestDTO);
|
|
|
}
|
|
|
@@ -163,6 +178,7 @@ public class LinkDataController {
|
|
|
@Operation(summary = "设备状态变化推送")
|
|
|
@PostMapping("/notification_stationStatus")
|
|
|
@Log(value = "设备状态变化推送", module = LogModuleEnum.PARKING, params = true, result = true)
|
|
|
+ @ApiRateLimit(prefix = "third_party:station_status", limitType = ApiRateLimit.LimitType.IP, count = 500, time = 60, message = "设备状态推送过于频繁,请稍后再试")
|
|
|
public ResponseParmsEntity stationStatus(@RequestBody RequestParmsEntity requestDTO){
|
|
|
return chargingReceptionService.stationStatus(requestDTO);
|
|
|
}
|