feat: 企业微信单点登录

This commit is contained in:
xiang2lin 2024-09-24 11:11:38 +08:00
parent 3bddc46c9a
commit 0baa4e0bf3
1 changed files with 29 additions and 0 deletions

View File

@ -215,6 +215,35 @@ public class LoginServiceImpl implements ILoginService {
} }
break; break;
case "weChat": case "weChat":
String authCode = entity.getString("code");//授权码
JSONObject params = new JSONObject();
params.put("code",authCode);
params.put("corpid",entity.getString("corpid"));
params.put("corpsecret",entity.getString("corpsecret"));
params.put("access_token",entity.getString("access_token"));
String res = HttpRequest.post(url).
header("appId",appId).
header("apiCode",userApiCode).
header("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj").
header("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(params.toJSONString()).
execute().
body();
JSONObject resJsonObject = JSONObject.parseObject(res);
JSONObject attribute = resJsonObject.getJSONObject("attribute");
String errcode = attribute.getString("errcode");
String errmsg = attribute.getString("errmsg");
if(!"0".equals(errcode)){
return BaseResult.getFailureMessageEntity("请求错误:"+errmsg);
}
String weComUserid = attribute.getString("userid");
userEntity.setWxUserId(weComUserid);
userEntity = sysUserDao.queryOne(userEntity);
if(null == userEntity ){
JSONObject object = new JSONObject();
object.put("userid",weComUserid);
return BaseResult.getFailureMessageEntity("认证失败!当前用户未绑定企业微信","1005",object);
}
break; break;
default: default:
return BaseResult.getFailureMessageEntity("错误的App类型:"+appType+" 支持的app类型有DD,weChat"); return BaseResult.getFailureMessageEntity("错误的App类型:"+appType+" 支持的app类型有DD,weChat");