-
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.
feat(sample): add isLocked property and lock/unlock use cases
- Loading branch information
Showing
15 changed files
with
152 additions
and
42 deletions.
There are no files selected for viewing
22 changes: 12 additions & 10 deletions
22
...s/database/change-data/attribute-value.ts → ...s/database/schema-change/new-attribute.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
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
29 changes: 29 additions & 0 deletions
29
apps/hcdc-access-service/src/app/sample/use-case/unlock.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,29 @@ | ||
import { AuthSubject, SampleAction } from '@diut/hcdc' | ||
import { Inject, Injectable } from '@nestjs/common' | ||
import { assertPermission } from 'src/app/auth/common' | ||
import { | ||
AUTH_CONTEXT_TOKEN, | ||
IAuthContext, | ||
ISampleRepository, | ||
SAMPLE_REPO_TOKEN, | ||
} from 'src/domain' | ||
import { SampleAssertExistsUseCase } from './assert-exists' | ||
|
||
@Injectable() | ||
export class SampleUnlockUseCase { | ||
constructor( | ||
@Inject(SAMPLE_REPO_TOKEN) | ||
private readonly sampleRepository: ISampleRepository, | ||
@Inject(AUTH_CONTEXT_TOKEN) | ||
private readonly authContext: IAuthContext, | ||
private readonly sampleAssertExistsUseCase: SampleAssertExistsUseCase, | ||
) {} | ||
|
||
async execute(input: Parameters<ISampleRepository['update']>[0]) { | ||
const entity = await this.sampleAssertExistsUseCase.execute(input[0]) | ||
const { ability } = this.authContext.getData() | ||
assertPermission(ability, AuthSubject.Sample, SampleAction.Lock, entity) | ||
|
||
await this.sampleRepository.update(input, { isLocked: false }) | ||
} | ||
} |
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
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
Oops, something went wrong.