|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.EnvCommonService;
|
|
|
@@ -112,21 +113,33 @@ public class MirrorController {
|
|
|
* @return 登陆结果
|
|
|
*/
|
|
|
@RequestMapping("/gpt/oauth")
|
|
|
- public Result<String> gptOauth(@RequestParam("usertoken") String userToken) {
|
|
|
+ public String gptOauth(@RequestParam("usertoken") String userToken) {
|
|
|
try {
|
|
|
log.info("用户通过userToken:{}", userToken);
|
|
|
ChatgptUser user = chatGptAccountService.findByUserTokenAndExpireTimeAfter(userToken, LocalDateTime.now());
|
|
|
if (user == null) {
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().setMsg("用户不存在或已过期").setCode(0).toResult();
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.putOpt("code",0);
|
|
|
+ result.putOpt("msg","用户不存在或已过期");
|
|
|
+ return result.toString();
|
|
|
}
|
|
|
|
|
|
//ChatgptSession session = chatGptAccountService.checkSession(carId);
|
|
|
//
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().setMsg("登陆成功").setCode(1).toResult(StringUtil.getString(user.getRelationId()));
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.putOpt("code",1);
|
|
|
+ result.putOpt("msg","登录成功");
|
|
|
+ result.putOpt("avatar",user.getImg());
|
|
|
+ result.putOpt("nickname",user.getName());
|
|
|
+ result.putOpt("uid",user.getRelationId());
|
|
|
+ return result.toString();
|
|
|
//}
|
|
|
} catch (Exception e) {
|
|
|
log.error("服务器错误", e);
|
|
|
- return GatewayResponse.FAIL.newBuilder().setMsg("服务器错误").setCode(0).toResult();
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.putOpt("code",0);
|
|
|
+ result.putOpt("msg","服务器错误");
|
|
|
+ return result.toString();
|
|
|
}
|
|
|
}
|
|
|
|