|
|
@@ -1,18 +1,23 @@
|
|
|
package com.cyksj.web.controller.manage.account;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
+import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.ChatgptSessionMapper;
|
|
|
import com.cyksj.model.entity.ChatgptSession;
|
|
|
+import com.cyksj.model.excel.ExcelGptMirrorAccountData;
|
|
|
import com.cyksj.model.views.ChatgptCarSessionView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.chatgpt.ChatGptAccountService;
|
|
|
+import com.cyksj.web.util.EasyExcelUtils;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
@@ -21,6 +26,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
|
|
|
/** admin/镜像车队账号管理
|
|
|
@@ -153,4 +160,25 @@ public class CmsGptCarController {
|
|
|
}
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出gpt镜像账号
|
|
|
+ */
|
|
|
+ @GetMapping("/export/mirror/account")
|
|
|
+ public void export(HttpServletResponse response) {
|
|
|
+ List<ExcelGptMirrorAccountData> dataList = beanSearcher.searchAll(ExcelGptMirrorAccountData.class, MapUtils.flatBuilder(request.getParameterMap()).build());
|
|
|
+ dataList.forEach(data -> {
|
|
|
+ String officialSession = data.getOfficialSession();
|
|
|
+ if (StrUtil.isNotEmpty(officialSession)) {
|
|
|
+ try {
|
|
|
+ JSONObject body = Jsons.parseObject(officialSession, JSONObject.class);
|
|
|
+ JSONObject accountCheckInfo = body.getJSONObject("accountCheckInfo");
|
|
|
+ String expiresAt = accountCheckInfo.getStr("expires_at");
|
|
|
+ data.setExpiryTime(DateUtil.parse(expiresAt));
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ EasyExcelUtils.createExcelStreamMutilByEasyExcel(response, ExcelGptMirrorAccountData.class, dataList, "gpt镜像账号", "gpt镜像账号", ExcelTypeEnum.XLS, null);
|
|
|
+ }
|
|
|
}
|