作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

... ... @@ -23,7 +23,22 @@ class AyrShare
'Authorization' => 'Bearer ',
'Content-Type' => 'application/json',
];
//私钥
private $private_key = "-----BEGIN RSA PRIVATE KEY-----
MIICWgIBAAKBgGFatMeBeaw7QJrqmylMLZlwuuO0FA/EZg5/g7Rrqu+FgpwvFkJq
9twEZJY+aIdDH8/RVrCZQGR/xUxKw9v4ows+sLwi4g41m8KRKDXUcJwQvSlwsHAi
h9hPGZxDsRK0Nv4pZ7XqGgh0Wb0VypX/+Q1dhX9BnXQmvEKayk8GQWQxAgMBAAEC
gYAFqOJNnudV7fPpja4LjpQwEW+sATIRYJeWTC9587ByUE6xicM/hTxouhCm82Xc
Rzi4OjFR/vbRYOQ1dTtBtIi18fdRrseQNyR/N2NZjw1X8n5aZcw5NVaa3d3YTQNa
uzjnYF5eYSOD4pNKKIDc35VHdmvGCV/JXwQKMTgu1+4AAQJBAL5jjN3kvMKFF8vG
DyYR8k+wPG9iXAdR0HjVNB3OzxKVW0MTwM32pJBXCmF1MOziL8WC48VHQL48hVRa
52xRqAECQQCC53rrrOPhPCLIb6kBfgqnxCojqlUK9paFL7NYTPtLYcOajY6+NiKT
CG1gaOwZh4r34HF7I59l/Ds98Z4nQDwxAkAC4/oIiGeBQIoK8vfZ6R3XreJNAp5J
EinrG7mN1kz4iEH5c7xSpDL9agTjU+cpQYneIs2Yeit2d+7CSBsJXvgBAkBDFsfU
yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe
yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j
zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
-----END RSA PRIVATE KEY-----";
/**
* @name :参数构建
*/
... ... @@ -143,12 +158,12 @@ class AyrShare
return $this->http_click('post',$url,$param);
}
/**
* @name :(删除子账户配置文件)post_create_profiles
* @name :(删除子账户配置文件)deleted_profiles
* @author :lyh
* @method :post
* @time :2023/5/5 15:16
*/
public function deleted_create_profiles($data){
public function deleted_profiles($data){
$param = [
'title'=>$data['title'],
'profileKey'=>$this->profile_key,
... ... @@ -190,19 +205,19 @@ class AyrShare
}
/**
* @name :get_profiles
* @name :(跳转第三方生成jwt令牌)post_generate_jwt
* @author :lyh
* @method :post
* @time :2023/5/5 18:07
* @time :2023/5/5 18:07 https://app.ayrshare.com/api/profiles/generateJWT
*/
public function get_profiles(){
// $param = [
// 'title'=>$data['title'],
// 'refId'=>$data['refId'],
// 'profileKey'=>$this->profile_key,
// ];
$url = $this->path.'/api/profile';
return $this->http_click('get',$url);
public function post_generate_jwt($data){
$param = [
'title'=>$data['domain'],
'refId'=>$this->private_key,
'profileKey'=>$this->profile_key,
];
$url = $this->path.'/api/profiles/generateJWT';
return $this->http_click('post',$url,$param);
}
public function api_user(){
... ...
... ... @@ -31,7 +31,70 @@ class AyrShareController extends BaseController
* @time :2023/5/5 16:44
*/
public function create_account(AyrShareLogic $ayrShareLogic){
$ayrShareLogic->ayr_share_add();
$param = [
'title'=>md5(uniqid().time())
];
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$res = $ayrShareHelper->post_create_profiles($param);
if($res['status'] == 'fail'){
$this->response('同步绑定失败');
}
//执行数据库操作
$ayrShareLogic->ayr_share_add($res);
$this->response('success');
}
/**
* @name :(删除用户账号并同步ayr_share账号)edit_account
* @author :lyh
* @method :post
* @time :2023/5/6 10:11
*/
public function del_account(AyrShareLogic $ayrShareLogic){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$info = $ayrShareLogic->ayr_share_info();
$data = [
'title'=>$info['title'],
'profileKey'=>$info['profile_key']
];
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$res = $ayrShareHelper->deleted_profiles($data);
if($res['status'] == 'fail'){
$this->response('同步删除失败');
}
$ayrShareLogic->ayr_share_del();
$this->response('success');
}
/**
* @name :(授权绑定第三方平台,生成jwt令牌)ayr_share_bind
* @author :lyh
* @method :post
* @time :2023/5/6 10:24
*/
public function bind_account(AyrShareLogic $ayrShareLogic){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$info = $ayrShareLogic->ayr_share_info();
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$data = [
'domain'=>$this->request->getHost(),
'profileKey'=>$info['profile_key']
];
$res = $ayrShareHelper->post_generate_jwt($data);
if($res['status'] == 'fail'){
$this->response('生成令牌失败');
}
$this->response('success');
}
}
... ...
... ... @@ -17,21 +17,12 @@ class AyrShareLogic extends BaseLogic
}
/**
* @name :(创建账号并绑定)ayr_add
* @name :(创建账号并绑定写入数据库)ayr_add
* @author :lyh
* @method :post
* @time :2023/5/6 9:19
*/
public function ayr_share_add(){
$param = [
'title'=>md5(uniqid().time())
];
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$res = $ayrShareHelper->post_create_profiles($param);
if($res['status'] == 'fail'){
$this->response('绑定失败');
}
public function ayr_share_add($res){
//插入数据库
$data = [
'title'=>$res['title'],
... ... @@ -49,12 +40,34 @@ class AyrShareLogic extends BaseLogic
}
/**
* @name :(zhuzhuang)sql_add
* @name :(获取当前数据详情)ayr_share_del
* @author :lyh
* @method :post
* @time :2023/5/6 10:04
* @time :2023/5/6 10:16
*/
public function sql_add(){
public function ayr_share_info(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
* @name :(删除ayr数据并同步删除)
* @author :lyh
* @method :post
* @time :2023/5/6 10:18
*/
public function ayr_share_del(){
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('删出失败');
}
return $this->success();
}
}
... ...
... ... @@ -199,6 +199,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('ayr')->group(function () {
Route::any('/lists', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists');
Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account');
Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account');
Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account');
});
});
... ...