Skip to content

Commit

Permalink
简化API请求参数和响应结果的字段名称
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkLee committed Mar 1, 2023
1 parent cb90b83 commit a7d7cdf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions app/Application/OrgMng/OrgService/CreateOrgRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ private function __construct()
public static function fromRequest(Request $request): static
{
$dto = new static;
$dto->tenantId = $request->integer('tenantId');
$dto->superiorId = $request->integer('superiorId');
$dto->orgTypeCode = $request->str('orgTypeCode');
$dto->tenantId = $request->integer('tenant');
$dto->superiorId = $request->integer('superior');
$dto->orgTypeCode = $request->str('orgType');
$dto->name = $request->str('name');
return $dto;
}
Expand Down
4 changes: 2 additions & 2 deletions app/Application/OrgMng/OrgService/OrgResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public function toArray(): array
{
return [
'id' => $this->id,
'tenantId' => $this->tenantId,
'tenant' => $this->tenantId,
'name' => $this->name,
'orgTypeCode' => $this->orgTypeCode,
'orgType' => $this->orgTypeCode,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ public function test_should_add_org()

// When
$response = $this->post('/api/organizations', [
'tenantId' => $tenant->getId(),
'tenant' => $tenant->getId(),
'name' => '上海金融开发中心',
'orgTypeCode' => 'DEVCENT',
'orgType' => 'DEVCENT',
]);

// Then
$response->assertStatus(200);
$response->assertJsonStructure(['id', 'tenantId']);
$response->assertJsonStructure(['id']);
$response->assertJson([
'tenantId' => $tenant->getId(),
'tenant' => $tenant->getId(),
'name' => '上海金融开发中心',
'orgTypeCode' => 'DEVCENT',
'orgType' => 'DEVCENT',
]);
}

Expand Down

0 comments on commit a7d7cdf

Please sign in to comment.