Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
4 个修改的文件
包含
121 行增加
和
28 行删除
| @@ -23,7 +23,22 @@ class AyrShare | @@ -23,7 +23,22 @@ class AyrShare | ||
| 23 | 'Authorization' => 'Bearer ', | 23 | 'Authorization' => 'Bearer ', |
| 24 | 'Content-Type' => 'application/json', | 24 | 'Content-Type' => 'application/json', |
| 25 | ]; | 25 | ]; |
| 26 | - | 26 | + //私钥 |
| 27 | + private $private_key = "-----BEGIN RSA PRIVATE KEY----- | ||
| 28 | + MIICWgIBAAKBgGFatMeBeaw7QJrqmylMLZlwuuO0FA/EZg5/g7Rrqu+FgpwvFkJq | ||
| 29 | + 9twEZJY+aIdDH8/RVrCZQGR/xUxKw9v4ows+sLwi4g41m8KRKDXUcJwQvSlwsHAi | ||
| 30 | + h9hPGZxDsRK0Nv4pZ7XqGgh0Wb0VypX/+Q1dhX9BnXQmvEKayk8GQWQxAgMBAAEC | ||
| 31 | + gYAFqOJNnudV7fPpja4LjpQwEW+sATIRYJeWTC9587ByUE6xicM/hTxouhCm82Xc | ||
| 32 | + Rzi4OjFR/vbRYOQ1dTtBtIi18fdRrseQNyR/N2NZjw1X8n5aZcw5NVaa3d3YTQNa | ||
| 33 | + uzjnYF5eYSOD4pNKKIDc35VHdmvGCV/JXwQKMTgu1+4AAQJBAL5jjN3kvMKFF8vG | ||
| 34 | + DyYR8k+wPG9iXAdR0HjVNB3OzxKVW0MTwM32pJBXCmF1MOziL8WC48VHQL48hVRa | ||
| 35 | + 52xRqAECQQCC53rrrOPhPCLIb6kBfgqnxCojqlUK9paFL7NYTPtLYcOajY6+NiKT | ||
| 36 | + CG1gaOwZh4r34HF7I59l/Ds98Z4nQDwxAkAC4/oIiGeBQIoK8vfZ6R3XreJNAp5J | ||
| 37 | + EinrG7mN1kz4iEH5c7xSpDL9agTjU+cpQYneIs2Yeit2d+7CSBsJXvgBAkBDFsfU | ||
| 38 | + yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe | ||
| 39 | + yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j | ||
| 40 | + zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | ||
| 41 | + -----END RSA PRIVATE KEY-----"; | ||
| 27 | /** | 42 | /** |
| 28 | * @name :参数构建 | 43 | * @name :参数构建 |
| 29 | */ | 44 | */ |
| @@ -143,12 +158,12 @@ class AyrShare | @@ -143,12 +158,12 @@ class AyrShare | ||
| 143 | return $this->http_click('post',$url,$param); | 158 | return $this->http_click('post',$url,$param); |
| 144 | } | 159 | } |
| 145 | /** | 160 | /** |
| 146 | - * @name :(删除子账户配置文件)post_create_profiles | 161 | + * @name :(删除子账户配置文件)deleted_profiles |
| 147 | * @author :lyh | 162 | * @author :lyh |
| 148 | * @method :post | 163 | * @method :post |
| 149 | * @time :2023/5/5 15:16 | 164 | * @time :2023/5/5 15:16 |
| 150 | */ | 165 | */ |
| 151 | - public function deleted_create_profiles($data){ | 166 | + public function deleted_profiles($data){ |
| 152 | $param = [ | 167 | $param = [ |
| 153 | 'title'=>$data['title'], | 168 | 'title'=>$data['title'], |
| 154 | 'profileKey'=>$this->profile_key, | 169 | 'profileKey'=>$this->profile_key, |
| @@ -190,19 +205,19 @@ class AyrShare | @@ -190,19 +205,19 @@ class AyrShare | ||
| 190 | } | 205 | } |
| 191 | 206 | ||
| 192 | /** | 207 | /** |
| 193 | - * @name :get_profiles | 208 | + * @name :(跳转第三方生成jwt令牌)post_generate_jwt |
| 194 | * @author :lyh | 209 | * @author :lyh |
| 195 | * @method :post | 210 | * @method :post |
| 196 | - * @time :2023/5/5 18:07 | 211 | + * @time :2023/5/5 18:07 https://app.ayrshare.com/api/profiles/generateJWT |
| 197 | */ | 212 | */ |
| 198 | - public function get_profiles(){ | ||
| 199 | -// $param = [ | ||
| 200 | -// 'title'=>$data['title'], | ||
| 201 | -// 'refId'=>$data['refId'], | ||
| 202 | -// 'profileKey'=>$this->profile_key, | ||
| 203 | -// ]; | ||
| 204 | - $url = $this->path.'/api/profile'; | ||
| 205 | - return $this->http_click('get',$url); | 213 | + public function post_generate_jwt($data){ |
| 214 | + $param = [ | ||
| 215 | + 'title'=>$data['domain'], | ||
| 216 | + 'refId'=>$this->private_key, | ||
| 217 | + 'profileKey'=>$this->profile_key, | ||
| 218 | + ]; | ||
| 219 | + $url = $this->path.'/api/profiles/generateJWT'; | ||
| 220 | + return $this->http_click('post',$url,$param); | ||
| 206 | } | 221 | } |
| 207 | 222 | ||
| 208 | public function api_user(){ | 223 | public function api_user(){ |
| @@ -31,7 +31,70 @@ class AyrShareController extends BaseController | @@ -31,7 +31,70 @@ class AyrShareController extends BaseController | ||
| 31 | * @time :2023/5/5 16:44 | 31 | * @time :2023/5/5 16:44 |
| 32 | */ | 32 | */ |
| 33 | public function create_account(AyrShareLogic $ayrShareLogic){ | 33 | public function create_account(AyrShareLogic $ayrShareLogic){ |
| 34 | - $ayrShareLogic->ayr_share_add(); | 34 | + $param = [ |
| 35 | + 'title'=>md5(uniqid().time()) | ||
| 36 | + ]; | ||
| 37 | + //发送请求注册社交用户 | ||
| 38 | + $ayrShareHelper = new AyrShareHelper(); | ||
| 39 | + $res = $ayrShareHelper->post_create_profiles($param); | ||
| 40 | + if($res['status'] == 'fail'){ | ||
| 41 | + $this->response('同步绑定失败'); | ||
| 42 | + } | ||
| 43 | + //执行数据库操作 | ||
| 44 | + $ayrShareLogic->ayr_share_add($res); | ||
| 45 | + $this->response('success'); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * @name :(删除用户账号并同步ayr_share账号)edit_account | ||
| 50 | + * @author :lyh | ||
| 51 | + * @method :post | ||
| 52 | + * @time :2023/5/6 10:11 | ||
| 53 | + */ | ||
| 54 | + public function del_account(AyrShareLogic $ayrShareLogic){ | ||
| 55 | + $this->request->validate([ | ||
| 56 | + 'id'=>['required'] | ||
| 57 | + ],[ | ||
| 58 | + 'id.required' => 'ID不能为空' | ||
| 59 | + ]); | ||
| 60 | + $info = $ayrShareLogic->ayr_share_info(); | ||
| 61 | + $data = [ | ||
| 62 | + 'title'=>$info['title'], | ||
| 63 | + 'profileKey'=>$info['profile_key'] | ||
| 64 | + ]; | ||
| 65 | + //发送请求注册社交用户 | ||
| 66 | + $ayrShareHelper = new AyrShareHelper(); | ||
| 67 | + $res = $ayrShareHelper->deleted_profiles($data); | ||
| 68 | + if($res['status'] == 'fail'){ | ||
| 69 | + $this->response('同步删除失败'); | ||
| 70 | + } | ||
| 71 | + $ayrShareLogic->ayr_share_del(); | ||
| 72 | + $this->response('success'); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * @name :(授权绑定第三方平台,生成jwt令牌)ayr_share_bind | ||
| 77 | + * @author :lyh | ||
| 78 | + * @method :post | ||
| 79 | + * @time :2023/5/6 10:24 | ||
| 80 | + */ | ||
| 81 | + public function bind_account(AyrShareLogic $ayrShareLogic){ | ||
| 82 | + $this->request->validate([ | ||
| 83 | + 'id'=>['required'] | ||
| 84 | + ],[ | ||
| 85 | + 'id.required' => 'ID不能为空' | ||
| 86 | + ]); | ||
| 87 | + $info = $ayrShareLogic->ayr_share_info(); | ||
| 88 | + //发送请求注册社交用户 | ||
| 89 | + $ayrShareHelper = new AyrShareHelper(); | ||
| 90 | + $data = [ | ||
| 91 | + 'domain'=>$this->request->getHost(), | ||
| 92 | + 'profileKey'=>$info['profile_key'] | ||
| 93 | + ]; | ||
| 94 | + $res = $ayrShareHelper->post_generate_jwt($data); | ||
| 95 | + if($res['status'] == 'fail'){ | ||
| 96 | + $this->response('生成令牌失败'); | ||
| 97 | + } | ||
| 35 | $this->response('success'); | 98 | $this->response('success'); |
| 36 | } | 99 | } |
| 37 | } | 100 | } |
| @@ -17,21 +17,12 @@ class AyrShareLogic extends BaseLogic | @@ -17,21 +17,12 @@ class AyrShareLogic extends BaseLogic | ||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | - * @name :(创建账号并绑定)ayr_add | 20 | + * @name :(创建账号并绑定写入数据库)ayr_add |
| 21 | * @author :lyh | 21 | * @author :lyh |
| 22 | * @method :post | 22 | * @method :post |
| 23 | * @time :2023/5/6 9:19 | 23 | * @time :2023/5/6 9:19 |
| 24 | */ | 24 | */ |
| 25 | - public function ayr_share_add(){ | ||
| 26 | - $param = [ | ||
| 27 | - 'title'=>md5(uniqid().time()) | ||
| 28 | - ]; | ||
| 29 | - //发送请求注册社交用户 | ||
| 30 | - $ayrShareHelper = new AyrShareHelper(); | ||
| 31 | - $res = $ayrShareHelper->post_create_profiles($param); | ||
| 32 | - if($res['status'] == 'fail'){ | ||
| 33 | - $this->response('绑定失败'); | ||
| 34 | - } | 25 | + public function ayr_share_add($res){ |
| 35 | //插入数据库 | 26 | //插入数据库 |
| 36 | $data = [ | 27 | $data = [ |
| 37 | 'title'=>$res['title'], | 28 | 'title'=>$res['title'], |
| @@ -49,12 +40,34 @@ class AyrShareLogic extends BaseLogic | @@ -49,12 +40,34 @@ class AyrShareLogic extends BaseLogic | ||
| 49 | } | 40 | } |
| 50 | 41 | ||
| 51 | /** | 42 | /** |
| 52 | - * @name :(zhuzhuang)sql_add | 43 | + * @name :(获取当前数据详情)ayr_share_del |
| 53 | * @author :lyh | 44 | * @author :lyh |
| 54 | * @method :post | 45 | * @method :post |
| 55 | - * @time :2023/5/6 10:04 | 46 | + * @time :2023/5/6 10:16 |
| 56 | */ | 47 | */ |
| 57 | - public function sql_add(){ | 48 | + public function ayr_share_info(){ |
| 49 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 50 | + if($info === false){ | ||
| 51 | + $this->fail('当前数据不存在或已被删除'); | ||
| 52 | + } | ||
| 53 | + return $this->success($info); | ||
| 54 | + } | ||
| 58 | 55 | ||
| 56 | + /** | ||
| 57 | + * @name :(删除ayr数据并同步删除) | ||
| 58 | + * @author :lyh | ||
| 59 | + * @method :post | ||
| 60 | + * @time :2023/5/6 10:18 | ||
| 61 | + */ | ||
| 62 | + public function ayr_share_del(){ | ||
| 63 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 64 | + $rs = $this->model->del($this->param); | ||
| 65 | + if($rs === false){ | ||
| 66 | + $this->fail('删出失败'); | ||
| 67 | + } | ||
| 68 | + return $this->success(); | ||
| 59 | } | 69 | } |
| 60 | } | 70 | } |
| 71 | + | ||
| 72 | + | ||
| 73 | + |
| @@ -199,6 +199,8 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -199,6 +199,8 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 199 | Route::prefix('ayr')->group(function () { | 199 | Route::prefix('ayr')->group(function () { |
| 200 | Route::any('/lists', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists'); | 200 | Route::any('/lists', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists'); |
| 201 | Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account'); | 201 | Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account'); |
| 202 | + Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account'); | ||
| 203 | + Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account'); | ||
| 202 | }); | 204 | }); |
| 203 | }); | 205 | }); |
| 204 | 206 |
-
请 注册 或 登录 后发表评论