feat(studio): 添加了文件的资源模型

Signed-off-by: 李东云 <dongyun.li@luxcreo.ai>
This commit is contained in:
李东云
2022-05-19 15:26:25 +08:00
parent 6b5b41abf0
commit 03c07bcb0f

View File

@@ -0,0 +1,62 @@
<?php
/**
* File.php@HDK
*
* @author 李东云<dongyun.li@luxcreo.cn>
* Powered by PhpStorm
* Created on 2022/5/19
*/
declare(strict_types=1);
namespace Singularity\HDK\Studio\Resource;
use Hyperf\Resource\Json\JsonResource;
use Singularity\HDK\Utils\Resource\ClassicResponse;
/**
* Singularity\HDK\Studio\Resource\File@HDK
*
* @author 李东云<dongyun.li@luxcreo.cn>
* Powered by PhpStorm
* Created on 2022/5/19
*
* @property string $fileId
* @property string $userId 创建用户的 id不确定能不能获取到
* @property string $wsId 所属工作空间 ID
* @property string $taskId 所属任务 IDtype为source可为空
* @property string $type 模型类型。source 源文件output 产物
* @property string $name 文件名
* @property string $path 相对路径
* @property string $fullPath 完整url路径
* @property string $mimeType 资源类型例如jpeg图片的资源类型为image/jpeg
* @property int $size Object大小
* @property string $length 模型文件长
* @property string $width 模型文件宽
* @property string $height 模型文件高
* @property string $external 完整的回调响应信息
* @property \Carbon\Carbon $createdAt
*/
final class File extends JsonResource
{
use ClassicResponse;
public function toArray(): array
{
return [
'fileId' => $this->fileId,
'workspaceId' => $this->wsId ?? null,
'type' => $this->type,
'name' => $this->name,
'path' => $this->path,
'fullPath' => $this->fullPath,
'mimeType' => $this->mimeType,
'size' => $this->size,
'model' => [
'length' => $this->length,
'width' => $this->width,
'height' => $this->height,
],
];
}
}