mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKit.git
synced 2026-01-15 00:35:08 +08:00
fix(studio): 更新工作区、晶格任务等资源模型
Signed-off-by: 李东云 <dongyun.li@luxcreo.ai>
This commit is contained in:
@@ -11,8 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Studio\Resource\Workspace\Tasks\Source;
|
||||
|
||||
use Hyperf\Contract\TranslatorInterface;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\Resource\Json\JsonResource;
|
||||
use Singularity\HDK\Studio\Enums\TaskLatticeAction;
|
||||
use Singularity\HDK\Studio\Resource\Field;
|
||||
use Singularity\HDK\Studio\Resource\File;
|
||||
use Singularity\HDK\Studio\Resource\Lattice as LatticeResource;
|
||||
use Singularity\HDK\Utils\Resource\ClassicResponse;
|
||||
|
||||
/**
|
||||
@@ -23,47 +28,49 @@ use Singularity\HDK\Utils\Resource\ClassicResponse;
|
||||
* Powered by PhpStorm
|
||||
* Created on 2022/5/13
|
||||
*
|
||||
* @property string $fileId 要处理的模型文件 ID
|
||||
* @property string $fileUrl 要处理的模型文件完整路径
|
||||
* @property TaskLatticeAction $action 模型精度
|
||||
* @property string $latticeId 晶格
|
||||
* @property float $scalingRatio 密度比,两位小数
|
||||
* @property float $size 晶格尺寸
|
||||
* @property float $wide 杆径粗细
|
||||
* @property int $surfaceNum 面数
|
||||
* @property string $fileId 要处理的模型文件 ID
|
||||
* @property string $fileUrl 要处理的模型文件完整路径
|
||||
* @property TaskLatticeAction $action 模型精度
|
||||
* @property string $latticeId 晶格
|
||||
* @property float $scalingRatio 密度比,两位小数
|
||||
* @property float $size 晶格尺寸
|
||||
* @property float $wide 杆径粗细
|
||||
* @property int $surfaceNum 面数
|
||||
* @property int $fieldId
|
||||
* @property Field $field
|
||||
* @property LatticeResource $lattice
|
||||
* @property File $source
|
||||
* @property File $output
|
||||
* @property File $outputSmall
|
||||
*/
|
||||
final class Lattice extends JsonResource
|
||||
{
|
||||
use ClassicResponse;
|
||||
|
||||
/**
|
||||
* @Inject()
|
||||
* @var \Hyperf\Contract\TranslatorInterface
|
||||
*/
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$action = $this->action ?? null;
|
||||
return [
|
||||
'fieldId' => $this->fieldId,
|
||||
'fileId' => $this->fileId,
|
||||
'fileUrl' => $this->fileUrl,
|
||||
'fieldZh' => $this->field?->nameZh,
|
||||
'fieldEn' => $this->field?->nameEn,
|
||||
'modelName' => $this->source?->name,
|
||||
'action' => is_null($action) ? null : $action,
|
||||
'lattice' => $this->latticeId,
|
||||
'lattice' => $this->when(!empty($this->lattice), $this->lattice?->title),
|
||||
'scalingRatio' => $this->scalingRatio,
|
||||
'size' => $this->size,
|
||||
'wide' => $this->wide,
|
||||
'surfaceNum' => $this->surfaceNum,
|
||||
$this->mergeWhen(
|
||||
isset($this->completeFileId),
|
||||
[
|
||||
'completeFileId' => $this->completeFileId,
|
||||
'completeFileUrl' => $this->completeFileUrl,
|
||||
]
|
||||
),
|
||||
$this->mergeWhen(
|
||||
isset($this->completeSmallFileId),
|
||||
[
|
||||
'completeSmallFileId' => $this->completeSmallFileId,
|
||||
'completeSmallFileUrl' => $this->completeSmallFileUrl,
|
||||
]
|
||||
),
|
||||
/*'viewShots' => [
|
||||
'http://oss/1.jpg'
|
||||
],*/
|
||||
'technology' => $this->when(isset($this->technology), $this->technology),
|
||||
'material' => $this->when(isset($this->material), $this->material),
|
||||
];
|
||||
}
|
||||
}
|
||||
60
src/Studio/Resource/Workspace/Tasks/Source/LatticeDetail.php
Normal file
60
src/Studio/Resource/Workspace/Tasks/Source/LatticeDetail.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Lattice.php@HDK
|
||||
*
|
||||
* @author 李东云<dongyun.li@luxcreo.cn>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2022/5/13
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Singularity\HDK\Studio\Resource\Workspace\Tasks\Source;
|
||||
|
||||
use Hyperf\Resource\Json\JsonResource;
|
||||
use Singularity\HDK\Studio\Enums\TaskLatticeAction;
|
||||
use Singularity\HDK\Studio\Resource\Field;
|
||||
use Singularity\HDK\Studio\Resource\File;
|
||||
use Singularity\HDK\Studio\Resource\Lattice as LatticeResource;
|
||||
use Singularity\HDK\Utils\Resource\ClassicResponse;
|
||||
|
||||
/**
|
||||
* 晶格模型生成任务的 source 格式
|
||||
* Singularity\HDK\Studio\Resource\Workspace\Tasks\Source\Lattice@HDK
|
||||
*
|
||||
* @author 李东云<dongyun.li@luxcreo.cn>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2022/5/13
|
||||
*
|
||||
* @property string $fileId 要处理的模型文件 ID
|
||||
* @property string $fileUrl 要处理的模型文件完整路径
|
||||
* @property TaskLatticeAction $action 模型精度
|
||||
* @property string $latticeId 晶格
|
||||
* @property float $scalingRatio 密度比,两位小数
|
||||
* @property float $size 晶格尺寸
|
||||
* @property float $wide 杆径粗细
|
||||
* @property int $surfaceNum 面数
|
||||
* @property int $fieldId
|
||||
* @property LatticeResource $lattice
|
||||
*/
|
||||
final class LatticeDetail extends JsonResource
|
||||
{
|
||||
use ClassicResponse;
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$action = $this->action ?? null;
|
||||
return [
|
||||
'field' => Field::make($this->field),
|
||||
'source' => File::make($this?->source),
|
||||
'action' => is_null($action) ? null : $action,
|
||||
'lattice' => LatticeResource::make($this->lattice),
|
||||
'scalingRatio' => $this->scalingRatio,
|
||||
'size' => $this->size,
|
||||
'wide' => $this->wide,
|
||||
'surfaceNum' => $this->surfaceNum,
|
||||
'output' => $this->when(isset($this->output), File::make($this?->output)),
|
||||
'outputPreview' => $this->when(isset($this->outputSmall), File::make($this?->outputSmall)),
|
||||
];
|
||||
}
|
||||
}
|
||||
50
src/Studio/Resource/Workspace/WorkspaceDetail.php
Normal file
50
src/Studio/Resource/Workspace/WorkspaceDetail.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Workspace.php@HDK
|
||||
*
|
||||
* @author 李东云<dongyun.li@luxcreo.cn>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2022/5/12
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Studio\Resource\Workspace;
|
||||
|
||||
use Hyperf\Resource\Json\JsonResource;
|
||||
use Singularity\HDK\Studio\Resource\Workspace\Tasks\Source\LatticeDetail;
|
||||
use Singularity\HDK\Utils\Resource\ClassicResponse;
|
||||
|
||||
/**
|
||||
* 工作区
|
||||
* Singularity\HDK\Studio\Resource\Workspace\Workspace@HDK
|
||||
*
|
||||
* @author 李东云<dongyun.li@luxcreo.cn>
|
||||
* Powered by PhpStorm
|
||||
* Created on 2022/5/12
|
||||
*
|
||||
* @property string $wsId
|
||||
* @property string $userId 创建用户
|
||||
* @property int $status 状态,标记是否完结,晶格填充后就不能再操作了
|
||||
* @property-read ?array $latticeTask
|
||||
* @property \Carbon\Carbon $createdAt
|
||||
*/
|
||||
class WorkspaceDetail extends JsonResource
|
||||
{
|
||||
use ClassicResponse;
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->wsId,
|
||||
'status' => $this->status,
|
||||
// 'tasks'=>$this->tasks,
|
||||
$this->mergeWhen(
|
||||
!empty($this->latticeTask),
|
||||
[
|
||||
'latticeTask' => empty($this->latticeTask) ? $this->latticeTask : LatticeDetail::make(
|
||||
$this->latticeTask
|
||||
)->toArray(),
|
||||
]
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user