|
|
@@ -2,16 +2,18 @@ package com.cyksj.web.controller.manage.account;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
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.dto.ChatGptChangePasswordDto;
|
|
|
import com.cyksj.model.entity.ChatgptSession;
|
|
|
import com.cyksj.model.excel.ExcelGptMirrorAccountData;
|
|
|
import com.cyksj.model.views.ChatgptCarSessionView;
|
|
|
@@ -24,6 +26,7 @@ import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@@ -154,6 +157,37 @@ public class CmsGptCarController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/post/mirror/changePassword")
|
|
|
+ public Result<String> changePassword(@RequestBody ChatGptChangePasswordDto chatGptChangePasswordDto){
|
|
|
+ Long chatgptSessionId = chatGptChangePasswordDto.getChatgptSessionId();
|
|
|
+ ChatgptSession chatgptSession = chatgptSessionMapper.selectById(chatgptSessionId);
|
|
|
+ if(chatgptSession == null){
|
|
|
+ throw BusinessRuntimeException.getInstance("车队不存在");
|
|
|
+ }
|
|
|
+ JSONObject jsonData = new JSONObject();
|
|
|
+ jsonData.put("url", chatGptChangePasswordDto.getUrl());
|
|
|
+ if(StringUtils.isBlank(chatGptChangePasswordDto.getPassword())){
|
|
|
+ chatGptChangePasswordDto.setPassword(RandomUtil.randomString(12));
|
|
|
+ }
|
|
|
+ jsonData.put("newpassword", chatGptChangePasswordDto.getPassword());
|
|
|
+ jsonData.put("proxy", "http://nKeghbxuT2R2QO7G:2pSJmJSZln2CPGJ2_country-us@geo.iproyal.com:12321");
|
|
|
+ String body = HttpUtil.post("http://85.113.70.93:8282/change", jsonData.toString());
|
|
|
+ // Parse response
|
|
|
+ JSONObject jsonResponse = new JSONObject(body);
|
|
|
+ int code = jsonResponse.getInt("code");
|
|
|
+
|
|
|
+ // Handle response
|
|
|
+ if (code == 1) {
|
|
|
+ //修改密码
|
|
|
+ chatgptSession.setPassword(chatGptChangePasswordDto.getPassword());
|
|
|
+ chatgptSessionMapper.updateById(chatgptSession);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ } else {
|
|
|
+ throw BusinessRuntimeException.getInstance("修改密码错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 刷新gpt得officialSession
|
|
|
*/
|