Ver código fonte

feat: "修改代理服务器"

Leonezhurui 2 anos atrás
pai
commit
4aeaf4256a

+ 1 - 72
src/main/java/com/njuzr/eaibackend/service/TranslateService.java

@@ -36,29 +36,7 @@ public class TranslateService {
     }
 
     public String translate(Long assignmentId, Long userId, TranslationDTO translationDTO) {
-        // 1 请求,构造请求条件
-//        String salt = UUID.randomUUID().toString();
-//        String curtime = String.valueOf(System.currentTimeMillis() / 1000);
-//        String sign;
-//        try {
-//            sign = calculateSign(appKey, appSecret, translationDTO.getQ(), salt, curtime);
-//        } catch (NoSuchAlgorithmException e) {
-//            log.error(e.getMessage());
-//            throw MyException.create(HttpStatus.INTERNAL_SERVER_ERROR, "不支持SHA-256算法");
-//        }
-
-//        MyRequestObject request =  new MyRequestObject(
-//                translationDTO.getQ(),
-//                translationDTO.getFrom(),
-//                translationDTO.getTo(),
-//                appKey,
-//                salt,
-//                sign,
-//                "v3",
-//                curtime
-//                );
-
-        MyResponseObject response = webClientUtil.post("http://localhost:5000/api/translate", translationDTO, MyResponseObject.class);
+        MyResponseObject response = webClientUtil.post("http://47.111.23.171:5000/api/translate", translationDTO, MyResponseObject.class);
 
         if (Objects.equals(response.getCode(), 200)) {
             Translation translation = new Translation();
@@ -98,53 +76,4 @@ public class TranslateService {
         private String data;
         private String msg;
     }
-
-    /**
-     * 计算鉴权签名 -
-     * 计算方式 : sign = sha256(appKey + input(q) + salt + curtime + appSecret)
-     *
-     * @param appKey    您的应用ID
-     * @param appSecret 您的应用密钥
-     * @param q         请求内容
-     * @param salt      随机值
-     * @param curtime   当前时间戳(秒)
-     * @return 鉴权签名sign
-     */
-    public String calculateSign(String appKey, String appSecret, String q, String salt, String curtime)
-            throws NoSuchAlgorithmException {
-        String strSrc = appKey + getInput(q) + salt + curtime + appSecret;
-        return encrypt(strSrc);
-    }
-
-    private String encrypt(String strSrc) throws NoSuchAlgorithmException {
-        byte[] bt = strSrc.getBytes();
-        MessageDigest md = MessageDigest.getInstance("SHA-256");
-        md.update(bt);
-        byte[] bts = md.digest();
-        StringBuilder des = new StringBuilder();
-        for (byte b : bts) {
-            String tmp = (Integer.toHexString(b & 0xFF));
-            if (tmp.length() == 1) {
-                des.append("0");
-            }
-            des.append(tmp);
-        }
-        return des.toString();
-    }
-
-    private static String getInput(String input) {
-        if (input == null) {
-            return null;
-        }
-        String result;
-        int len = input.length();
-        if (len <= 20) {
-            result = input;
-        } else {
-            String startStr = input.substring(0, 10);
-            String endStr = input.substring(len - 10, len);
-            result = startStr + len + endStr;
-        }
-        return result;
-    }
 }

+ 1 - 1
src/main/resources/application-prod.yaml

@@ -50,7 +50,7 @@ openai:
       key: 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
 
 proxy:
-  enabled: true
+  enabled: false
   host: 20.111.54.16
   port: 8123