|
@@ -2,24 +2,19 @@ package cn.cslg.pas.service;
|
|
|
|
|
|
import cn.cslg.pas.common.core.base.Constants;
|
|
|
import cn.cslg.pas.common.core.base.RedisConf;
|
|
|
-import cn.cslg.pas.common.utils.RedisUtil;
|
|
|
+import cn.cslg.pas.common.model.PersonnelVO;
|
|
|
import cn.cslg.pas.common.utils.Response;
|
|
|
-import cn.cslg.pas.common.utils.ResponseEnum;
|
|
|
-import cn.cslg.pas.common.utils.StringUtils;
|
|
|
+import cn.cslg.pas.common.utils.*;
|
|
|
import cn.cslg.pas.domain.Project;
|
|
|
import cn.cslg.pas.domain.ProjectUser;
|
|
|
import cn.cslg.pas.domain.User;
|
|
|
-import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
-import cn.dev33.satoken.stp.SaLoginModel;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.captcha.CaptchaUtil;
|
|
|
import cn.hutool.captcha.CircleCaptcha;
|
|
|
import cn.hutool.core.img.ImgUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import okhttp3.*;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -43,7 +38,7 @@ public class OAuth2Service {
|
|
|
private final ProjectUserService projectUserService;
|
|
|
private final ProjectService projectService;
|
|
|
@Value("${authorUrl}")
|
|
|
- private String url;
|
|
|
+ private String url;
|
|
|
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
|
|
|
|
|
public User getUserinfo() {
|
|
@@ -125,17 +120,17 @@ public class OAuth2Service {
|
|
|
OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
|
|
|
Request request = new Request.Builder()
|
|
|
- .url(url+"/permission/api/admin/verifyCode")
|
|
|
+ .url(url + "/permission/api/admin/verifyCode")
|
|
|
.get()
|
|
|
.build();
|
|
|
String resBody = okHttpClient.newCall(request).execute().body().string();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
JSONObject data = (JSONObject) jsonObject.get("data");
|
|
|
- Object captcha =data.get("captcha");
|
|
|
- Object uuid = data.get("uuid");
|
|
|
+ Object captcha = data.get("captcha");
|
|
|
+ Object uuid = data.get("uuid");
|
|
|
Object code = data.get("code");
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
- result.put("captcha",captcha.toString());
|
|
|
+ result.put("captcha", captcha.toString());
|
|
|
result.put("uuid", uuid.toString());
|
|
|
result.put("code", code.toString());
|
|
|
//将验证码存放到Redis里面并设置
|
|
@@ -143,30 +138,31 @@ public class OAuth2Service {
|
|
|
//KEY值格式为: 验证码:UUID VALUE值为:验证码生成工具所生成的验证码
|
|
|
return Response.success(result);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * @param
|
|
|
* @return 登录成功的信息
|
|
|
* @author 沈永艺
|
|
|
*/
|
|
|
- public String login( String username,String password,String code,String uuid) throws IOException {
|
|
|
- Map<String,Object> map =new HashMap<>();
|
|
|
- map.put("code",code);
|
|
|
- map.put("uuid",uuid);
|
|
|
- map.put("username",username);
|
|
|
- map.put("password",password);
|
|
|
- JSONObject json =new JSONObject(map);
|
|
|
- RequestBody a = RequestBody.create(JSON, String.valueOf(json));
|
|
|
+ public String login(String username, String password, String code, String uuid) throws IOException {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("code", code);
|
|
|
+ map.put("uuid", uuid);
|
|
|
+ map.put("username", username);
|
|
|
+ map.put("password", password);
|
|
|
+ JSONObject json = new JSONObject(map);
|
|
|
+ RequestBody a = RequestBody.create(JSON, String.valueOf(json));
|
|
|
OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
Request request = new Request.Builder()
|
|
|
- .url(url+"/permission/api/admin/login")
|
|
|
+ .url(url + "/permission/api/admin/login")
|
|
|
.post(a)
|
|
|
.build();
|
|
|
String resBody = okHttpClient.newCall(request).execute().body().string();
|
|
|
- JSONObject jsonObject =JSONObject.parseObject(resBody);
|
|
|
- String token =jsonObject.get("data").toString();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
+ String token = jsonObject.get("data").toString();
|
|
|
+ PersonnelVO personnelVO = JsonUtils.jsonToPojo(token, PersonnelVO.class);
|
|
|
|
|
|
|
|
|
- return Response.success(true);
|
|
|
+ return Response.success(personnelVO.getToken());
|
|
|
}
|
|
|
|
|
|
public String changePwd(String oldPassword, String newPassword) {
|