From c67d197da09b8a87425e1a67baa9faf69b9dcd47 Mon Sep 17 00:00:00 2001 From: xupei Date: Wed, 3 Sep 2025 18:15:23 +0800 Subject: [PATCH] =?UTF-8?q?BUGFIX:=E6=97=A0=E6=B3=95=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E8=B0=B7=E6=AD=8C=E7=99=BB=E5=BD=95/=E6=95=99=E8=82=B2?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=97=A0=E6=B3=95=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?design=E4=BD=BF=E7=94=A8=E9=A2=91=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConvenientInquiryController.java | 5 ++-- .../da/service/impl/AccountServiceImpl.java | 23 ++++++++++++------- src/main/resources/application-dev.properties | 10 +++++--- .../resources/application-prod.properties | 6 ++++- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/ai/da/controller/ConvenientInquiryController.java b/src/main/java/com/ai/da/controller/ConvenientInquiryController.java index 12038698..b549b3a2 100644 --- a/src/main/java/com/ai/da/controller/ConvenientInquiryController.java +++ b/src/main/java/com/ai/da/controller/ConvenientInquiryController.java @@ -64,7 +64,7 @@ public class ConvenientInquiryController { @GetMapping("/getDesignStatistic") public Response> getDesignStatistic(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) List ids, @RequestParam(required = false) String email) { - Long accountId = UserContext.getUserHolder().getId(); + /*Long accountId = UserContext.getUserHolder().getId(); String userEmail = accountService.getById(accountId).getUserEmail(); if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L) @@ -85,7 +85,8 @@ public class ConvenientInquiryController { return Response.success(designStatistic); } else { return Response.fail("Sorry, you don't have permission"); - } + }*/ + return Response.success(convenientInquiryService.getDesignStatistic(startTime, endTime, ids, email)); } diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index 64e4d421..0047ff4c 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -121,6 +121,16 @@ public class AccountServiceImpl extends ServiceImpl impl @Value("${minio.bucketName.users}") private String userBucket; + @Value("${google.client.id}") + private String googleClientId; + + @Value("${google.client.secret}") + private String googleClientSecret; + + @Value("${google.redirect.uri}") + private String googleRedirectUri; + + @Resource private RedisUtil redisUtil; @@ -2148,12 +2158,9 @@ public class AccountServiceImpl extends ServiceImpl impl private static final String TOKEN_URL = "https://oauth2.googleapis.com/token"; private static final String USER_INFO_URL = "https://www.googleapis.com/oauth2/v3/userinfo"; // private static final String CLIENT_ID = "194770296147-njd68pm7tnapgonkj2h48mhf63n15n3f.apps.googleusercontent.com"; - private static final String CLIENT_ID = "29310152396-nnsd3h533fld665oguu8ovrt1nukmt46.apps.googleusercontent.com"; // private static final String CLIENT_SECRET = "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"; - private static final String CLIENT_SECRET = "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"; // private static final String REDIRECT_URI = "https://0551-117-143-125-51.ngrok-free.app/api/third/party/auth/google_callback"; // private static final String REDIRECT_URI = "https://develop.api.aida.com.hk/api/third/party/auth/google_callback"; - private static final String REDIRECT_URI = "https://www.aida.com.hk/api/third/party/auth/google_callback"; public GoogleUser getGoogleUserFromCode(String code) { // Step 1: Exchange code for access_token @@ -2167,9 +2174,9 @@ public class AccountServiceImpl extends ServiceImpl impl private String getAccessToken(String code) { RestTemplate restTemplate = new RestTemplate(); Map params = new HashMap<>(); - params.put("client_id", CLIENT_ID); - params.put("client_secret", CLIENT_SECRET); - params.put("redirect_uri", REDIRECT_URI); + params.put("client_id", googleClientId); + params.put("client_secret", googleClientSecret); + params.put("redirect_uri", googleRedirectUri); params.put("grant_type", "authorization_code"); params.put("code", code); @@ -2749,7 +2756,7 @@ public class AccountServiceImpl extends ServiceImpl impl GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder( new NetHttpTransport(), JacksonFactory.getDefaultInstance()) - .setAudience(Collections.singletonList(CLIENT_ID)) + .setAudience(Collections.singletonList(googleClientId)) .build(); // 验证并解析 ID Token @@ -3084,7 +3091,7 @@ public class AccountServiceImpl extends ServiceImpl impl GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder( new NetHttpTransport(), JacksonFactory.getDefaultInstance()) - .setAudience(Collections.singletonList(CLIENT_ID)) + .setAudience(Collections.singletonList(googleClientId)) .build(); // 验证并解析 ID Token diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index a769658b..0758b621 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,8 +1,8 @@ server.port=5567 spring.datasource.primary.driver-class-name=com.mysql.cj.jdbc.Driver -#spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true -spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/test_aida_3.1?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true +spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/aida?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true +#spring.datasource.primary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/test_aida_3.1?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true spring.datasource.primary.username=aida_con spring.datasource.primary.password=123456 @@ -149,4 +149,8 @@ spring.mail.properties.mail.smtp.socketFactory.port=465 ALIYUN_API_KEY=sk-dc3f88b7df844fc5a7d3616ebd8a589c FREEPIK_API_KEY=FPSX94e5917d376a4facb87dabbaa0319c72 -ollama.url=http://localhost:11434/api/chat \ No newline at end of file +ollama.url=http://localhost:11434/api/chat + +google.client.id=29310152396-c44dcsoksjirhn7vbo29p8u8n0sg4qps.apps.googleusercontent.com +google.client.secret=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 +google.redirect.uri=https://develop.aida.com.hk/api/third/party/auth/google_callback \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 7bb68a5c..c62a4a4a 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -150,4 +150,8 @@ spring.mail.properties.mail.smtp.ssl.enable=true spring.mail.properties.mail.smtp.socketFactory.port=465 ALIYUN_API_KEY=sk-dc3f88b7df844fc5a7d3616ebd8a589c -FREEPIK_API_KEY=FPSX94e5917d376a4facb87dabbaa0319c72 \ No newline at end of file +FREEPIK_API_KEY=FPSX94e5917d376a4facb87dabbaa0319c72 + +google.client.id=29310152396-nnsd3h533fld665oguu8ovrt1nukmt46.apps.googleusercontent.com +google.client.secret=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 +google.redirect.uri=https://www.aida.com.hk/api/third/party/auth/google_callback \ No newline at end of file