This commit is contained in:
SepehrYahyaee
2026-05-24 13:34:43 +03:30
parent 866696094f
commit 2bdd0d507e
9 changed files with 566 additions and 234 deletions

View File

@@ -5,11 +5,13 @@ import {
HttpException,
InternalServerErrorException,
Param,
Post,
Put,
Query,
UseGuards,
} from "@nestjs/common";
import { ApiBearerAuth, ApiBody, ApiOperation, ApiParam, ApiTags } from "@nestjs/swagger";
import { ApiBearerAuth, ApiBody, ApiOperation, ApiParam, ApiResponse, ApiTags } from "@nestjs/swagger";
import { ExpertFileAssignResultDto } from "src/common/dto/expert-file-assign-result.dto";
import { LocalActorAuthGuard } from "src/auth/guards/actor-local.guard";
import { RolesGuard } from "src/auth/guards/role.guard";
import { Roles } from "src/decorators/roles.decorator";
@@ -79,7 +81,36 @@ export class ExpertBlameV2Controller {
}
}
@Post(":id/assign")
@ApiOperation({
summary: "Check availability and assign blame case to this expert",
description:
"Call before opening a case from the list. Returns `assigned` when the case was free and is now locked to you, `already_assigned_to_you` when you already hold the lock, or **409** with `status=locked` when another expert is reviewing. Does not replace PUT lock — use this for list UI availability.",
})
@ApiParam({ name: "id", description: "Blame case request id" })
@ApiResponse({ status: 200, type: ExpertFileAssignResultDto })
@ApiResponse({
status: 409,
description: "Another expert is processing this case",
type: ExpertFileAssignResultDto,
})
async assignForReview(@Param("id") id: string, @CurrentUser() actor: any) {
try {
return await this.expertBlameService.assignBlameCaseForReviewV2(id, actor);
} catch (error) {
if (error instanceof HttpException) throw error;
throw new InternalServerErrorException(
error instanceof Error ? error.message : "Failed to assign blame case",
);
}
}
@Put("lock/:id")
@ApiOperation({
summary: "Lock blame case for review (legacy)",
description:
"Same assignment logic as POST `:id/assign`, but returns the legacy `{ _id, lock }` shape and maps conflicts to 400 instead of 409.",
})
@ApiParam({ name: "id", description: "Blame case request id" })
async lockRequest(@Param("id") id: string, @CurrentUser() actor: any) {
try {