mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-31 19:52:54 +08:00
Modify the HTTP call scheme
This commit is contained in:
@ -54,7 +54,7 @@
|
||||
<!-- http -->
|
||||
<dependency>
|
||||
<groupId>com.dtflys.forest</groupId>
|
||||
<artifactId>forest-spring-boot-starter</artifactId>
|
||||
<artifactId>forest-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -8,7 +8,7 @@ import ai.chat2db.server.domain.api.service.ConfigService;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
||||
import ai.chat2db.server.tools.common.config.Chat2dbProperties;
|
||||
import ai.chat2db.server.web.api.aspect.ConnectionInfoAspect;
|
||||
import ai.chat2db.server.web.api.http.GatewayClientServiceV2;
|
||||
import ai.chat2db.server.web.api.http.GatewayClientService;
|
||||
import ai.chat2db.server.web.api.http.response.ApiKeyResponse;
|
||||
import ai.chat2db.server.web.api.http.response.QrCodeResponse;
|
||||
import ai.chat2db.server.web.api.util.OpenAIClient;
|
||||
@ -32,11 +32,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Slf4j
|
||||
public class AiConfigController {
|
||||
|
||||
//@Autowired
|
||||
//private GatewayClientService gatewayClientService;
|
||||
@Resource
|
||||
private GatewayClientService gatewayClientService;
|
||||
|
||||
@Autowired
|
||||
private GatewayClientServiceV2 gatewayClientService;
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
@Resource
|
||||
|
@ -20,11 +20,19 @@ public interface GatewayClientService {
|
||||
/**
|
||||
* 获取公众号的二维码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Get("/api/client/getLoginQrCode")
|
||||
DataResult<QrCodeResponse> getLoginQrCode();
|
||||
|
||||
/**
|
||||
* Refresh login
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
@Get("/api/client/getQrCode")
|
||||
DataResult<QrCodeResponse> getQrCode(@Query("token") String token);
|
||||
@Get("/api/client/getLoginStatus")
|
||||
DataResult<QrCodeResponse> getLoginStatus(@Query("token") String token);
|
||||
|
||||
/**
|
||||
* 返回剩余次数
|
||||
|
@ -1,63 +0,0 @@
|
||||
package ai.chat2db.server.web.api.http;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
||||
import ai.chat2db.server.tools.common.config.Chat2dbProperties;
|
||||
import ai.chat2db.server.web.api.http.response.ApiKeyResponse;
|
||||
import ai.chat2db.server.web.api.http.response.QrCodeResponse;
|
||||
import com.dtflys.forest.Forest;
|
||||
import com.dtflys.forest.annotation.Get;
|
||||
import com.dtflys.forest.annotation.Query;
|
||||
import com.dtflys.forest.annotation.Var;
|
||||
import com.dtflys.forest.utils.TypeReference;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Gateway 的http 服务
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Component
|
||||
public class GatewayClientServiceV2 {
|
||||
@Resource
|
||||
private Chat2dbProperties chat2dbProperties;
|
||||
|
||||
/**
|
||||
* 获取公众号的二维码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Get("/api/client/getLoginQrCode")
|
||||
public DataResult<QrCodeResponse> getLoginQrCode() {
|
||||
return Forest.get(chat2dbProperties.getGateway().getBaseUrl() + "/api/client/getLoginQrCode")
|
||||
.execute(new TypeReference<>() {});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query login status
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
@Get("/api/client/getLoginStatus")
|
||||
public DataResult<QrCodeResponse> getLoginStatus(@Query("token") String token) {
|
||||
return Forest.get(chat2dbProperties.getGateway().getBaseUrl() + "/api/client/getLoginStatus")
|
||||
.addQuery("token", token)
|
||||
.execute(new TypeReference<>() {});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回剩余次数
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@Get("/api/client/remaininguses/{key}")
|
||||
public DataResult<ApiKeyResponse> remaininguses(@Var("key") String key) {
|
||||
return Forest.get(chat2dbProperties.getGateway().getBaseUrl() + "/api/client/remaininguses/" + key)
|
||||
.execute(new TypeReference<>() {});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user