feat(studio): 支持了文件列表、晶格任务中视图截图的列表资源模型

Signed-off-by: 李东云 <dongyun.li@luxcreo.ai>
This commit is contained in:
李东云
2022-06-09 20:31:39 +08:00
parent 36bdc1f120
commit 80bb562251
3 changed files with 56 additions and 20 deletions

View File

@@ -61,9 +61,9 @@ final class File extends JsonResource
!empty($this->length) || !empty($this->width) || !empty($this->height),
[
'model' => [
'length' => $this->length,
'width' => $this->width,
'height' => $this->height,
'length' => $this->length ?? null,
'width' => $this->width ?? null,
'height' => $this->height ?? null,
],
]
),

View File

@@ -0,0 +1,26 @@
<?php
/**
* FileCollection.php@hyperf-development-kit
*
* @author 李东云<dongyun.li@luxcreo.cn>
* Powered by PhpStorm
* Created on 2022/5/6
*/
namespace Singularity\HDK\Studio\Resource;
use Hyperf\Resource\Json\ResourceCollection;
use Singularity\HDK\Utils\Resource\ClassicResponse;
/**
* 文件集合
* Singularity\HDK\Studio\Resource\FileCollection@hyperf-development-kit
*
* @author 李东云<dongyun.li@luxcreo.cn>
* Powered by PhpStorm
* Created on 2022/5/6
*/
class FileCollection extends ResourceCollection
{
use ClassicResponse;
}

View File

@@ -11,12 +11,14 @@ declare(strict_types=1);
namespace Singularity\HDK\Studio\Resource\Workspace\Tasks\Source;
use Hyperf\Contract\StdoutLoggerInterface;
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\FileCollection;
use Singularity\HDK\Studio\Resource\Lattice as LatticeResource;
use Singularity\HDK\Utils\Resource\ClassicResponse;
@@ -28,20 +30,21 @@ 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 int $fieldId
* @property Field $field
* @property LatticeResource $lattice
* @property File $source
* @property File $output
* @property File $outputSmall
* @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
* @property \Hyperf\Database\Model\Collection $showPicIds
*/
final class Lattice extends JsonResource
{
@@ -53,6 +56,12 @@ final class Lattice extends JsonResource
*/
private TranslatorInterface $translator;
/**
* @Inject
* @var \Hyperf\Contract\StdoutLoggerInterface
*/
private StdoutLoggerInterface $logger;
public function toArray(): array
{
$action = $this->action ?? null;
@@ -66,9 +75,10 @@ final class Lattice extends JsonResource
'size' => $this->size,
'wide' => $this->wide,
'surfaceNum' => $this->surfaceNum,
/*'viewShots' => [
'http://oss/1.jpg'
],*/
'viewShots' => $this->when(
isset($this->showPicIds),
isset($this->showPicIds) ? FileCollection::make($this->showPicIds) : null
),
'technology' => $this->when(isset($this->technology), $this->technology),
'material' => $this->when(isset($this->material), $this->material),
];