BUGFIX:无法通过谷歌登录/教育管理员无法查看design使用频次

This commit is contained in:
2025-09-03 18:15:23 +08:00
parent d8f0188596
commit c67d197da0
4 changed files with 30 additions and 14 deletions

View File

@@ -64,7 +64,7 @@ public class ConvenientInquiryController {
@GetMapping("/getDesignStatistic")
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,
@RequestParam(required = false) List<Long> 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));
}

View File

@@ -121,6 +121,16 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> 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<AccountMapper, Account> 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<AccountMapper, Account> impl
private String getAccessToken(String code) {
RestTemplate restTemplate = new RestTemplate();
Map<String, String> 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<AccountMapper, Account> 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<AccountMapper, Account> impl
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(
new NetHttpTransport(),
JacksonFactory.getDefaultInstance())
.setAudience(Collections.singletonList(CLIENT_ID))
.setAudience(Collections.singletonList(googleClientId))
.build();
// 验证并解析 ID Token

View File

@@ -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
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

View File

@@ -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
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