fix(studio): 更新了 field 资源中的条件引入

Signed-off-by: 李东云 <dongyun.li@luxcreo.ai>
This commit is contained in:
李东云
2022-05-07 14:30:14 +08:00
parent c89a3dad1b
commit 7f29dc1242
3 changed files with 1683 additions and 1676 deletions

View File

@@ -24,7 +24,6 @@
"hyperf/database": "^2.2",
"hyperf/di": "^2.2",
"hyperf/framework": "^2.2",
"hyperf/guzzle": "^2.2",
"hyperf/http-server": "^2.2",
"hyperf/logger": "^2.2",
"hyperf/redis": "^2.2",
@@ -32,19 +31,22 @@
"hyperf/translation": "^2.2",
"lmc/http-constants": "^1.2",
"roave/dont": "^1.5",
"symfony/mailer": "^6.0",
"teapot/status-code": "^1.1"
},
"require-dev": {
"hyperf/guzzle": "^2.2",
"firebase/php-jwt": "^6.1",
"hyperf/session": "^2.2",
"hyperf/validation": "^2.2",
"symfony/mailer": "^6.0",
"phpunit/phpunit": "^9.5",
"roave/security-advisories": "dev-latest"
},
"suggest": {
"firebase/php-jwt": "JWT 鉴权必需",
"hyperf/session": "Session 鉴权必需"
"hyperf/session": "Session 鉴权必需",
"symfony/mailer": "用于发送电子邮件",
"hyperf/guzzle": "需要发起 http 请求时必需"
},
"config": {
"optimize-autoloader": true,

3291
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -20,14 +20,15 @@ use Singularity\HDK\Utils\Resource\ClassicResponse;
* Powered by PhpStorm
* Created on 2022/5/5
*
* @property int $id
* @property string $nameZh 领域中文名称
* @property string $nameEn 领域英文名称
* @property int $latticeSize 默认晶格尺寸,单位 mm
* @property int $latticeSizeMin 晶格范围最小值,单位 mm
* @property int $latticeSizeMax 晶格范围最大值,单位 mm
* @property string $rodDiameterMin 杆径范围最小值,单位 mm
* @property string $rodDiameterMax 杆径范围最大值,单位 mm
* @property int $id
* @property string $nameZh 领域中文名称
* @property string $nameEn 领域英文名称
* @property int $latticeSize 默认晶格尺寸,单位 mm
* @property int $latticeSizeMin 晶格范围最小值,单位 mm
* @property int $latticeSizeMax 晶格范围最大值,单位 mm
* @property string $rodDiameterMin 杆径范围最小值,单位 mm
* @property string $rodDiameterMax 杆径范围最大值,单位 mm
* @property array $latticeList 下属晶格列表
*/
class Field extends JsonResource
{
@@ -40,32 +41,31 @@ class Field extends JsonResource
*/
public function toArray(): array
{
$schema = [
return [
'id' => $this->id,
'nameZh' => $this->nameZh,
'nameEn' => $this->nameEn,
'latticeSize' => $this->latticeSize,
$this->mergeWhen(
!empty($this->latticeSizeMax) && !empty($this->latticeSizeMin),
[
'latticeSizeRange' => [
'min' => $this->latticeSizeMin,
'max' => $this->latticeSizeMax,
],
]
),
$this->mergeWhen(
!empty($this->rodDiameterMax) && !empty($this->rodDiameterMin),
[
'rodDiameterRange' => [
'min' => floatval($this->rodDiameterMin),
'max' => floatval($this->rodDiameterMax),
],
]
),
'latticeList' => new LatticeCollection($this->whenLoaded('latticeList')),
];
if (!empty($this->latticeSize)) {
$schema['latticeSize'] = $this->latticeSize;
}
if (!empty($this->latticeSizeMax) && !empty($this->latticeSizeMin)) {
$schema['latticeSizeRange'] = [
'min' => $this->latticeSizeMin,
'max' => $this->latticeSizeMax,
];
}
if (!empty($this->rodDiameterMax) && !empty($this->rodDiameterMin)) {
$schema['rodDiameterRange'] = [
'min' => floatval($this->rodDiameterMin),
'max' => floatval($this->rodDiameterMax),
];
}
if (!empty($this->latticeList)) {
$schema['latticeList'] = new LatticeCollection($this->latticeList);
}
return $schema;
}
}