Skip to content

Commit

Permalink
add org name
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkLee committed Feb 23, 2023
1 parent 942b942 commit c4b4c35
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 53 deletions.
9 changes: 9 additions & 0 deletions app/Application/OrgMng/OrgService/CreateOrgRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static function fromRequest(Request $request): static
$dto->tenantId = $request->integer('tenantId');
$dto->superiorId = $request->integer('superiorId');
$dto->orgTypeCode = $request->integer('orgTypeCode');
$dto->name = $request->str('name');
return $dto;
}

Expand All @@ -55,4 +56,12 @@ public function getOrgTypeCode(): string
{
return $this->orgTypeCode;
}

/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
}
3 changes: 3 additions & 0 deletions app/Application/OrgMng/OrgService/OrgResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ class OrgResponse
{
private int $id;
private int $tenantId;
private string $name;

public static function fromOrg(Org $org): static
{
$response = new static();
$response->id = $org->getId();
$response->tenantId = $org->getTenantId();
$response->name = $org->getName();
return $response;
}

Expand All @@ -22,6 +24,7 @@ public function toArray(): array
return [
'id' => $this->id,
'tenantId' => $this->tenantId,
'name'=>$this->name,
];
}
}
3 changes: 2 additions & 1 deletion app/Application/OrgMng/OrgService/OrgService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function buildOrg(CreateOrgRequest $request): Org
$orgDomainDTO = (new OrgDomainDTO())
->tenantId($request->getTenantId())
->superiorId($request->getSuperiorId())
->orgTypeCode($request->getOrgTypeCode());
->orgTypeCode($request->getOrgTypeCode())
->name($request->getName());

return $this->orgBuilder
->orgDomainDTO($orgDomainDTO)
Expand Down
120 changes: 69 additions & 51 deletions app/Domain/OrgMng/Org/DTO/OrgDomainDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,79 @@

class OrgDomainDTO
{
private int $tenantId;
private int $superiorId;
private string $orgTypeCode;
private int $tenantId;
private int $superiorId;
private string $orgTypeCode;
private string $name;

/**
* @return int
*/
public function getTenantId(): int
{
return $this->tenantId;
}
/**
* @return int
*/
public function getTenantId(): int
{
return $this->tenantId;
}

/**
* @return int
*/
public function getSuperiorId(): int
{
return $this->superiorId;
}
/**
* @return int
*/
public function getSuperiorId(): int
{
return $this->superiorId;
}

/**
* @return string
*/
public function getOrgTypeCode(): string
{
return $this->orgTypeCode;
}
/**
* @return string
*/
public function getOrgTypeCode(): string
{
return $this->orgTypeCode;
}

/**
* @param int $tenantId
* @return self
*/
public function tenantId(int $tenantId): self
{
$this->tenantId = $tenantId;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}

/**
* @param int $superiorId
* @return self
*/
public function superiorId(int $superiorId): self
{
$this->superiorId = $superiorId;
return $this;
}
/**
* @param int $tenantId
* @return self
*/
public function tenantId(int $tenantId): self
{
$this->tenantId = $tenantId;
return $this;
}

/**
* @param string $orgTypeCode
* @return self
*/
public function orgTypeCode(string $orgTypeCode): self
{
$this->orgTypeCode = $orgTypeCode;
return $this;
}
/**
* @param int $superiorId
* @return self
*/
public function superiorId(int $superiorId): self
{
$this->superiorId = $superiorId;
return $this;
}

/**
* @param string $orgTypeCode
* @return self
*/
public function orgTypeCode(string $orgTypeCode): self
{
$this->orgTypeCode = $orgTypeCode;
return $this;
}

/**
* @param string $name
*/
public function name(string $name): self
{
$this->name = $name;
return $this;
}
}
8 changes: 7 additions & 1 deletion app/Domain/OrgMng/Org/Org.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Org
private int $leaderId = 0;

#[Column(type: Types::STRING, length: 100)]
private $name = '';
private string $name = '';

#[Column(type: Types::INTEGER)]
private int $status = OrgStatus::EFFECTIVE;
Expand Down Expand Up @@ -59,6 +59,7 @@ public static function fromOrgDomainDTO(OrgDomainDTO $orgDomainDto): static
$org->tenantId = $orgDomainDto->getTenantId();
$org->superiorId = $orgDomainDto->getSuperiorId();
$org->orgTypeCode = $orgDomainDto->getOrgTypeCode();
$org->name = $orgDomainDto->getName();
return $org;
}

Expand All @@ -71,4 +72,9 @@ public function getTenantId(): int
{
return $this->tenantId;
}

public function getName(): string
{
return $this->name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ public function test_should_add_org()
{
$response = $this->post('/api/organizations', [
'tenantId' => 66,
'name' => 'foo',
]);
$response->assertStatus(200);
$response->assertJsonStructure(['id', 'tenantId']);
$response->assertJson([
'tenantId' => 66,
'name' => 'foo',
]);
}

public function test_should_update_org_basic_info()
Expand Down

0 comments on commit c4b4c35

Please sign in to comment.