feat : oss

This commit is contained in:
2024-11-12 11:14:48 +08:00
parent a9f81888b7
commit 86b94d168c
7 changed files with 74 additions and 12 deletions

View File

@@ -12,6 +12,7 @@ namespace App\Service\Common;
use App\Cache\Redis\Common\CommonRedisKey;
use App\Cache\Redis\RedisCache;
use App\Constants\Common\OssObjectCode;
use App\Exception\ErrException;
use App\Lib\AdminReturn;
use App\Lib\Log;
@@ -265,14 +266,14 @@ class OssCallbackService
case 'jpeg':
case 'png':
case 'bmp':
$type = 1;
$type = OssObjectCode::TYPE_IMAGE;
break;
case 'mp3':
$type = 2;
$type = OssObjectCode::TYPE_AUDIO;
break;
case 'mp4':
case 'swf':
$type = 3;
$type = OssObjectCode::TYPE_VIDEO;
break;
}
@@ -285,7 +286,7 @@ class OssCallbackService
$ossObjectModel->audio_second = $this->data['audio_second'] ?? 0;
$ossObjectModel->video_duration = $this->data['video_duration'] ?? 0;
$ossObjectModel->size = $this->data['size'] ?? 0;
$ossObjectModel->is_enabled = OssObjectCode::DISABLE;
$ossObjectModel->type = $type;
if (!$ossObjectModel->save()){

View File

@@ -43,4 +43,46 @@ trait OssTrait
}
}
/**
* 更改资源属性 -> Enable
* @param array $ossIds
* @return void
*/
public function updateOssObjects(array $ossIds): void
{
$this->checkOssObjects($ossIds);
$this->ossObjectModel->updateEnabledByIds($ossIds);
}
/**
* 更改资源属性 -> Disable
* @param array $ossIds
* @return void
*/
public function updateOssObjectsDisable(array $ossIds): void
{
$this->ossObjectModel->updateDisableByIds($ossIds);
}
/**
* 获取所有数据
* @param array $ossIds
* @return array
*/
public function getOssObjects(array $ossIds): array
{
$data = $this->ossObjectModel->getInfoByOssIds($ossIds);
if (empty($data)){
return [];
}
$res = [];
foreach ($data->toArray() as $one)
{
$res[$one['id']] = $one;
}
return $res;
}
}