diff --git a/pom.xml b/pom.xml
index f71ca240..6145fec1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -125,7 +125,24 @@
mysql-connector-java
8.0.33
-
+
+
+ io.jsonwebtoken
+ jjwt-api
+ 0.11.2
+
+
+ io.jsonwebtoken
+ jjwt-impl
+ 0.11.2
+ runtime
+
+
+ io.jsonwebtoken
+ jjwt-jackson
+ 0.11.2
+ runtime
+
net.sf.json-lib
diff --git a/src/main/java/UnitTest/AesUtil.java b/src/main/java/UnitTest/AesUtil.java
new file mode 100644
index 00000000..e083a05f
--- /dev/null
+++ b/src/main/java/UnitTest/AesUtil.java
@@ -0,0 +1,59 @@
+package UnitTest;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.GCMParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+public class AesUtil {
+ static final int KEY_LENGTH_BYTE = 32;
+ static final int TAG_LENGTH_BIT = 128;
+ private final byte[] aesKey;
+
+ public AesUtil(byte[] key) {
+ if (key.length != KEY_LENGTH_BYTE) {
+ throw new IllegalArgumentException("无效的ApiV3Key,长度必须为32个字节");
+ }
+ this.aesKey = key;
+ }
+
+ public String decryptToString(byte[] associatedData, byte[] nonce, String ciphertext)
+ throws GeneralSecurityException, IOException {
+ try {
+ Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
+
+ SecretKeySpec key = new SecretKeySpec(aesKey, "AES");
+ GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, nonce);
+
+ cipher.init(Cipher.DECRYPT_MODE, key, spec);
+ cipher.updateAAD(associatedData);
+
+ return new String(cipher.doFinal(Base64.getDecoder().decode(ciphertext)), "utf-8");
+ } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
+ throw new IllegalStateException(e);
+ } catch (InvalidKeyException | InvalidAlgorithmParameterException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static String decryptToString(String enData) throws GeneralSecurityException, IOException {
+ String key = "1d35eefc2b8207d615028d056ce5296c";
+ String associatedData = "12345";
+ String nonce = "3229172322917278";
+ AesUtil aesUtils = new AesUtil(key.getBytes());
+ String deData = aesUtils.decryptToString(associatedData.getBytes(), nonce.getBytes(), enData);
+ return deData;
+ }
+
+ public static void main(String[] args) throws Exception {
+ String enData = "Bs4h+MXFkIsmtacWqM2ah808n53ru/eAcIwN/rGLNaIOKEBaysqG6g==";
+ System.out.println(decryptToString(enData));
+ }
+
+}
diff --git a/src/main/java/UnitTest/KeyValidator.java b/src/main/java/UnitTest/KeyValidator.java
deleted file mode 100644
index d296e2c9..00000000
--- a/src/main/java/UnitTest/KeyValidator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package UnitTest;
-
-import java.util.Base64;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.concurrent.TimeUnit;
-
-public class KeyValidator {
-
- public static boolean validateKey(String key, String sharedSecret) {
- try {
- String[] parts = key.split(":");
- if (parts.length != 3) {
- return false; // Invalid key format
- }
-
- String secret = parts[0];
- String timestampStr = parts[1];
- String expirationStr = parts[2];
-
- long timestamp = Long.parseLong(timestampStr);
- long expiration = Long.parseLong(expirationStr);
-
- // Check if the key has expired
- if (System.currentTimeMillis() > expiration * 1000) {
- return false; // Key has expired
- }
-
- // Recreate the key for verification
- String keyData = String.join(":", secret, timestampStr, expirationStr);
- String generatedKey = generateKey(sharedSecret, keyData);
-
- return key.equals(generatedKey); // Validate the key
- } catch (Exception e) {
- return false; // Error in processing, consider the key invalid
- }
- }
-
- private static String generateKey(String secret, String keyData) throws NoSuchAlgorithmException {
- MessageDigest md = MessageDigest.getInstance("SHA-256");
- md.update((keyData + secret).getBytes());
- byte[] digest = md.digest();
- return Base64.getUrlEncoder().encodeToString(digest);
- }
-
- public static void main(String[] args) throws Exception {
- String sharedSecret = "DsideaL4r5t6y7u@123"; // This should match the one used in Python
- String key = "0ede740c2c81ea362dcdeee568716eb06706d96dda55be6109bb8cf2c83344c1"; // Example key to validate
-
- boolean isValid = validateKey(key, sharedSecret);
- System.out.println("Is the key valid? " + isValid);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/dsideal/QingLong/Zbdc/Model/ZbdcModel.java b/src/main/java/com/dsideal/QingLong/Zbdc/Model/ZbdcModel.java
index 2194f9da..ec4ef4b7 100644
--- a/src/main/java/com/dsideal/QingLong/Zbdc/Model/ZbdcModel.java
+++ b/src/main/java/com/dsideal/QingLong/Zbdc/Model/ZbdcModel.java
@@ -744,7 +744,11 @@ public class ZbdcModel {
else record.set(key, Double.parseDouble(value.toString()));
}
}
- int lb_sb_id = jsonObject.getInteger("lb_sb_id");
+ int lb_sb_id = 1;
+ if (jsonObject.containsKey("lb_sb_id")) {
+ lb_sb_id = jsonObject.getInteger("lb_sb_id");
+ }
+
Record lbSbRecord = Db.findById("t_zbdc_table_lbsb", "lb_sb_id", lb_sb_id);
int lb_id = lbSbRecord.getInt("lb_id");//类别ID
String lb_name = lbSbRecord.getStr("lb_name");//类别名称