作者 邓超

Merge branch 'develop' into dc

@@ -124,15 +124,6 @@ class Handler extends ExceptionHandler @@ -124,15 +124,6 @@ class Handler extends ExceptionHandler
124 } else { 124 } else {
125 $code = Code::SYSTEM_ERROR(); 125 $code = Code::SYSTEM_ERROR();
126 } 126 }
127 - //钉钉通知错误信息  
128 - if (in_array(config('app.env'), ['test', 'production']) && (in_array(substr($code, 0, 1), ['B', 'C']))) {  
129 - $exceptionMessage = "路由:" . Route::current()->uri .  
130 - "-----错误CODE:" . $exception->getCode() .  
131 - "-----错误message:" . $exception->getMessage() .  
132 - '------错误文件:' . $exception->getFile() . '-------错误行数:' .  
133 - $exception->getLine();  
134 - (new DingService())->handle(['keyword' => "ERROR", 'msg' => config('app.env') . '环境报错:' . $exceptionMessage, 'isAtAll' => false]);  
135 - }  
136 //开启debug 错误原样输出 127 //开启debug 错误原样输出
137 $debub = config('app.debug'); 128 $debub = config('app.debug');
138 $message = $debub ? $message : ($code->description ?? $message); 129 $message = $debub ? $message : ($code->description ?? $message);
@@ -111,10 +111,10 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K @@ -111,10 +111,10 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
111 * @param :platforms: "facebook", "fbg", "twitter", 111 * @param :platforms: "facebook", "fbg", "twitter",
112 * "linkedin", "instagram","youtube", "reddit" ,"telegram"" 112 * "linkedin", "instagram","youtube", "reddit" ,"telegram""
113 */ 113 */
114 - public function post_send_msg($param){ 114 + public function post_send_msg($param,$api_key){
115 //平台参数处理 115 //平台参数处理
116 $this->headers['Accept-Encoding'] = 'gzip'; 116 $this->headers['Accept-Encoding'] = 'gzip';
117 - $this->headers['Authorization'] = $this->headers['Authorization'].$param['profile_key']; 117 + $this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
118 $url = $this->path.'/api/post'; 118 $url = $this->path.'/api/post';
119 return $this->http_click('posts',$url,$param,$this->headers); 119 return $this->http_click('posts',$url,$param,$this->headers);
120 } 120 }
@@ -127,15 +127,10 @@ class Common @@ -127,15 +127,10 @@ class Common
127 * @method :post 127 * @method :post
128 * @time :2023/5/9 10:47 128 * @time :2023/5/9 10:47
129 */ 129 */
130 - public static function uniqueMultiArray($multiArray) {  
131 - $flatArray = array();  
132 - foreach ($multiArray as $item) {  
133 - if (is_array($item)) {  
134 - $flatArray = array_merge($flatArray, uniqueMultiArray($item));  
135 - } else {  
136 - $flatArray[] = $item;  
137 - }  
138 - }  
139 - return array_map("unserialize", array_unique(array_map("serialize", $flatArray))); 130 + public static function uniqueMultiArray($arr) {
  131 + $arr = array_map('serialize', $arr);
  132 + $arr = array_unique($arr);
  133 + $arr = array_map('unserialize', $arr);
  134 + return $arr;
140 } 135 }
141 } 136 }
@@ -2,8 +2,11 @@ @@ -2,8 +2,11 @@
2 2
3 namespace App\Http\Controllers\Bside\AyrShare; 3 namespace App\Http\Controllers\Bside\AyrShare;
4 4
  5 +use App\Enums\Common\Code;
  6 +use App\Helper\AyrShare as AyrShareHelper;
5 use App\Http\Controllers\Bside\BaseController; 7 use App\Http\Controllers\Bside\BaseController;
6 use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; 8 use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic;
  9 +use App\Http\Logic\Bside\AyrShare\AyrShareLogic;
7 10
8 /** 11 /**
9 * @name:社交发布 12 * @name:社交发布
@@ -11,15 +14,95 @@ use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; @@ -11,15 +14,95 @@ use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic;
11 class AyrReleaseController extends BaseController 14 class AyrReleaseController extends BaseController
12 { 15 {
13 /** 16 /**
  17 + * @name :(获取当前用户已绑定的社交链接)info
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2023/5/9 16:00
  21 + */
  22 + public function info(AyrShareLogic $ayrShareLogic){
  23 + $info = $ayrShareLogic->ayr_share_info();
  24 + $this->response('success',Code::SUCCESS,$info);
  25 + }
  26 + /**
14 * @name :(发布社交)send_post 27 * @name :(发布社交)send_post
15 * @author :lyh 28 * @author :lyh
16 * @method :post 29 * @method :post
17 * @time :2023/5/9 9:36 30 * @time :2023/5/9 9:36
18 */ 31 */
19 - public function send_post(AyrReleaseLogic $ayrReleaseLogic){  
20 - //保存数据库  
21 - $ayrReleaseLogic->release_add();  
22 - 32 + public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic){
  33 +// DB::beginTransaction();
  34 +// try {
  35 + //获取发送账号详情
  36 + $share_info = $ayrShareLogic->ayr_share_info();
  37 + $data = [
  38 + 'images'=>$this->param['image'],
  39 + 'files'=>$this->param['file'],
  40 + ];
  41 + //参数处理
  42 + $image_data = $this->image_file_param($data);
  43 + $this->param['mediaUrls'] = array_merge($image_data['images_link'],$image_data['files_link']);
  44 + var_dump($this->param);
  45 + die();
  46 + //统一生成链接
  47 + $param = [
  48 + 'post'=>$this->param['content'],
  49 + 'platforms'=>$this->param['platforms'],
  50 + 'mediaUrls'=>$this->param['mediaUrls'],//参数处理
  51 + ];
  52 + //发送请求注册社交用户
  53 + $ayrShareHelper = new AyrShareHelper();
  54 + $res = $ayrShareHelper->post_send_msg($param,$share_info['profile_key']);
  55 + $this->response('success',Code::SUCCESS,$res);
  56 + //保存数据库
  57 + $ayrReleaseLogic->release_add();
  58 +// DB::commit();
  59 +// }catch (\Exception $e){
  60 +// DB::rollBack();
  61 +// $this->response('error',Code::USER_ERROR);
  62 +// }
23 } 63 }
24 64
  65 + /**
  66 + * @name :(上传第三方参数参数)get_param
  67 + * @author :lyh
  68 + * @method :post
  69 + * @time :2023/5/10 10:27
  70 + */
  71 + public function image_file_param($data) {
  72 + if (empty($data) || !is_array($data)) {
  73 + return empty($data) ? is_array($data) ? [] : '' : $data;
  74 + }
  75 + foreach ($data as $k => $v) {
  76 + if (is_array($v)) {
  77 + $data[$k] = $this->_extents($v);
  78 + } else {
  79 + if (is_null($v)) {
  80 + $data[$k] = '';
  81 + continue;
  82 + }
  83 + //获取操作人
  84 + switch ((string) $k) {
  85 + case 'image':
  86 + $data['image_link'] = url('/b/image/' . $v . '/2');
  87 + break;
  88 + case 'images':
  89 + $v = explode(',',$v);
  90 + foreach ($v as $k1=>$v1){
  91 + $data['images_link'][$k1] = url('/b/image/' . $v1 . '/2');
  92 + }
  93 + break;
  94 + case 'file':
  95 + $data['file_link'] = url('/b/file_hash/' . $v .'/mp4');
  96 + break;
  97 + case 'files':
  98 + $v = explode(',',$v);
  99 + foreach ($v as $k1=>$v1){
  100 + $data['files_link'][$k1] = url('/b/file_hash/' . $v1 . '/mp4');
  101 + }
  102 + break;
  103 + }
  104 + }
  105 + }
  106 + return $data;
  107 + }
25 } 108 }
@@ -21,14 +21,26 @@ class AyrShareController extends BaseController @@ -21,14 +21,26 @@ class AyrShareController extends BaseController
21 */ 21 */
22 public function lists(AyrShareModel $ayrShareModel){ 22 public function lists(AyrShareModel $ayrShareModel){
23 $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']); 23 $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']);
24 - $ayrShareHelper = new AyrShareHelper();  
25 - foreach ($lists['list'] as $k=>$v){  
26 - $lists['list'][$k]['ayr'] = $ayrShareHelper->get_profiles_users($v['profile_key']);  
27 - }  
28 $this->response('列表',Code::SUCCESS,$lists); 24 $this->response('列表',Code::SUCCESS,$lists);
29 } 25 }
30 26
31 /** 27 /**
  28 + * @name :(定时更新)save_account
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/5/9 14:39
  32 + */
  33 + public function save_account(AyrShareLogic $ayrShareLogic){
  34 + $info = $ayrShareLogic->ayr_share_info();
  35 + $ayrShareHelper = new AyrShareHelper();
  36 + $share_info = $ayrShareHelper->get_profiles_users($info['profile_key']);
  37 + if(isset($share_info['activeSocialAccounts'])){
  38 + $str = json_encode($share_info['activeSocialAccounts']);
  39 + $ayrShareLogic->ayr_share_edit(['bind_plat_from'=>$str]);
  40 + }
  41 + $this->response('success');
  42 + }
  43 + /**
32 * @name :(创建ayr_share账户)create_account 44 * @name :(创建ayr_share账户)create_account
33 * @author :lyh 45 * @author :lyh
34 * @method :post 46 * @method :post
@@ -66,7 +78,7 @@ class AyrShareController extends BaseController @@ -66,7 +78,7 @@ class AyrShareController extends BaseController
66 'title'=>$info['title'], 78 'title'=>$info['title'],
67 'profileKey'=>$info['profile_key'] 79 'profileKey'=>$info['profile_key']
68 ]; 80 ];
69 - //发送请求注册社交用户 81 + //发送请求删除社交用户
70 $ayrShareHelper = new AyrShareHelper(); 82 $ayrShareHelper = new AyrShareHelper();
71 $res = $ayrShareHelper->deleted_profiles($data); 83 $res = $ayrShareHelper->deleted_profiles($data);
72 if($res['status'] == 'fail'){ 84 if($res['status'] == 'fail'){
@@ -41,16 +41,6 @@ class BaseController extends Controller @@ -41,16 +41,6 @@ class BaseController extends Controller
41 $this->set_user_log(); 41 $this->set_user_log();
42 } 42 }
43 } 43 }
44 -  
45 - /**  
46 - * @name :ceshi  
47 - * @author :lyh  
48 - * @method :post  
49 - * @time :2023/5/9 11:43  
50 - */  
51 - public function ceshi(){  
52 -  
53 - }  
54 /** 44 /**
55 * @name 参数过滤 45 * @name 参数过滤
56 * @return void 46 * @return void
@@ -152,7 +142,6 @@ class BaseController extends Controller @@ -152,7 +142,6 @@ class BaseController extends Controller
152 * @method 142 * @method
153 */ 143 */
154 protected function _extents($data) { 144 protected function _extents($data) {
155 -  
156 if (empty($data) || !is_array($data)) { 145 if (empty($data) || !is_array($data)) {
157 return empty($data) ? is_array($data) ? [] : '' : $data; 146 return empty($data) ? is_array($data) ? [] : '' : $data;
158 } 147 }
@@ -169,6 +158,12 @@ class BaseController extends Controller @@ -169,6 +158,12 @@ class BaseController extends Controller
169 case 'image': 158 case 'image':
170 $data['image_link'] = url('/b/image/' . $v); 159 $data['image_link'] = url('/b/image/' . $v);
171 break; 160 break;
  161 + case 'images':
  162 + $v = explode(',',$v);
  163 + foreach ($v as $k1=>$v1){
  164 + $data['images_link'][$k1] = url('/b/image/' . $v1);
  165 + }
  166 + break;
172 case 'file': 167 case 'file':
173 $data['file_link'] = url('/b/file_hash/' . $v); 168 $data['file_link'] = url('/b/file_hash/' . $v);
174 break; 169 break;
@@ -11,6 +11,7 @@ use App\Http\Logic\Bside\Setting\WebSettingServiceLogic; @@ -11,6 +11,7 @@ use App\Http\Logic\Bside\Setting\WebSettingServiceLogic;
11 */ 11 */
12 class WebSettingServiceController extends BaseController 12 class WebSettingServiceController extends BaseController
13 { 13 {
  14 + const TYPE_CODE = 6;
14 /** 15 /**
15 * @name :lists 16 * @name :lists
16 * @author :lyh 17 * @author :lyh
@@ -19,6 +20,12 @@ class WebSettingServiceController extends BaseController @@ -19,6 +20,12 @@ class WebSettingServiceController extends BaseController
19 */ 20 */
20 public function lists(WebSettingServiceLogic $webSettingServiceLogic){ 21 public function lists(WebSettingServiceLogic $webSettingServiceLogic){
21 $lists = $webSettingServiceLogic->setting_service_list(); 22 $lists = $webSettingServiceLogic->setting_service_list();
  23 + foreach ($lists as $k => $v){
  24 + if($v['type'] == self::TYPE_CODE){
  25 + $v['values_link'] = url('/b/image/' . $v['values']);
  26 + $lists[$k] = $v;
  27 + }
  28 + }
22 $this->response('success',Code::SUCCESS,$lists); 29 $this->response('success',Code::SUCCESS,$lists);
23 } 30 }
24 /** 31 /**
@@ -25,7 +25,7 @@ class FileController @@ -25,7 +25,7 @@ class FileController
25 25
26 public $config = ''; 26 public $config = '';
27 27
28 - public $thr_path = ''; 28 + public $uploads = '';
29 29
30 public $request = ''; 30 public $request = '';
31 31
@@ -33,7 +33,8 @@ class FileController @@ -33,7 +33,8 @@ class FileController
33 { 33 {
34 $this->request = request(); 34 $this->request = request();
35 $this->config = config('filesystems.disks.upload'); 35 $this->config = config('filesystems.disks.upload');
36 - $this->path = $this->config['root'].'/file/'; 36 + $this->uploads = config('uploads.default_file');
  37 + $this->path = $this->config['root'].$this->uploads['path'].'/';
37 } 38 }
38 39
39 /** 40 /**
@@ -43,7 +44,7 @@ class FileController @@ -43,7 +44,7 @@ class FileController
43 * @method :post 44 * @method :post
44 * @time :2023/5/9 9:15 45 * @time :2023/5/9 9:15
45 */ 46 */
46 - public function index($hash = ''){ 47 + public function index($hash = '',$type = 1){
47 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { 48 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
48 header("HTTP/1.1 304 Not Modified"); 49 header("HTTP/1.1 304 Not Modified");
49 exit; 50 exit;
@@ -59,6 +60,7 @@ class FileController @@ -59,6 +60,7 @@ class FileController
59 } 60 }
60 $content = file_get_contents($path); 61 $content = file_get_contents($path);
61 $header['Content-Length'] = $info['size']; 62 $header['Content-Length'] = $info['size'];
  63 + $header['Content-Type'] = 'video/'.$info['type'];
62 return response($content, 200, $header); 64 return response($content, 200, $header);
63 } 65 }
64 /** 66 /**
@@ -66,9 +68,9 @@ class FileController @@ -66,9 +68,9 @@ class FileController
66 */ 68 */
67 public function upload() { 69 public function upload() {
68 $this->request->validate([ 70 $this->request->validate([
69 - 'image'=>['required'], 71 + 'file'=>['required'],
70 ],[ 72 ],[
71 - 'image.required'=>'图片必须填写', 73 + 'file.required'=>'必须填写',
72 ]); 74 ]);
73 $files = $this->request->file('file'); 75 $files = $this->request->file('file');
74 if (empty($files)) { 76 if (empty($files)) {
@@ -82,7 +84,7 @@ class FileController @@ -82,7 +84,7 @@ class FileController
82 } 84 }
83 } 85 }
84 /** 86 /**
85 - * @name :上传图片 87 + * @name :上传
86 * @return void 88 * @return void
87 * @author :liyuhang 89 * @author :liyuhang
88 * @method 90 * @method
@@ -96,12 +98,13 @@ class FileController @@ -96,12 +98,13 @@ class FileController
96 return $hash; 98 return $hash;
97 } 99 }
98 $url = $this->path; 100 $url = $this->path;
99 - $res = $this->request->file('image')->move($url); 101 + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
  102 + $res = $files->move($url,$fileName);
100 if ($res === false) { 103 if ($res === false) {
101 return $this->response($files->getError(), Code::USER_ERROR); 104 return $this->response($files->getError(), Code::USER_ERROR);
102 } 105 }
103 $data = [ 106 $data = [
104 - 'path' => $url.'/'.$res->getClientOriginalName(), 107 + 'path' => $url.$fileName,
105 'created_at' => date('Y-m-d H:i:s',time()), 108 'created_at' => date('Y-m-d H:i:s',time()),
106 'size' => $res->getSize(), 109 'size' => $res->getSize(),
107 'hash' => $hash, 110 'hash' => $hash,
@@ -111,7 +114,7 @@ class FileController @@ -111,7 +114,7 @@ class FileController
111 if ($rs === false) { 114 if ($rs === false) {
112 return $this->response('添加失败', Code::USER_ERROR); 115 return $this->response('添加失败', Code::USER_ERROR);
113 } 116 }
114 - return $hash; 117 + return $this->response('资源',Code::SUCCESS,['file'=>$hash]);
115 } 118 }
116 /** 119 /**
117 * 多文件上传 120 * 多文件上传
@@ -133,12 +136,13 @@ class FileController @@ -133,12 +136,13 @@ class FileController
133 continue; 136 continue;
134 } 137 }
135 $url = $this->path; 138 $url = $this->path;
136 - $res = $file->move($url); 139 + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
  140 + $res = $file->move($url,$fileName);
137 if ($res === false) { 141 if ($res === false) {
138 return $this->response($file->getError(), Code::USER_ERROR); 142 return $this->response($file->getError(), Code::USER_ERROR);
139 } 143 }
140 $save_data[] = [ 144 $save_data[] = [
141 - 'path' => $url.'/'.$res->getClientOriginalName(), 145 + 'path' => $url.$fileName,
142 'created_at' => date('Y-m-d H:i:s',time()), 146 'created_at' => date('Y-m-d H:i:s',time()),
143 'size' => $res->getSize(), 147 'size' => $res->getSize(),
144 'hash' => $hash, 148 'hash' => $hash,
@@ -147,7 +151,7 @@ class FileController @@ -147,7 +151,7 @@ class FileController
147 $data[] = $hash; 151 $data[] = $hash;
148 } 152 }
149 $fileModel->insert($save_data); 153 $fileModel->insert($save_data);
150 - return $data; 154 + return $this->response('资源',Code::SUCCESS,['files'=>$data]);
151 } 155 }
152 /** 156 /**
153 * @name 统一返回参数 157 * @name 统一返回参数
@@ -161,10 +165,46 @@ class FileController @@ -161,10 +165,46 @@ class FileController
161 $result = [ 165 $result = [
162 'msg' => $msg == ' ' ? $code->description : $msg, 166 'msg' => $msg == ' ' ? $code->description : $msg,
163 'code' => $code->value, 167 'code' => $code->value,
164 - 'data' => $data, 168 + 'data' => $this->_extents($data),
165 ]; 169 ];
166 $this->header['Content-Type'] = $type; 170 $this->header['Content-Type'] = $type;
167 $response = response($result,$result_code,$this->header); 171 $response = response($result,$result_code,$this->header);
168 throw new HttpResponseException($response); 172 throw new HttpResponseException($response);
169 } 173 }
  174 +
  175 + /**
  176 + * @param $data
  177 + * @name :返回参数处理
  178 + * @return array|string
  179 + * @author :liyuhang
  180 + * @method
  181 + */
  182 + protected function _extents($data) {
  183 +
  184 + if (empty($data) || !is_array($data)) {
  185 + return empty($data) ? is_array($data) ? [] : '' : $data;
  186 + }
  187 + foreach ($data as $k => $v) {
  188 + if (is_array($v)) {
  189 + $data[$k] = $this->_extents($v);
  190 + } else {
  191 + if (is_null($v)) {
  192 + $data[$k] = '';
  193 + continue;
  194 + }
  195 + switch ((string) $k) {
  196 + case 'file':
  197 + $data['file_link'] = url('/b/file_hash/' . $v .'/'.rand(100,999));
  198 + break;
  199 + case 'files':
  200 + $v = explode(',',$v);
  201 + foreach ($v as $k1=>$v1){
  202 + $data['files_link'][$k1] = url('/b/file_hash/' . $v1 . '/'.rand(100,999));
  203 + }
  204 + break;
  205 + }
  206 + }
  207 + }
  208 + return $data;
  209 + }
170 } 210 }
@@ -6,6 +6,7 @@ use App\Enums\Common\Code; @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\type; 6 use App\Http\Controllers\type;
7 use App\Http\Controllers\统一返回参数; 7 use App\Http\Controllers\统一返回参数;
8 use App\Models\File\Image as ImageModel; 8 use App\Models\File\Image as ImageModel;
  9 +use App\Models\User\User as UserModel;
9 use Illuminate\Http\Exceptions\HttpResponseException; 10 use Illuminate\Http\Exceptions\HttpResponseException;
10 use Illuminate\Http\JsonResponse; 11 use Illuminate\Http\JsonResponse;
11 use Illuminate\Support\Facades\Storage; 12 use Illuminate\Support\Facades\Storage;
@@ -24,6 +25,8 @@ class ImageController @@ -24,6 +25,8 @@ class ImageController
24 'Content-Description' => 'File Transfer', 25 'Content-Description' => 'File Transfer',
25 ], 26 ],
26 ]; 27 ];
  28 + const TYPE = 1;
  29 +
27 public $path = ''; 30 public $path = '';
28 31
29 public $config = ''; 32 public $config = '';
@@ -36,10 +39,11 @@ class ImageController @@ -36,10 +39,11 @@ class ImageController
36 { 39 {
37 $this->request = request(); 40 $this->request = request();
38 $this->config = config('filesystems.disks.upload'); 41 $this->config = config('filesystems.disks.upload');
39 - $this->path = $this->config['root']; 42 + $this->uploads = config('upload.default_image');
  43 + $this->path = $this->config['root'].$this->uploads['path'].'/';
40 } 44 }
41 45
42 - public function index($hash = '', $w = 0 ,$h = 0){ 46 + public function index($hash = '',$type = self::TYPE, $w = 0 ,$h = 0 ){
43 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { 47 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
44 header("HTTP/1.1 304 Not Modified"); 48 header("HTTP/1.1 304 Not Modified");
45 exit; 49 exit;
@@ -50,6 +54,7 @@ class ImageController @@ -50,6 +54,7 @@ class ImageController
50 $this->response('指定图片不存在!', Code::USER_ERROR); 54 $this->response('指定图片不存在!', Code::USER_ERROR);
51 } 55 }
52 //查看缩略图是否存在 56 //查看缩略图是否存在
  57 +// $header['Content-Type'] = 'image/'.$info['type'];
53 $filename = $this->path . $info['hash'] . $w . '_' . $h; 58 $filename = $this->path . $info['hash'] . $w . '_' . $h;
54 if(is_file($filename)){ 59 if(is_file($filename)){
55 $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT"; 60 $last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
@@ -78,7 +83,12 @@ class ImageController @@ -78,7 +83,12 @@ class ImageController
78 $img_type = $info['type']; 83 $img_type = $info['type'];
79 $content = base64_encode($content); 84 $content = base64_encode($content);
80 $img_base64 = 'data:image/' . $img_type . ';base64,' . $content; 85 $img_base64 = 'data:image/' . $img_type . ';base64,' . $content;
81 - return response($img_base64, 200, $header); 86 + if($type != self::TYPE){
  87 + header('Content-Type: image/' . $img_type);
  88 + echo base64_decode($content);
  89 + exit;
  90 + }
  91 + return response($img_base64,200,$header);
82 } 92 }
83 93
84 /** 94 /**
@@ -114,15 +124,16 @@ class ImageController @@ -114,15 +124,16 @@ class ImageController
114 $imageModel = new ImageModel(); 124 $imageModel = new ImageModel();
115 $image_hash = $imageModel->read(['hash'=>$hash]); 125 $image_hash = $imageModel->read(['hash'=>$hash]);
116 if($image_hash !== false){ 126 if($image_hash !== false){
117 - return $hash; 127 + return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
118 } 128 }
119 $url = $this->path; 129 $url = $this->path;
120 - $res = $this->request->file('image')->move($url); 130 + $fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
  131 + $res = $files->move($url,$fileName);
121 if ($res === false) { 132 if ($res === false) {
122 return $this->response($files->getError(), Code::USER_ERROR); 133 return $this->response($files->getError(), Code::USER_ERROR);
123 } 134 }
124 $data = [ 135 $data = [
125 - 'path' => $url.'/'.$res->getClientOriginalName(), 136 + 'path' => $url.$fileName,
126 'created_at' => date('Y-m-d H:i:s',time()), 137 'created_at' => date('Y-m-d H:i:s',time()),
127 'size' => $res->getSize(), 138 'size' => $res->getSize(),
128 'hash' => $hash, 139 'hash' => $hash,
@@ -132,7 +143,7 @@ class ImageController @@ -132,7 +143,7 @@ class ImageController
132 if ($rs === false) { 143 if ($rs === false) {
133 return $this->response('添加失败', Code::USER_ERROR); 144 return $this->response('添加失败', Code::USER_ERROR);
134 } 145 }
135 - return $hash; 146 + return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
136 } 147 }
137 /** 148 /**
138 * 生成缩略图缓存 149 * 生成缩略图缓存
@@ -154,6 +165,7 @@ class ImageController @@ -154,6 +165,7 @@ class ImageController
154 * @return type 165 * @return type
155 */ 166 */
156 private function multi($files) { 167 private function multi($files) {
  168 +
157 if (!is_array($files)) { 169 if (!is_array($files)) {
158 $files = [$files]; 170 $files = [$files];
159 } 171 }
@@ -168,21 +180,23 @@ class ImageController @@ -168,21 +180,23 @@ class ImageController
168 continue; 180 continue;
169 } 181 }
170 $url = $this->path; 182 $url = $this->path;
171 - $res = $file->move($url); 183 + $fileName = uniqid().rand(10000,99999).'.'.$file->getClientOriginalExtension();
  184 + $res = $file->move($url,$fileName);
172 if ($res === false) { 185 if ($res === false) {
173 return $this->response($file->getError(), Code::USER_ERROR); 186 return $this->response($file->getError(), Code::USER_ERROR);
174 } 187 }
175 $save_data[] = [ 188 $save_data[] = [
176 - 'path' => $url.'/'.$res->getClientOriginalName(), 189 + 'path' => $url.$fileName,
177 'created_at' => date('Y-m-d H:i:s',time()), 190 'created_at' => date('Y-m-d H:i:s',time()),
  191 + 'updated_at'=>date('Y-m-d H:i:s',time()),
178 'size' => $res->getSize(), 192 'size' => $res->getSize(),
179 'hash' => $hash, 193 'hash' => $hash,
180 - 'type'=>$files->getClientOriginalExtension(), 194 + 'type'=>$file->getClientOriginalExtension(),
181 ]; 195 ];
182 $data[] = $hash; 196 $data[] = $hash;
183 } 197 }
184 $imageModel->insert($save_data); 198 $imageModel->insert($save_data);
185 - return $data; 199 + return $this->response('图片资源',Code::SUCCESS,['image'=>$data]);
186 } 200 }
187 201
188 //下载 202 //下载
@@ -202,10 +216,50 @@ class ImageController @@ -202,10 +216,50 @@ class ImageController
202 $result = [ 216 $result = [
203 'msg' => $msg == ' ' ? $code->description : $msg, 217 'msg' => $msg == ' ' ? $code->description : $msg,
204 'code' => $code->value, 218 'code' => $code->value,
205 - 'data' => $data, 219 + 'data' => $this->_extents($data),
206 ]; 220 ];
207 $this->header['Content-Type'] = $type; 221 $this->header['Content-Type'] = $type;
208 $response = response($result,$result_code,$this->header); 222 $response = response($result,$result_code,$this->header);
209 throw new HttpResponseException($response); 223 throw new HttpResponseException($response);
210 } 224 }
  225 +
  226 + /**
  227 + * @param $data
  228 + * @name :返回参数处理
  229 + * @return array|string
  230 + * @author :liyuhang
  231 + * @method
  232 + */
  233 + protected function _extents($data) {
  234 +
  235 + if (empty($data) || !is_array($data)) {
  236 + return empty($data) ? is_array($data) ? [] : '' : $data;
  237 + }
  238 + foreach ($data as $k => $v) {
  239 + if (is_array($v)) {
  240 + $data[$k] = $this->_extents($v);
  241 + } else {
  242 + if (is_null($v)) {
  243 + $data[$k] = '';
  244 + continue;
  245 + }
  246 + //获取操作人
  247 + switch ((string) $k) {
  248 + case 'image':
  249 + $data['image_link'] = url('/b/image/' . $v);
  250 + break;
  251 + case 'images':
  252 + $v = explode(',',$v);
  253 + foreach ($v as $k1=>$v1){
  254 + $data['images_link'][$k1] = url('/b/image/' . $v1);
  255 + }
  256 + break;
  257 + case 'file':
  258 + $data['file_link'] = url('/b/file_hash/' . $v);
  259 + break;
  260 + }
  261 + }
  262 + }
  263 + return $data;
  264 + }
211 } 265 }
@@ -17,6 +17,19 @@ class AyrReleaseLogic extends BaseLogic @@ -17,6 +17,19 @@ class AyrReleaseLogic extends BaseLogic
17 } 17 }
18 18
19 /** 19 /**
  20 + * @name :()release_info
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/5/9 16:27
  24 + */
  25 + public function release_info(){
  26 + $info = $this->model->read($this->param);
  27 + if($info === false){
  28 + $this->fail('error');
  29 + }
  30 + return $this->success($info);
  31 + }
  32 + /**
20 * @name :(发布社交写入数据库)release_add 33 * @name :(发布社交写入数据库)release_add
21 * @author :lyh 34 * @author :lyh
22 * @method :post 35 * @method :post
@@ -36,30 +49,111 @@ class AyrReleaseLogic extends BaseLogic @@ -36,30 +49,111 @@ class AyrReleaseLogic extends BaseLogic
36 * @method :post 49 * @method :post
37 * @time :2023/5/9 10:02 50 * @time :2023/5/9 10:02
38 */ 51 */
39 - public function ayr_release_add(){ 52 + public function ayr_release_add($param){
40 $param = [ 53 $param = [
41 'post'=>$this->param['content'], 54 'post'=>$this->param['content'],
42 - 'platforms'=>$this->param['platforms'] 55 + 'platforms'=>$this->param['platforms'],
  56 + 'mediaUrls'=>$this->param['mediaUrls'],
43 ]; 57 ];
  58 + return $this->success($param);
44 } 59 }
45 60
46 /** 61 /**
  62 + * @name :(发布到推特)post_twitter
  63 + * @author :lyh
  64 + * @method :post
  65 + * @time :2023/5/9 13:42
  66 + */
  67 + public function post_twitter($param){
  68 + $param['post'] = '描述';
  69 + $param['platforms'] = ['twitter'];
  70 + $param['twitterOptions'] = [
  71 + 'thread'=> true,
  72 + 'threadNumber'=> true,
  73 + 'mediaUrls'=>[
  74 + //图片地址
  75 + ],
  76 + ];
  77 + return $this->success($param);
  78 + }
  79 + /**
47 * @name :(发布到youtube)post_facebook 80 * @name :(发布到youtube)post_facebook
48 * @author :lyh 81 * @author :lyh
49 * @method :post 82 * @method :post
50 * @time :2023/5/9 10:05 83 * @time :2023/5/9 10:05
51 */ 84 */
52 public function post_facebook(){ 85 public function post_facebook(){
53 - return $this->success(); 86 + $param['post'] = '视频描述';
  87 + $param['platforms'] = ['facebook'];
  88 + $param['faceBookOptions'] = [
  89 + 'reels'=> true,
  90 + 'title'=>'Super title for the Reel'
  91 + ];
  92 + return $this->success($param);
54 } 93 }
55 94
56 /** 95 /**
57 - * @name :(发布到youtube)post_youtube 96 + * @name :(发布到fbg,)post_youtube
58 * @author :lyh 97 * @author :lyh
59 * @method :post 98 * @method :post
60 * @time :2023/5/9 10:22 99 * @time :2023/5/9 10:22
  100 + * @TODO::只能发布一张图片和一张视频
  101 + */
  102 + public function post_gmb(){
  103 + $param['post'] = '描述';
  104 + $param['platforms'] = ['gmb'];
  105 + $param['mediaUrls'] = [];//图片链接
  106 + $param['gmbOptions'] = [
  107 + //视屏设置
  108 + 'isPhotoVideo' => true,
  109 + 'category'=> 'cate',//分类
  110 + ];
  111 + return $this->success($param);
  112 + }
  113 +
  114 + /**
  115 + * @name :(发布到instagram)post_google
  116 + * @author :lyh
  117 + * @method :post
  118 + * @time :2023/5/9 11:54
61 */ 119 */
62 - public function post_youtube(){ 120 + public function post_instagram(){
  121 + $param['post'] = '视频描述';
  122 + $param['platforms'] = ['instagram'];
  123 + $param['faceBookOptions'] = [
  124 + 'reels'=> true,
  125 + 'title'=>'Super title for the Reel'
  126 + ];
  127 + return $this->success();
  128 + }
  129 +
  130 + /**
  131 + * @name :(领英)post_linkedin
  132 + * @author :lyh
  133 + * @method :post
  134 + * @time :2023/5/9 11:56
  135 + */
  136 + public function post_linkedin(){
  137 + return $this->success();
  138 + }
  139 +
  140 + /**
  141 + * @name :(红迪网)post_reddit
  142 + * @author :lyh
  143 + * @method :post
  144 + * @time :2023/5/9 13:40
  145 + */
  146 + public function post_reddit(){
63 return $this->success(); 147 return $this->success();
64 } 148 }
  149 +
  150 + /**
  151 + * @name :(抖音)post_tiktok
  152 + * @author :lyh
  153 + * @method :post
  154 + * @time :2023/5/9 13:44
  155 + */
  156 + public function post_tiktok(){
  157 +
  158 + }
65 } 159 }
@@ -56,6 +56,19 @@ class AyrShareLogic extends BaseLogic @@ -56,6 +56,19 @@ class AyrShareLogic extends BaseLogic
56 } 56 }
57 57
58 /** 58 /**
  59 + * @name :(更新)ayr_share_edit
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2023/5/9 14:44
  63 + */
  64 + public function ayr_share_edit($param){
  65 + $rs = $this->model->edit($param,['id'=>$this->param['id']]);
  66 + if($rs === false){
  67 + $this->fail('error');
  68 + }
  69 + return $this->success();
  70 + }
  71 + /**
59 * @name :(删除ayr数据并同步删除) 72 * @name :(删除ayr数据并同步删除)
60 * @author :lyh 73 * @author :lyh
61 * @method :post 74 * @method :post
@@ -40,8 +40,14 @@ class WebSettingFromLogic extends BaseLogic @@ -40,8 +40,14 @@ class WebSettingFromLogic extends BaseLogic
40 try { 40 try {
41 //删除以前的数据 41 //删除以前的数据
42 $this->model->del(['project_id'=>$this->user['project_id']]); 42 $this->model->del(['project_id'=>$this->user['project_id']]);
  43 + foreach ($this->param['data'] as $k => $v){
  44 + $v['created_at'] = date('Y-m-d H:i:s');
  45 + $v['updated_at'] = date('Y-m-d H:i:s');
  46 + $v['project_id'] = $this->user['project_id'];
  47 + $this->param['data'][$k] = $v;
  48 + }
43 //新增 49 //新增
44 - $this->model->add_all($this->param['data']); 50 + $this->model->insert($this->param['data']);
45 }catch (\Exception $e){ 51 }catch (\Exception $e){
46 $this->fail('error'); 52 $this->fail('error');
47 } 53 }
@@ -37,9 +37,11 @@ class WebSettingReceivingLogic extends BaseLogic @@ -37,9 +37,11 @@ class WebSettingReceivingLogic extends BaseLogic
37 $this->model->del(['project_id'=>$this->user['project_id']]); 37 $this->model->del(['project_id'=>$this->user['project_id']]);
38 foreach ($this->param['data'] as $k => $v){ 38 foreach ($this->param['data'] as $k => $v){
39 $v['project_id'] = $this->user['project_id']; 39 $v['project_id'] = $this->user['project_id'];
  40 + $v['created_at'] = date('Y-m-d H:i:s');
  41 + $v['updated_at'] = date('Y-m-d H:i:s');
40 $this->param['data'][$k] = $v; 42 $this->param['data'][$k] = $v;
41 } 43 }
42 - $this->model->add_all($this->param['data']); 44 + $this->model->insert($this->param['data']);
43 }catch (\Exception $e){ 45 }catch (\Exception $e){
44 $this->fail('error'); 46 $this->fail('error');
45 } 47 }
@@ -36,17 +36,21 @@ class WebSettingServiceLogic extends BaseLogic @@ -36,17 +36,21 @@ class WebSettingServiceLogic extends BaseLogic
36 * @time :2023/5/4 11:10 36 * @time :2023/5/4 11:10
37 */ 37 */
38 public function setting_service_save(){ 38 public function setting_service_save(){
  39 + DB::beginTransaction();
39 try { 40 try {
40 $this->param['data'] = Common::uniqueMultiArray($this->param['data']); 41 $this->param['data'] = Common::uniqueMultiArray($this->param['data']);
41 //删除以前的数据 42 //删除以前的数据
42 $this->model->del(['project_id'=>$this->user['project_id']]); 43 $this->model->del(['project_id'=>$this->user['project_id']]);
43 foreach ($this->param['data'] as $k => $v){ 44 foreach ($this->param['data'] as $k => $v){
44 - //查询数据是否在数组中存在  
45 $v['project_id'] = $this->user['project_id']; 45 $v['project_id'] = $this->user['project_id'];
  46 + $v['created_at'] = date('Y-m-d H:i:s');
  47 + $v['updated_at'] = date('Y-m-d H:i:s');
46 $this->param['data'][$k] = $v; 48 $this->param['data'][$k] = $v;
47 } 49 }
48 - $this->model->add_all($this->param['data']); 50 + $this->model->insert($this->param['data']);
  51 + DB::commit();
49 }catch (\Exception $e){ 52 }catch (\Exception $e){
  53 + DB::rollBack();
50 $this->fail('error'); 54 $this->fail('error');
51 } 55 }
52 return $this->success(); 56 return $this->success();
@@ -51,8 +51,7 @@ class WebSettingTextLogic extends BaseLogic @@ -51,8 +51,7 @@ class WebSettingTextLogic extends BaseLogic
51 */ 51 */
52 public function setting_text_save(){ 52 public function setting_text_save(){
53 $web_setting = new WebSetting(); 53 $web_setting = new WebSetting();
54 - $setting_info = $this->setting_read();  
55 - if(count($this->param['data']) > $setting_info['anchor_num']){ 54 + if(count($this->param['data']) > $this->param['anchor_num']){
56 $this->fail('超过最大设置限制'); 55 $this->fail('超过最大设置限制');
57 } 56 }
58 DB::beginTransaction(); 57 DB::beginTransaction();
@@ -66,10 +65,12 @@ class WebSettingTextLogic extends BaseLogic @@ -66,10 +65,12 @@ class WebSettingTextLogic extends BaseLogic
66 $web_setting->edit($data,['project_id'=>$this->user['project_id']]); 65 $web_setting->edit($data,['project_id'=>$this->user['project_id']]);
67 $this->model->del(['project_id'=>$this->user['project_id']]); 66 $this->model->del(['project_id'=>$this->user['project_id']]);
68 foreach ($this->param['data'] as $k => $v){ 67 foreach ($this->param['data'] as $k => $v){
  68 + $v['created_at'] = date('Y-m-d H:i:s');
  69 + $v['updated_at'] = date('Y-m-d H:i:s');
69 $v['project_id'] = $this->user['project_id']; 70 $v['project_id'] = $this->user['project_id'];
70 $this->param['data'][$k] = $v; 71 $this->param['data'][$k] = $v;
71 } 72 }
72 - $this->model->add_all($this->param['data']); 73 + $this->model->insert($this->param['data']);
73 DB::commit(); 74 DB::commit();
74 }catch (\Exception $e){ 75 }catch (\Exception $e){
75 DB::rollBack(); 76 DB::rollBack();
@@ -29,7 +29,7 @@ class LoginAuthMiddleware @@ -29,7 +29,7 @@ class LoginAuthMiddleware
29 if(empty($info)){ 29 if(empty($info)){
30 return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']); 30 return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']);
31 } 31 }
32 - // 设置数据信息 32 +// // 设置数据信息
33 // $project = ProjectServer::useProject($info['project_id']); 33 // $project = ProjectServer::useProject($info['project_id']);
34 // if($project){ 34 // if($project){
35 // return response(['code'=>Code::USER_ERROR,'msg'=>'数据库未配置']); 35 // return response(['code'=>Code::USER_ERROR,'msg'=>'数据库未配置']);
@@ -15,5 +15,22 @@ class AyrShareRequest extends FormRequest @@ -15,5 +15,22 @@ class AyrShareRequest extends FormRequest
15 { 15 {
16 return true; 16 return true;
17 } 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 + 'name'=>'required||unique:gl_ayr_share,name',
  27 + ];
  28 + }
18 29
  30 + public function messages()
  31 + {
  32 + return [
  33 + 'name.required'=>'请填写名称',
  34 + ];
  35 + }
19 } 36 }
@@ -114,16 +114,6 @@ class Base extends Model @@ -114,16 +114,6 @@ class Base extends Model
114 } 114 }
115 115
116 /** 116 /**
117 - * @name :(获取数据条数)count  
118 - * @author :lyh  
119 - * @method :post  
120 - * @time :2023/5/8 15:51  
121 - */  
122 - public function get_count($condition){  
123 - $query = $this->formatQuery($condition);  
124 - $query->count();  
125 - }  
126 - /**  
127 * @name :新增 117 * @name :新增
128 * @return void 118 * @return void
129 * @author :liyuhang 119 * @author :liyuhang
@@ -136,20 +126,6 @@ class Base extends Model @@ -136,20 +126,6 @@ class Base extends Model
136 } 126 }
137 127
138 /** 128 /**
139 - * @name :(批量插入)add_all  
140 - * @author :lyh  
141 - * @method :post  
142 - * @time :2023/5/8 17:41  
143 - */  
144 - public function add_all($data){  
145 - foreach ($data as $k => $v){  
146 - $v['created_at'] = date('Y-m-d H:i:s');  
147 - $v['updated_at'] = date('Y-m-d H:i:s');  
148 - $data[$k] = $v;  
149 - }  
150 - return $this->insert($data);  
151 - }  
152 - /**  
153 * @name :编辑 129 * @name :编辑
154 * @return void 130 * @return void
155 * @author :liyuhang 131 * @author :liyuhang
@@ -68,7 +68,7 @@ return [ @@ -68,7 +68,7 @@ return [
68 'url' => env('DATABASE_URL'), 68 'url' => env('DATABASE_URL'),
69 'host' => env('DB_HOST', '127.0.0.1'), 69 'host' => env('DB_HOST', '127.0.0.1'),
70 'port' => env('DB_PORT', '3306'), 70 'port' => env('DB_PORT', '3306'),
71 - 'database' => env('DB_DATABASE_TMP', 'gl_data_tmp'), 71 + 'database' => env('DB_DATABASE_TMP', 'gl_data_0_tmp'),
72 'username' => env('DB_USERNAME', 'forge'), 72 'username' => env('DB_USERNAME', 'forge'),
73 'password' => env('DB_PASSWORD', ''), 73 'password' => env('DB_PASSWORD', ''),
74 'unix_socket' => env('DB_SOCKET', ''), 74 'unix_socket' => env('DB_SOCKET', ''),
@@ -14,12 +14,19 @@ return [ @@ -14,12 +14,19 @@ return [
14 ], 14 ],
15 'path' => '/product' 15 'path' => '/product'
16 ], 16 ],
17 - //用户头像  
18 - 'user' =>[ 17 + //默认
  18 + 'default_image' =>[
19 'size' => [ 19 'size' => [
20 'max' => 1024*1024*2, // 2M 20 'max' => 1024*1024*2, // 2M
21 ], 21 ],
22 - 'path' => '/user' 22 + 'path' => '/image'
  23 + ],
  24 + //默认视频
  25 + 'default_file' =>[
  26 + 'size' => [
  27 + 'max' => 1024*1024*200, // 2M
  28 + ],
  29 + 'path' => '/file'
23 ], 30 ],
24 //博客图 31 //博客图
25 'blog' =>[ 32 'blog' =>[
@@ -211,7 +211,8 @@ Route::middleware(['bloginauth'])->group(function () { @@ -211,7 +211,8 @@ Route::middleware(['bloginauth'])->group(function () {
211 211
212 //社交绑定 212 //社交绑定
213 Route::prefix('ayr')->group(function () { 213 Route::prefix('ayr')->group(function () {
214 - Route::any('/lists', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists'); 214 + Route::any('/', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'lists'])->name('ayr_lists');
  215 + Route::any('/save', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'save_account'])->name('ayr_save_account');
215 Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account'); 216 Route::any('/create', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'create_account'])->name('ayr_create_account');
216 Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account'); 217 Route::any('/del', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'del_account'])->name('ayr_del_account');
217 Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account'); 218 Route::any('/bind', [\App\Http\Controllers\Bside\AyrShare\AyrShareController::class, 'bind_account'])->name('ayr_bind_account');