|
|
@@ -3,6 +3,7 @@ package com.cyksj.web.controller.mirror;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.extra.servlet.ServletUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
@@ -29,6 +30,7 @@ import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -36,6 +38,7 @@ import javax.servlet.http.Cookie;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -53,6 +56,8 @@ public class MirrorController {
|
|
|
|
|
|
private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
|
|
|
|
|
|
+ private static String DOMAIN = "https://gpt.bestaistore.com";
|
|
|
+
|
|
|
private final ChatGptAccountService chatGptAccountService;
|
|
|
|
|
|
private final ClaudeService claudeService;
|
|
|
@@ -418,4 +423,39 @@ public class MirrorController {
|
|
|
LumaUser lumaUser = lumaService.getLumaUser(userId, relationId);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(lumaHost + (EnvCommonService.active_pre.equals(envCommonService.getEnv()) ? "/8083":"/8085") +"/api/applets/luma/lumaMirrorWithToken/" + lumaUser.getUserToken());
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * gpt3天体验
|
|
|
+ */
|
|
|
+ @GetMapping("/gpt/trial")
|
|
|
+ public void trialGpt() throws IOException {
|
|
|
+ String clientIP = ServletUtil.getClientIP(request);
|
|
|
+ Cookie trialTokenCookie = ServletUtil.getCookie(request, "trialToken");
|
|
|
+ String userAgent = ServletUtil.getHeader(request, "userAgent", StandardCharsets.UTF_8);
|
|
|
+ String trialToken = "";
|
|
|
+ if (trialTokenCookie != null) {
|
|
|
+ trialToken = trialTokenCookie.getValue();
|
|
|
+
|
|
|
+ }
|
|
|
+ String userToken = chatGptAccountService.trialGpt(clientIP, trialToken, userAgent);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(userToken)) {
|
|
|
+ response.sendRedirect("https://nf.video/4p465k/?gid=18");
|
|
|
+ }else {
|
|
|
+ SysConfig sysConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey,"trial_gpt_domain"));
|
|
|
+ if (sysConfig != null) {
|
|
|
+ String sysValue = sysConfig.getSysValue();
|
|
|
+ if (JSONUtil.isJsonArray(sysValue)) {
|
|
|
+ List<String> domainList = JSONUtil.parseArray(sysValue).toList(String.class);
|
|
|
+ DOMAIN = domainList.get(RandomUtil.randomInt(domainList.size()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Cookie cookie = new Cookie("trialToken",userToken);
|
|
|
+ cookie.setMaxAge(2592000);
|
|
|
+ cookie.setPath("/");
|
|
|
+ ServletUtil.addCookie(response,cookie);
|
|
|
+ response.sendRedirect(DOMAIN + "/codetoken?logintoken=" + userToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|