import { Controller, Get, Patch, Put, Delete, Body, Param, UseGuards, HttpStatus } from '@nestjs/common'; import { SettingsService } from './settings.service'; import { JwtAuthGuard } from '../auth/jwt-auth.guard'; import { ApiTags, ApiOperation, ApiBearerAuth, ApiResponse, ApiOkResponse, ApiUnauthorizedResponse } from '@nestjs/swagger'; @ApiTags('Settings - تنظیمات متون پویا و واژه‌نامه علمی') @Controller('settings') export class SettingsController { constructor(private readonly settingsService: SettingsService) {} @Get('ui-texts') @ApiOperation({ summary: 'دریافت تمامی متون و پیکربندی‌های رابط کاربری' }) @ApiOkResponse({ description: 'یک آبجکت کلید-مقدار حاوی تمامی متون، شعارها و برچسب‌های دکمه‌ها', schema: { example: { hero_badge: "تخصص دارویی از آلمان", hero_title: "تخصص آلمانی در خدمت سلامت پت‌های خانگی", hero_desc: "بیش از ۴۰ سال تجربه نوآورانه..." } } }) getUiTexts() { return this.settingsService.getUiTexts(); } @UseGuards(JwtAuthGuard) @ApiBearerAuth() @Patch('ui-texts/:key') @ApiOperation({ summary: 'ویرایش متن یک کلید در رابط کاربری (نیازمند توکن)' }) @ApiOkResponse({ description: 'متن با موفقیت به‌روزرسانی شد', schema: { example: { key: 'hero_badge', value: 'تخصص دارویی ممتاز از آلمان' } } }) @ApiUnauthorizedResponse({ description: 'عدم دسترسی به دلیل عدم احراز هویت', schema: { example: { success: false, message: 'Unauthorized', code: 'UNAUTHORIZED' } } }) updateUiText(@Param('key') key: string, @Body('value') value: string) { return this.settingsService.updateUiText(key, value); } @Get('scientific-terms') @ApiOperation({ summary: 'دریافت تمامی اصطلاحات واژه‌نامه علمی' }) @ApiOkResponse({ description: 'لیست کامل اصطلاحات علمی به همراه تعاریف و شناسه‌ها', schema: { example: [ { key: 'green-mussel', term: 'صدف لب‌سبز (Perna Canaliculus)', definition: 'این صدف بومی سواحل بکر نیوزیلند است...', wikiId: 'general' } ] } }) getScientificTerms() { return this.settingsService.getScientificTerms(); } @UseGuards(JwtAuthGuard) @ApiBearerAuth() @Put('scientific-terms/:key') @ApiOperation({ summary: 'ثبت یا ویرایش یک اصطلاح علمی (نیازمند توکن)' }) @ApiOkResponse({ description: 'اصطلاح علمی ثبت یا ویرایش شد', schema: { example: { key: 'green-mussel', term: 'صدف لب‌سبز اصل نیوزیلند', definition: 'این صدف بومی سواحل بکر نیوزیلند است...', wikiId: 'general' } } }) @ApiUnauthorizedResponse({ description: 'عدم دسترسی', schema: { example: { success: false, message: 'Unauthorized', code: 'UNAUTHORIZED' } } }) upsertScientificTerm(@Param('key') key: string, @Body() data: any) { return this.settingsService.upsertScientificTerm(key, data); } @UseGuards(JwtAuthGuard) @ApiBearerAuth() @Delete('scientific-terms/:key') @ApiOperation({ summary: 'حذف یک اصطلاح علمی (نیازمند توکن)' }) @ApiOkResponse({ description: 'اصطلاح علمی حذف شد', schema: { example: { success: true, message: 'Scientific term successfully deleted' } } }) @ApiUnauthorizedResponse({ description: 'عدم دسترسی', schema: { example: { success: false, message: 'Unauthorized', code: 'UNAUTHORIZED' } } }) deleteScientificTerm(@Param('key') key: string) { return this.settingsService.deleteScientificTerm(key); } }