refactor: 修改图片/视频上传记录表名
This commit is contained in:
@@ -3,8 +3,8 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\controller\v1;
|
||||
|
||||
use app\admin\model\v1\SysImageModel;
|
||||
use app\admin\model\v1\SysVideoModel;
|
||||
use app\admin\model\v1\SysImageUploadRecordModel;
|
||||
use app\admin\model\v1\SysVideoUploadRecordModel;
|
||||
use Intervention\Image\ImageManager;
|
||||
use think\facade\Filesystem;
|
||||
|
||||
@@ -39,7 +39,7 @@ class Upload
|
||||
$filemd5 = $file->md5();
|
||||
$filesha1 = $file->sha1();
|
||||
|
||||
$image_model = SysImageModel::md5($filemd5)->find();
|
||||
$image_model = SysImageUploadRecordModel::md5($filemd5)->find();
|
||||
if (is_null($image_model)) {
|
||||
$filename = Filesystem::disk('image')->putFile($param['module'], $file);
|
||||
// 生成缩略图
|
||||
@@ -51,7 +51,7 @@ class Upload
|
||||
$image->save('.' . $storage . '/' . $thumb_filename);
|
||||
|
||||
// 保存图片
|
||||
$image_model = new SysImageModel();
|
||||
$image_model = new SysImageUploadRecordModel();
|
||||
$image_model->language_id = request()->lang_id;
|
||||
$image_model->module = $param['module'];
|
||||
$image_model->image_path = $filename;
|
||||
@@ -68,8 +68,8 @@ class Upload
|
||||
return success('操作成功', [
|
||||
'path' => $storage . '/' . $image_model->image_path,
|
||||
'thumb_path' => $storage . '/' . $image_model->image_thumb,
|
||||
'filemd5' => $image_model->file_md5,
|
||||
'filesha1' => $image_model->file_sha1
|
||||
'filemd5' => $image_model->file_md5,
|
||||
'filesha1' => $image_model->file_sha1
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
return error($th->getMessage());
|
||||
@@ -106,26 +106,26 @@ class Upload
|
||||
$filemd5 = $file->md5();
|
||||
$filesha1 = $file->sha1();
|
||||
|
||||
$video = SysVideoModel::md5($filemd5)->find();
|
||||
$video = SysVideoUploadRecordModel::md5($filemd5)->find();
|
||||
if (is_null($video)) {
|
||||
$filename = Filesystem::disk('video')->putFile($param['module'], $file);
|
||||
|
||||
// 保存视频
|
||||
$video = new SysVideoModel();
|
||||
$video = new SysVideoUploadRecordModel();
|
||||
$video->language_id = request()->lang_id;
|
||||
$video->module = $param['module'];
|
||||
$video->video_path = $filename;
|
||||
$video->file_size = $file->getSize();
|
||||
$video->file_type = $file->getOriginalMime();
|
||||
$video->file_md5 = $filemd5;
|
||||
$video->file_sha1 = $filesha1;
|
||||
$video->file_size = $file->getSize();
|
||||
$video->file_type = $file->getOriginalMime();
|
||||
$video->file_md5 = $filemd5;
|
||||
$video->file_sha1 = $filesha1;
|
||||
if (!$video->save()) {
|
||||
return error('上传失败');
|
||||
}
|
||||
}
|
||||
|
||||
return success('上传成功', [
|
||||
'path' => $storage . '/' . $video->video_path,
|
||||
'path' => $storage . '/' . $video->video_path,
|
||||
'file_md5' => $video->file_md5,
|
||||
'file_sha1' => $video->file_sha1
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user