-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move mapping in controller and uc, create dto.
- Loading branch information
1 parent
3891d5f
commit 4bfd818
Showing
8 changed files
with
289 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 23 additions & 8 deletions
31
apps/server/src/modules/account/controller/mapper/account-response.mapper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
import { Account } from '@src/modules/account/domain/account'; | ||
import { AccountResponse } from '../dto'; | ||
import { AccountResponse, AccountSearchListResponse } from '../dto'; | ||
import { ResolvedAccountDto, ResolvedSearchListAccountDto } from '../../uc/dto/resolved-account.dto'; | ||
|
||
export class AccountResponseMapper { | ||
static mapToResponse(account: Account): AccountResponse { | ||
static mapToAccountResponse(resolvedAccount: ResolvedAccountDto): AccountResponse { | ||
return new AccountResponse({ | ||
id: account.id ?? '', | ||
userId: account.userId, | ||
activated: account.activated, | ||
username: account.username, | ||
updatedAt: account.updatedAt, | ||
id: resolvedAccount.id as string, | ||
userId: resolvedAccount.userId, | ||
activated: resolvedAccount.activated, | ||
username: resolvedAccount.username ?? '', | ||
updatedAt: resolvedAccount.updatedAt, | ||
}); | ||
} | ||
|
||
static mapToAccountResponses(resolvedAccounts: ResolvedAccountDto[]): AccountResponse[] { | ||
return resolvedAccounts.map((resolvedAccount) => AccountResponseMapper.mapToAccountResponse(resolvedAccount)); | ||
} | ||
|
||
static mapToAccountSearchListResponse( | ||
resolvedSearchListAccountDto: ResolvedSearchListAccountDto | ||
): AccountSearchListResponse { | ||
return new AccountSearchListResponse( | ||
AccountResponseMapper.mapToAccountResponses(resolvedSearchListAccountDto.data), | ||
resolvedSearchListAccountDto.total, | ||
resolvedSearchListAccountDto.skip, | ||
resolvedSearchListAccountDto.limit | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.