作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

... ... @@ -32,17 +32,17 @@ class AyrReleaseController extends BaseController
* @time :2023/5/9 9:36
*/
public function send_post(AyrReleaseLogic $ayrReleaseLogic,AyrShareLogic $ayrShareLogic){
DB::beginTransaction();
try {
// DB::beginTransaction();
// try {
//获取发送账号详情
$share_info = $ayrShareLogic->ayr_share_info();
$data = [
'image'=>explode(',',$this->param['image']),
'file'=>explode(',',$this->param['file'])
'images'=>$this->param['image'],
'files'=>$this->param['file'],
];
//参数处理
$image_file = $this->_extents($data);
$this->param['mediaUrls'] = $image_file;
$image_data = $this->image_file_param($data);
$this->param['mediaUrls'] = array_merge($image_data['images_link'],$image_data['files_link']);
//统一生成链接
$param = [
'post'=>$this->param['content'],
... ... @@ -55,11 +55,54 @@ class AyrReleaseController extends BaseController
$this->response('success',Code::SUCCESS,$res);
//保存数据库
$ayrReleaseLogic->release_add();
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->response('error',Code::USER_ERROR);
}
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->response('error',Code::USER_ERROR);
// }
}
/**
* @name :(上传第三方参数参数)get_param
* @author :lyh
* @method :post
* @time :2023/5/10 10:27
*/
public function image_file_param($data) {
if (empty($data) || !is_array($data)) {
return empty($data) ? is_array($data) ? [] : '' : $data;
}
foreach ($data as $k => $v) {
if (is_array($v)) {
$data[$k] = $this->_extents($v);
} else {
if (is_null($v)) {
$data[$k] = '';
continue;
}
//获取操作人
switch ((string) $k) {
case 'image':
$data['image_link'] = url('/b/image/' . $v . '/'.rand(100,999));
break;
case 'images':
$v = explode(',',$v);
foreach ($v as $k1=>$v1){
$data['images_link'][$k1] = url('/b/image/' . $v1 . '/'.rand(100,999));
}
break;
case 'file':
$data['file_link'] = url('/b/file_hash/' . $v .'/.mp4');
break;
case 'files':
$v = explode(',',$v);
foreach ($v as $k1=>$v1){
$data['files_link'][$k1] = url('/b/file_hash/' . $v1 . '/.mp4');
}
break;
}
}
}
return $data;
}
}
... ...
... ... @@ -151,8 +151,7 @@ class BaseController extends Controller
* @author :liyuhang
* @method
*/
public function _extents($data) {
protected function _extents($data) {
if (empty($data) || !is_array($data)) {
return empty($data) ? is_array($data) ? [] : '' : $data;
}
... ...
... ... @@ -25,7 +25,7 @@ class FileController
public $config = '';
public $thr_path = '';
public $uploads = '';
public $request = '';
... ... @@ -33,7 +33,8 @@ class FileController
{
$this->request = request();
$this->config = config('filesystems.disks.upload');
$this->path = $this->config['root'].'/file/';
$this->uploads = config('uploads.default_file');
$this->path = $this->config['root'].$this->uploads['path'].'/';
}
/**
... ... @@ -43,7 +44,7 @@ class FileController
* @method :post
* @time :2023/5/9 9:15
*/
public function index($hash = ''){
public function index($hash = '',$type = 1){
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
header("HTTP/1.1 304 Not Modified");
exit;
... ... @@ -59,6 +60,7 @@ class FileController
}
$content = file_get_contents($path);
$header['Content-Length'] = $info['size'];
$header['Content-Type'] = 'video/'.$info['type'];
return response($content, 200, $header);
}
/**
... ... @@ -66,9 +68,9 @@ class FileController
*/
public function upload() {
$this->request->validate([
'image'=>['required'],
'file'=>['required'],
],[
'image.required'=>'图片必须填写',
'file.required'=>'必须填写',
]);
$files = $this->request->file('file');
if (empty($files)) {
... ... @@ -112,7 +114,7 @@ class FileController
if ($rs === false) {
return $this->response('添加失败', Code::USER_ERROR);
}
return $hash;
return $this->response('资源',Code::SUCCESS,['file'=>$hash]);
}
/**
* 多文件上传
... ... @@ -149,7 +151,7 @@ class FileController
$data[] = $hash;
}
$fileModel->insert($save_data);
return $data;
return $this->response('资源',Code::SUCCESS,['files'=>$data]);
}
/**
* @name 统一返回参数
... ... @@ -163,10 +165,46 @@ class FileController
$result = [
'msg' => $msg == ' ' ? $code->description : $msg,
'code' => $code->value,
'data' => $data,
'data' => $this->_extents($data),
];
$this->header['Content-Type'] = $type;
$response = response($result,$result_code,$this->header);
throw new HttpResponseException($response);
}
/**
* @param $data
* @name :返回参数处理
* @return array|string
* @author :liyuhang
* @method
*/
protected function _extents($data) {
if (empty($data) || !is_array($data)) {
return empty($data) ? is_array($data) ? [] : '' : $data;
}
foreach ($data as $k => $v) {
if (is_array($v)) {
$data[$k] = $this->_extents($v);
} else {
if (is_null($v)) {
$data[$k] = '';
continue;
}
switch ((string) $k) {
case 'file':
$data['file_link'] = url('/b/file_hash/' . $v .'/'.rand(100,999));
break;
case 'files':
$v = explode(',',$v);
foreach ($v as $k1=>$v1){
$data['files_link'][$k1] = url('/b/file_hash/' . $v1 . '/'.rand(100,999));
}
break;
}
}
}
return $data;
}
}
... ...
... ... @@ -39,7 +39,8 @@ class ImageController
{
$this->request = request();
$this->config = config('filesystems.disks.upload');
$this->path = $this->config['root'];
$this->uploads = config('upload.default_image');
$this->path = $this->config['root'].$this->uploads['path'].'/';
}
public function index($hash = '',$type = self::TYPE, $w = 0 ,$h = 0 ){
... ...
... ... @@ -51,8 +51,7 @@ class WebSettingTextLogic extends BaseLogic
*/
public function setting_text_save(){
$web_setting = new WebSetting();
$setting_info = $this->setting_read();
if(count($this->param['data']) > $setting_info['anchor_num']){
if(count($this->param['data']) > $this->param['anchor_num']){
$this->fail('超过最大设置限制');
}
DB::beginTransaction();
... ...
... ... @@ -14,12 +14,19 @@ return [
],
'path' => '/product'
],
//用户头像
'user' =>[
//默认
'default_image' =>[
'size' => [
'max' => 1024*1024*2, // 2M
],
'path' => '/user'
'path' => '/image'
],
//默认视频
'default_file' =>[
'size' => [
'max' => 1024*1024*200, // 2M
],
'path' => '/file'
],
//博客图
'blog' =>[
... ...
... ... @@ -219,12 +219,10 @@ Route::middleware(['bloginauth'])->group(function () {
//社交绑定
Route::prefix('release')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'info'])->name('ayr_release_info');
Route::any('/send', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'send_post'])->name('ayr_release_send');
});
});
// 自定义页面
Route::prefix('template')->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('template_header_footer');
... ... @@ -253,5 +251,5 @@ Route::group([], function () {
// Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country');
Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
Route::any('/image/{hash}/{type?}/{w?}/{h?}', [\App\Http\Controllers\file\ImageController::class,'index'])->name('image_show');
Route::any('/file_hash/{hash}', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show');
Route::any('/file_hash/{hash}/{type?}/', [\App\Http\Controllers\file\FileController::class,'index'])->name('file_show');
});
... ...