apps/recallassess/recallassess-api/src/api/admin/contact-enquiry/contact-enquiry.controller.ts
api/admin/contact-enquiry
Methods |
|
| Async getDetail | ||||||
getDetail(id: number)
|
||||||
Decorators :
@Get(':id')
|
||||||
|
Override the default detail-fetch endpoint so that opening an enquiry in the admin UI auto-marks it as read (capturing the admin's user.id + a timestamp the first time anyone opens it). The order matters:
If the mark-read call fails internally it logs a warning but does NOT throw, so the detail view still loads cleanly even in edge cases (no authenticated user, transient DB blip, etc.).
Parameters :
|
import { BaseController } from "@bish-nest/core/controller/base.controller";
import { DetailResponseDataInterface } from "@bish-nest/core/interfaces/detail-response-data.interface";
import { Controller, Get, Param, ParseIntPipe } from "@nestjs/common";
import { ContactEnquiryService } from "./services/contact-enquiry.service";
@Controller("api/admin/contact-enquiry")
export class ContactEnquiryController extends BaseController<ContactEnquiryService> {
constructor(contactEnquiryService: ContactEnquiryService) {
super(contactEnquiryService);
}
/**
* Override the default detail-fetch endpoint so that opening an enquiry in
* the admin UI auto-marks it as read (capturing the admin's user.id + a
* timestamp the first time anyone opens it).
*
* The order matters:
* 1. Mark-read first (so the response payload reflects the new state).
* 2. Then fetch the detail and return it.
*
* If the mark-read call fails internally it logs a warning but does NOT
* throw, so the detail view still loads cleanly even in edge cases (no
* authenticated user, transient DB blip, etc.).
*/
@Get(":id")
override async getDetail(
@Param("id", ParseIntPipe) id: number,
): Promise<DetailResponseDataInterface<unknown>> {
await this.entityService.markReadOnFirstView(id);
return this.entityService.getDetail(id);
}
}