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 {
|
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() @IsString() outcomeReview?: string;
|
||||||
@IsOptional() @IsArray() evidence?: unknown[];
|
@IsOptional() @IsArray() evidence?: unknown[];
|
||||||
|
@IsOptional() @IsString() reviewDueAt?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Controller('decisions')
|
@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()
|
@Post()
|
||||||
async create(
|
async create(
|
||||||
@CurrentSession() session: AuthenticatedSession,
|
@CurrentSession() session: AuthenticatedSession,
|
||||||
|
|
@ -80,9 +94,15 @@ export class DecisionsController {
|
||||||
const [updated] = await db
|
const [updated] = await db
|
||||||
.update(decisions)
|
.update(decisions)
|
||||||
.set({
|
.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.selectedOption !== undefined ? { selectedOption: dto.selectedOption } : {}),
|
||||||
...(dto.outcomeReview !== undefined ? { outcomeReview: dto.outcomeReview } : {}),
|
...(dto.outcomeReview !== undefined ? { outcomeReview: dto.outcomeReview } : {}),
|
||||||
...(dto.evidence !== undefined ? { evidence: dto.evidence } : {}),
|
...(dto.evidence !== undefined ? { evidence: dto.evidence } : {}),
|
||||||
|
...(dto.reviewDueAt !== undefined
|
||||||
|
? { reviewDueAt: dto.reviewDueAt ? new Date(dto.reviewDueAt) : null }
|
||||||
|
: {}),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
})
|
})
|
||||||
.where(and(eq(decisions.id, id), eq(decisions.tenantId, session.tenantId)))
|
.where(and(eq(decisions.id, id), eq(decisions.tenantId, session.tenantId)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue