- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation. - Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings. - Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors. - Fixed unmount lifecycle guards, promise error handling, and component edge cases.
114 lines
3.4 KiB
TypeScript
114 lines
3.4 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Put,
|
|
Delete,
|
|
Body,
|
|
Param,
|
|
UseGuards,
|
|
} from "@nestjs/common";
|
|
import { CmsService } from "./cms.service";
|
|
import {
|
|
CreateHeroBannerDto,
|
|
CreateVetTestimonialDto,
|
|
CreateSmartAdvisorRuleDto,
|
|
} from "./dto/cms.dto";
|
|
import { ApiTags, ApiOperation, ApiBearerAuth } from "@nestjs/swagger";
|
|
import { JwtAuthGuard } from "../auth/jwt-auth.guard";
|
|
import { RolesGuard } from "../auth/roles.guard";
|
|
import { Roles } from "../auth/roles.decorator";
|
|
|
|
@ApiTags("CMS - مدیریت بنرها، نظرات دامپزشکان و قوانین مشاوره")
|
|
@Controller("admin/cms")
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles("ADMIN")
|
|
@ApiBearerAuth()
|
|
export class CmsController {
|
|
constructor(private readonly cmsService: CmsService) {}
|
|
|
|
// Hero Banners Admin
|
|
@Get("hero-banners")
|
|
@ApiOperation({ summary: "لیست تمام بنرهای هیرو" })
|
|
getHeroBanners() {
|
|
return this.cmsService.getHeroBanners();
|
|
}
|
|
|
|
@Post("hero-banners")
|
|
@ApiOperation({ summary: "ایجاد بنر جدید هیرو" })
|
|
createHeroBanner(@Body() dto: CreateHeroBannerDto) {
|
|
return this.cmsService.createHeroBanner(dto);
|
|
}
|
|
|
|
@Put("hero-banners/:id")
|
|
@ApiOperation({ summary: "ویرایش بنر هیرو" })
|
|
updateHeroBanner(
|
|
@Param("id") id: string,
|
|
@Body() dto: Partial<CreateHeroBannerDto>,
|
|
) {
|
|
return this.cmsService.updateHeroBanner(id, dto);
|
|
}
|
|
|
|
@Delete("hero-banners/:id")
|
|
@ApiOperation({ summary: "حذف بنر هیرو" })
|
|
deleteHeroBanner(@Param("id") id: string) {
|
|
return this.cmsService.deleteHeroBanner(id);
|
|
}
|
|
|
|
// Vet Testimonials Admin
|
|
@Get("vet-testimonials")
|
|
@ApiOperation({ summary: "لیست تمام نظرات دامپزشکان" })
|
|
getVetTestimonials() {
|
|
return this.cmsService.getVetTestimonials();
|
|
}
|
|
|
|
@Post("vet-testimonials")
|
|
@ApiOperation({ summary: "ایجاد نظر دامپزشک جدید" })
|
|
createVetTestimonial(@Body() dto: CreateVetTestimonialDto) {
|
|
return this.cmsService.createVetTestimonial(dto);
|
|
}
|
|
|
|
@Put("vet-testimonials/:id")
|
|
@ApiOperation({ summary: "ویرایش نظر دامپزشک" })
|
|
updateVetTestimonial(
|
|
@Param("id") id: string,
|
|
@Body() dto: Partial<CreateVetTestimonialDto>,
|
|
) {
|
|
return this.cmsService.updateVetTestimonial(id, dto);
|
|
}
|
|
|
|
@Delete("vet-testimonials/:id")
|
|
@ApiOperation({ summary: "حذف نظر دامپزشک" })
|
|
deleteVetTestimonial(@Param("id") id: string) {
|
|
return this.cmsService.deleteVetTestimonial(id);
|
|
}
|
|
|
|
// Smart Advisor Rules Admin
|
|
@Get("smart-advisor-rules")
|
|
@ApiOperation({ summary: "لیست قوانین دستیار هوشمند سلامت" })
|
|
getSmartAdvisorRules() {
|
|
return this.cmsService.getSmartAdvisorRules();
|
|
}
|
|
|
|
@Post("smart-advisor-rules")
|
|
@ApiOperation({ summary: "ایجاد قانون مشاوره هوشمند جدید" })
|
|
createSmartAdvisorRule(@Body() dto: CreateSmartAdvisorRuleDto) {
|
|
return this.cmsService.createSmartAdvisorRule(dto);
|
|
}
|
|
|
|
@Put("smart-advisor-rules/:id")
|
|
@ApiOperation({ summary: "ویرایش قانون مشاوره هوشمند" })
|
|
updateSmartAdvisorRule(
|
|
@Param("id") id: string,
|
|
@Body() dto: Partial<CreateSmartAdvisorRuleDto>,
|
|
) {
|
|
return this.cmsService.updateSmartAdvisorRule(id, dto);
|
|
}
|
|
|
|
@Delete("smart-advisor-rules/:id")
|
|
@ApiOperation({ summary: "حذف قانون مشاوره هوشمند" })
|
|
deleteSmartAdvisorRule(@Param("id") id: string) {
|
|
return this.cmsService.deleteSmartAdvisorRule(id);
|
|
}
|
|
}
|