作者 lyh

gx

@@ -91,7 +91,7 @@ class AyrShareController extends BaseController @@ -91,7 +91,7 @@ class AyrShareController extends BaseController
91 $this->response('同步绑定失败'); 91 $this->response('同步绑定失败');
92 } 92 }
93 //执行数据库操作 93 //执行数据库操作
94 - $ayrShareLogic->ayr_share_add($res); 94 + $ayrShareLogic->ayr_share_save($res);
95 $this->response('success'); 95 $this->response('success');
96 } 96 }
97 97
@@ -108,15 +108,17 @@ class AyrShareController extends BaseController @@ -108,15 +108,17 @@ class AyrShareController extends BaseController
108 'id.required' => 'ID不能为空' 108 'id.required' => 'ID不能为空'
109 ]); 109 ]);
110 $info = $ayrShareLogic->ayr_share_info(); 110 $info = $ayrShareLogic->ayr_share_info();
111 - $data = [ 111 + if(!empty($info['title'])){
  112 + $data = [
112 // 'title'=>$info['title'], 113 // 'title'=>$info['title'],
113 - 'profileKey'=>$info['profile_key']  
114 - ];  
115 - //发送请求删除社交用户  
116 - $ayrShareHelper = new AyrShareHelper();  
117 - $res = $ayrShareHelper->deleted_profiles($data);  
118 - if($res['status'] == 'fail'){  
119 - $this->response('同步删除失败'); 114 + 'profileKey'=>$info['profile_key']
  115 + ];
  116 + //发送请求删除社交用户
  117 + $ayrShareHelper = new AyrShareHelper();
  118 + $res = $ayrShareHelper->deleted_profiles($data);
  119 + if($res['status'] == 'fail'){
  120 + $this->response('同步删除失败');
  121 + }
120 } 122 }
121 $ayrShareLogic->ayr_share_del(); 123 $ayrShareLogic->ayr_share_del();
122 $this->response('success'); 124 $this->response('success');
@@ -46,7 +46,7 @@ class AyrShareLogic extends BaseLogic @@ -46,7 +46,7 @@ class AyrShareLogic extends BaseLogic
46 * @method :post 46 * @method :post
47 * @time :2023/5/6 9:19 47 * @time :2023/5/6 9:19
48 */ 48 */
49 - public function ayr_share_add($res){ 49 + public function ayr_share_save($res){
50 //插入数据库 50 //插入数据库
51 $param = [ 51 $param = [
52 'title'=>$res['title'], 52 'title'=>$res['title'],
@@ -56,7 +56,12 @@ class AyrShareLogic extends BaseLogic @@ -56,7 +56,12 @@ class AyrShareLogic extends BaseLogic
56 'project_id'=>$this->user['project_id'], 56 'project_id'=>$this->user['project_id'],
57 'name'=>$this->param['name'], 57 'name'=>$this->param['name'],
58 ]; 58 ];
59 - $rs = $this->model->add($param); 59 + $info = $this->model->read(['name'=>$this->param['name']]);
  60 + if($info !== false){
  61 + $rs = $this->model->edit($param,['id'=>$info['id']]);
  62 + }else{
  63 + $rs = $this->model->add($param);
  64 + }
60 if($rs === false){ 65 if($rs === false){
61 $this->fail('error'); 66 $this->fail('error');
62 } 67 }