forked from AdrianCassar/Xenia-WebServices
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Properties type 1 (dword)
- Loading branch information
Showing
10 changed files
with
117 additions
and
1 deletion.
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
33 changes: 33 additions & 0 deletions
33
src/application/commandHandlers/AddSessionPropertyCommandHandler.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Inject } from '@nestjs/common'; | ||
import { ICommandHandler, CommandHandler } from '@nestjs/cqrs'; | ||
import ISessionRepository, { | ||
ISessionRepositorySymbol, | ||
} from 'src/domain/repositories/ISessionRepository'; | ||
import { AddSessionPropertyCommand } from '../commands/AddSessionPropertyCommand'; | ||
import { property } from 'tiny-types'; | ||
|
||
@CommandHandler(AddSessionPropertyCommand) | ||
export class AddSessionPropertyCommandHandler | ||
implements ICommandHandler<AddSessionPropertyCommand> | ||
{ | ||
constructor( | ||
@Inject(ISessionRepositorySymbol) | ||
private repository: ISessionRepository, | ||
) {} | ||
|
||
async execute(command: AddSessionPropertyCommand) { | ||
const session = await this.repository.findSession( | ||
command.titleId, | ||
command.sessionId, | ||
); | ||
|
||
if (!session) { | ||
return undefined; | ||
} | ||
|
||
session.addProperty({ property: command.properties }); | ||
await this.repository.save(session); | ||
|
||
return session; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import SessionId from 'src/domain/value-objects/SessionId'; | ||
import TitleId from 'src/domain/value-objects/TitleId'; | ||
|
||
export class AddSessionPropertyCommand { | ||
constructor( | ||
public readonly titleId: TitleId, | ||
public readonly sessionId: SessionId, | ||
public readonly properties: Map<number, { propertyId: number; value: number }>, | ||
) {} | ||
} |
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
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
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
6 changes: 6 additions & 0 deletions
6
src/infrastructure/presentation/requests/GetSessionPropertyRequest.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class GetSessionPropertyRequest { | ||
@ApiProperty() | ||
properties: Map<number, { propertyId: number; value: number }>; | ||
} |
3 changes: 3 additions & 0 deletions
3
src/infrastructure/presentation/responses/SessionPropertyResponse.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface SessionPropertyResponse { | ||
properties: Map<number, number>; | ||
} |