From ee357f0dd7bee415a5eca5ba95f70eaeeb1aadcd Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Thu, 20 Nov 2025 09:06:04 +0800
Subject: [PATCH] 优化
---
ard-work/src/main/java/com/ard/work/util/UtilMethod.java | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/ard-work/src/main/java/com/ard/work/util/UtilMethod.java b/ard-work/src/main/java/com/ard/work/util/UtilMethod.java
index 69388ef..fe26e6c 100644
--- a/ard-work/src/main/java/com/ard/work/util/UtilMethod.java
+++ b/ard-work/src/main/java/com/ard/work/util/UtilMethod.java
@@ -2,6 +2,9 @@
import com.alibaba.fastjson2.JSONObject;
import com.ard.system.authorize.service.AuthorizeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -10,25 +13,35 @@
* @date: 2025/3/4
* @description:
*/
+@Service
public class UtilMethod {
- @Resource
+ @Autowired
private AuthorizeService authorizeService;
/**
* 根据授权数量,验证授权信息是否合规
*/
public void authorizationVerification(int ls){
- JSONObject data = authorizeService.getAuthorizationInfo();
- if ("normal".equals(data.get("Type"))){
- int droneNum = (int) data.get("droneNum");
- if (ls > droneNum){
- throw new RuntimeException("添加无人机数量超过当前授权数量!!!");
- }
- }else if ("expired".equals(data.get("Type"))){
- throw new RuntimeException("授权文件过期!!!");
- }else if ("mismatch".equals(data.get("Type"))){
- throw new RuntimeException("授权文件不匹配!!!");
+
+ JSONObject authInfo = authorizeService.getAuthorizationInfo();
+ String authType = authInfo.getString("Type");
+
+ switch (authType) {
+ case "normal":
+ int allowedDroneNum = authInfo.getIntValue("droneNum");
+ if (ls > allowedDroneNum) {
+ throw new RuntimeException(String.format(
+ "授权数量%d,当前操作将导致总数达到%d,超过授权限制",
+ allowedDroneNum, ls));
+ }
+ break;
+ case "expired":
+ throw new RuntimeException("授权文件已过期");
+ case "mismatch":
+ throw new RuntimeException("授权文件不匹配");
+ default:
+ throw new RuntimeException("未知的授权类型: " + authType);
}
}
--
Gitblit v1.9.3