feat(CC-055): add GET /decisions/:id + expand PATCH to update context/options/assumptions/reviewDueAt
This commit is contained in:
parent
2cf220133f
commit
ff68bb2ca5
1 changed files with 21 additions and 1 deletions
|
|
@ -15,9 +15,13 @@ class CreateDecisionDto {
|
|||
}
|
||||
|
||||
class UpdateDecisionDto {
|
||||
@IsOptional() @IsString() selectedOption?: string;
|
||||
@IsOptional() @IsString() context?: string;
|
||||
@IsOptional() @IsArray() options?: string[];
|
||||
@IsOptional() @IsArray() assumptions?: string[];
|
||||
@IsOptional() @IsString() selectedOption?: string | null;
|
||||
@IsOptional() @IsString() outcomeReview?: string;
|
||||
@IsOptional() @IsArray() evidence?: unknown[];
|
||||
@IsOptional() @IsString() reviewDueAt?: string | null;
|
||||
}
|
||||
|
||||
@Controller('decisions')
|
||||
|
|
@ -50,6 +54,16 @@ export class DecisionsController {
|
|||
});
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async getOne(
|
||||
@CurrentSession() session: AuthenticatedSession,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
return db.query.decisions.findFirst({
|
||||
where: and(eq(decisions.id, id), eq(decisions.tenantId, session.tenantId)),
|
||||
});
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@CurrentSession() session: AuthenticatedSession,
|
||||
|
|
@ -80,9 +94,15 @@ export class DecisionsController {
|
|||
const [updated] = await db
|
||||
.update(decisions)
|
||||
.set({
|
||||
...(dto.context !== undefined ? { context: dto.context } : {}),
|
||||
...(dto.options !== undefined ? { options: dto.options } : {}),
|
||||
...(dto.assumptions !== undefined ? { assumptions: dto.assumptions } : {}),
|
||||
...(dto.selectedOption !== undefined ? { selectedOption: dto.selectedOption } : {}),
|
||||
...(dto.outcomeReview !== undefined ? { outcomeReview: dto.outcomeReview } : {}),
|
||||
...(dto.evidence !== undefined ? { evidence: dto.evidence } : {}),
|
||||
...(dto.reviewDueAt !== undefined
|
||||
? { reviewDueAt: dto.reviewDueAt ? new Date(dto.reviewDueAt) : null }
|
||||
: {}),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(and(eq(decisions.id, id), eq(decisions.tenantId, session.tenantId)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue