作者 lyh

gx

@@ -53,33 +53,26 @@ class AyrReleaseController extends BaseController @@ -53,33 +53,26 @@ class AyrReleaseController extends BaseController
53 * @time :2023/5/9 9:36 53 * @time :2023/5/9 9:36
54 */ 54 */
55 public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ 55 public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){
56 -// DB::beginTransaction();  
57 -// try {  
58 - //获取发送账号详情  
59 - $share_info = $ayrShareLogic->ayr_share_info();  
60 - $data = [  
61 - 'images'=>$this->param['image'],  
62 - 'files'=>$this->param['file'],  
63 - ];  
64 - //参数处理  
65 - $this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);;  
66 - //统一生成链接  
67 - $param = [  
68 - 'post'=>$this->param['content'],  
69 - 'platforms'=>$this->param['platforms'],  
70 - 'mediaUrls'=>$this->param['mediaUrls'],//参数处理  
71 - 'idempotencyKey'=>$this->param['idempotencyKey'],//时间(如是过去时间,立即发布)  
72 - ];  
73 - //发送请求注册社交用户  
74 - $res = $ayrShare->post_send_msg($param,$share_info['profile_key']);  
75 - $this->response('success',Code::SUCCESS,$res);  
76 - //保存数据库  
77 - $ayrReleaseLogic->release_add();  
78 -// DB::commit();  
79 -// }catch (\Exception $e){  
80 -// DB::rollBack();  
81 -// $this->response('error',Code::USER_ERROR);  
82 -// } 56 + //获取发送账号详情
  57 + $share_info = $ayrShareLogic->ayr_share_info();
  58 + $data = [
  59 + 'images'=>$this->param['images'],
  60 + 'files'=>$this->param['video'],
  61 + ];
  62 + //参数处理
  63 + $this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);;
  64 + //统一生成发布
  65 + $param = [
  66 + 'post'=>$this->param['content'],
  67 + 'platforms'=>$this->param['platforms'],
  68 + 'mediaUrls'=>$this->param['mediaUrls'],//参数处理
  69 + 'idempotencyKey'=>$this->param['idempotency_key'],//时间(如是过去时间,立即发布)
  70 + ];
  71 + //发送请求发布社交文章
  72 + $res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
  73 + //保存数据库
  74 + $ayrReleaseLogic->release_add();
  75 + $this->response('success',Code::SUCCESS,$res);
83 } 76 }
84 77
85 /** 78 /**
@@ -22,7 +22,10 @@ class AyrShareController extends BaseController @@ -22,7 +22,10 @@ class AyrShareController extends BaseController
22 * @time :2023/5/5 16:06 22 * @time :2023/5/5 16:06
23 */ 23 */
24 public function lists(AyrShareModel $ayrShareModel){ 24 public function lists(AyrShareModel $ayrShareModel){
25 - $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']); 25 + //授权配置列表
  26 + $share_list = $ayrShareModel->platforms;
  27 + $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['id','name','bind_plat_from','operator_id','created_at','updated_at']);
  28 + $lists['share_list'] = $share_list;
26 $this->response('列表',Code::SUCCESS,$lists); 29 $this->response('列表',Code::SUCCESS,$lists);
27 } 30 }
28 31
@@ -38,6 +38,8 @@ class AyrReleaseLogic extends BaseLogic @@ -38,6 +38,8 @@ class AyrReleaseLogic extends BaseLogic
38 * @time :2023/5/9 9:38 38 * @time :2023/5/9 9:38
39 */ 39 */
40 public function release_add(){ 40 public function release_add(){
  41 + $this->param['project_id'] = $this->user['project_id'];
  42 + $this->param['operator_id'] = $this->user['id'];
41 $rs = $this->model->add($this->param); 43 $rs = $this->model->add($this->param);
42 if($rs === false){ 44 if($rs === false){
43 $this->fail('error'); 45 $this->fail('error');
@@ -48,7 +48,7 @@ class AyrShareLogic extends BaseLogic @@ -48,7 +48,7 @@ class AyrShareLogic extends BaseLogic
48 * @time :2023/5/6 10:16 48 * @time :2023/5/6 10:16
49 */ 49 */
50 public function ayr_share_info(){ 50 public function ayr_share_info(){
51 - $info = $this->model->read(['id'=>$this->param['id']]); 51 + $info = $this->model->read(['id'=>$this->param['share_id']]);
52 if($info === false){ 52 if($info === false){
53 $this->fail('当前数据不存在或已被删除'); 53 $this->fail('当前数据不存在或已被删除');
54 } 54 }
  1 +<?php
  2 +
  3 +namespace App\Http\Requests\Bside\AyrRelease;
  4 +
  5 +use Illuminate\Foundation\Http\FormRequest;
  6 +
  7 +class AyrReleaseRequest extends FormRequest
  8 +{
  9 + /**
  10 + * Determine if the user is authorized to make this request.
  11 + *
  12 + * @return bool
  13 + */
  14 + public function authorize()
  15 + {
  16 + return true;
  17 + }
  18 + /**
  19 + * Get the validation rules that apply to the request.
  20 + *
  21 + * @return array
  22 + */
  23 + public function rules()
  24 + {
  25 + return [
  26 + 'title'=>'required',
  27 + 'images'=>'required',
  28 + 'video'=>'required',
  29 + 'content'=>'required',
  30 + 'share_id'=>'required',
  31 + 'platforms'=>'required',
  32 + 'idempotency_key'=>'required',
  33 + ];
  34 + }
  35 +
  36 + public function messages()
  37 + {
  38 + return [
  39 + 'name.required'=>'参数错误',
  40 + ];
  41 + }
  42 +}
@@ -7,4 +7,30 @@ use App\Models\Base; @@ -7,4 +7,30 @@ use App\Models\Base;
7 class AyrShare extends Base 7 class AyrShare extends Base
8 { 8 {
9 protected $table = 'gl_ayr_share'; 9 protected $table = 'gl_ayr_share';
  10 +
  11 + const TYPE_FACEBOOK = 1;
  12 + const TYPE_TWITTER = 2;
  13 + const TYPE_LINKEDIN = 3;
  14 + const TYPE_INSTAGRAM = 4;
  15 + const TYPE_YOUTUBE = 5;
  16 + const TYPE_REDDIT = 6;
  17 + const TYPE_TELEGRAM = 7;
  18 + const TYPE_GMB = 8;
  19 + const TYPE_PINTEREST = 9;
  20 + const TYPE_TIKTOK = 10;
  21 + /**
  22 + * @var :授权列表
  23 + */
  24 + public $platforms = [
  25 + self::TYPE_FACEBOOK => 'Facebook',
  26 + self::TYPE_TWITTER => 'Twitter',
  27 + self::TYPE_LINKEDIN => 'LinkedIn',
  28 + self::TYPE_INSTAGRAM => 'Instagram',
  29 + self::TYPE_YOUTUBE => 'YouTube',
  30 + self::TYPE_REDDIT => 'Reddit',
  31 + self::TYPE_TELEGRAM => 'Telegram',
  32 + self::TYPE_GMB => 'Google',
  33 + self::TYPE_PINTEREST => 'Pinterest',
  34 + self::TYPE_TIKTOK => 'TikTok',
  35 + ];
10 } 36 }