作者 lyh

gx

@@ -32,17 +32,17 @@ class AyrReleaseController extends BaseController @@ -32,17 +32,17 @@ class AyrReleaseController extends BaseController
32 * @time :2023/5/9 9:36 32 * @time :2023/5/9 9:36
33 */ 33 */
34 public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic){ 34 public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic){
35 - DB::beginTransaction();  
36 - try { 35 +// DB::beginTransaction();
  36 +// try {
37 //获取发送账号详情 37 //获取发送账号详情
38 $share_info = $ayrShareLogic->ayr_share_info(); 38 $share_info = $ayrShareLogic->ayr_share_info();
39 $data = [ 39 $data = [
40 - 'image'=>explode(',',$this->param['image']),  
41 - 'file'=>explode(',',$this->param['file']) 40 + 'images'=>$this->param['image'],
  41 + 'files'=>$this->param['file'],
42 ]; 42 ];
43 //参数处理 43 //参数处理
44 - $image_file = $this->_extents($data);  
45 - $this->param['mediaUrls'] = $image_file; 44 + $image_data = $this->image_file_param($data);
  45 + $this->param['mediaUrls'] = array_merge($image_data['images_link'],$image_data['files_link']);
46 //统一生成链接 46 //统一生成链接
47 $param = [ 47 $param = [
48 'post'=>$this->param['content'], 48 'post'=>$this->param['content'],
@@ -55,11 +55,54 @@ class AyrReleaseController extends BaseController @@ -55,11 +55,54 @@ class AyrReleaseController extends BaseController
55 $this->response('success',Code::SUCCESS,$res); 55 $this->response('success',Code::SUCCESS,$res);
56 //保存数据库 56 //保存数据库
57 $ayrReleaseLogic->release_add(); 57 $ayrReleaseLogic->release_add();
58 - DB::commit();  
59 - }catch (\Exception $e){  
60 - DB::rollBack();  
61 - $this->response('error',Code::USER_ERROR);  
62 - } 58 +// DB::commit();
  59 +// }catch (\Exception $e){
  60 +// DB::rollBack();
  61 +// $this->response('error',Code::USER_ERROR);
  62 +// }
63 } 63 }
64 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 . '/'.rand(100,999));
  87 + break;
  88 + case 'images':
  89 + $v = explode(',',$v);
  90 + foreach ($v as $k1=>$v1){
  91 + $data['images_link'][$k1] = url('/b/image/' . $v1 . '/'.rand(100,999));
  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 + }
65 } 108 }
@@ -151,8 +151,7 @@ class BaseController extends Controller @@ -151,8 +151,7 @@ class BaseController extends Controller
151 * @author :liyuhang 151 * @author :liyuhang
152 * @method 152 * @method
153 */ 153 */
154 - public function _extents($data) {  
155 - 154 + protected function _extents($data) {
156 if (empty($data) || !is_array($data)) { 155 if (empty($data) || !is_array($data)) {
157 return empty($data) ? is_array($data) ? [] : '' : $data; 156 return empty($data) ? is_array($data) ? [] : '' : $data;
158 } 157 }
@@ -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)) {
@@ -112,7 +114,7 @@ class FileController @@ -112,7 +114,7 @@ class FileController
112 if ($rs === false) { 114 if ($rs === false) {
113 return $this->response('添加失败', Code::USER_ERROR); 115 return $this->response('添加失败', Code::USER_ERROR);
114 } 116 }
115 - return $hash; 117 + return $this->response('资源',Code::SUCCESS,['file'=>$hash]);
116 } 118 }
117 /** 119 /**
118 * 多文件上传 120 * 多文件上传
@@ -149,7 +151,7 @@ class FileController @@ -149,7 +151,7 @@ class FileController
149 $data[] = $hash; 151 $data[] = $hash;
150 } 152 }
151 $fileModel->insert($save_data); 153 $fileModel->insert($save_data);
152 - return $data; 154 + return $this->response('资源',Code::SUCCESS,['files'=>$data]);
153 } 155 }
154 /** 156 /**
155 * @name 统一返回参数 157 * @name 统一返回参数
@@ -163,10 +165,46 @@ class FileController @@ -163,10 +165,46 @@ class FileController
163 $result = [ 165 $result = [
164 'msg' => $msg == ' ' ? $code->description : $msg, 166 'msg' => $msg == ' ' ? $code->description : $msg,
165 'code' => $code->value, 167 'code' => $code->value,
166 - 'data' => $data, 168 + 'data' => $this->_extents($data),
167 ]; 169 ];
168 $this->header['Content-Type'] = $type; 170 $this->header['Content-Type'] = $type;
169 $response = response($result,$result_code,$this->header); 171 $response = response($result,$result_code,$this->header);
170 throw new HttpResponseException($response); 172 throw new HttpResponseException($response);
171 } 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 + }
172 } 210 }
@@ -39,7 +39,8 @@ class ImageController @@ -39,7 +39,8 @@ class ImageController
39 { 39 {
40 $this->request = request(); 40 $this->request = request();
41 $this->config = config('filesystems.disks.upload'); 41 $this->config = config('filesystems.disks.upload');
42 - $this->path = $this->config['root']; 42 + $this->uploads = config('uploads.default_image');
  43 + $this->path = $this->config['root'].$this->uploads['path'].'/';
43 } 44 }
44 45
45 public function index($hash = '',$type = self::TYPE, $w = 0 ,$h = 0 ){ 46 public function index($hash = '',$type = self::TYPE, $w = 0 ,$h = 0 ){
@@ -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();
@@ -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' =>[
@@ -219,12 +219,10 @@ Route::middleware(['bloginauth'])->group(function () { @@ -219,12 +219,10 @@ Route::middleware(['bloginauth'])->group(function () {
219 //社交绑定 219 //社交绑定
220 Route::prefix('release')->group(function () { 220 Route::prefix('release')->group(function () {
221 Route::any('/', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'info'])->name('ayr_release_info'); 221 Route::any('/', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'info'])->name('ayr_release_info');
  222 + Route::any('/send', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'send_post'])->name('ayr_release_send');
222 }); 223 });
223 }); 224 });
224 225
225 -  
226 -  
227 -  
228 // 自定义页面 226 // 自定义页面
229 Route::prefix('template')->group(function () { 227 Route::prefix('template')->group(function () {
230 Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('template_header_footer'); 228 Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('template_header_footer');
@@ -253,5 +251,5 @@ Route::group([], function () { @@ -253,5 +251,5 @@ Route::group([], function () {
253 // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); 251 // Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country');
254 Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); 252 Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
255 Route::any('/image/{hash}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show'); 253 Route::any('/image/{hash}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
256 - Route::any('/file_hash/{hash}', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show'); 254 + Route::any('/file_hash/{hash}/{type?}/', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show');
257 }); 255 });