2025-08-23 13:20:01 +08:00
|
|
|
import { Body, Controller, Get, Put, UseGuards } from '@nestjs/common';
|
|
|
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
|
|
|
import { SmsSettingsService } from './sms-settings.service';
|
|
|
|
|
import { UpdateSmsSettingsDto, type SmsSettingsVo } from './sms-settings.dto';
|
2025-08-24 02:31:42 +08:00
|
|
|
import { JwtAuthGuard } from '../../auth/guards/JwtAuthGuard';
|
|
|
|
|
import { Roles } from '../../auth/decorators/RolesDecorator';
|
|
|
|
|
import { RolesGuard } from '../../auth/guards/RolesGuard';
|
2025-08-23 13:20:01 +08:00
|
|
|
|
|
|
|
|
@ApiTags('Settings/Sms')
|
|
|
|
|
@ApiBearerAuth()
|
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
|
|
|
@Roles('super', 'admin')
|
|
|
|
|
@Controller('settings/sms')
|
|
|
|
|
export class SmsSettingsController {
|
|
|
|
|
constructor(private readonly service: SmsSettingsService) {}
|
|
|
|
|
|
|
|
|
|
@Get()
|
|
|
|
|
@ApiOperation({ summary: '获取短信设置' })
|
|
|
|
|
async get(): Promise<{ code: number; data: SmsSettingsVo }> {
|
|
|
|
|
const data = await this.service.getSettings();
|
|
|
|
|
return { code: 0, data };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Put()
|
|
|
|
|
@ApiOperation({ summary: '更新短信设置' })
|
|
|
|
|
async update(@Body() dto: UpdateSmsSettingsDto): Promise<{ code: number; data: SmsSettingsVo }> {
|
|
|
|
|
const data = await this.service.updateSettings(dto);
|
|
|
|
|
return { code: 0, data };
|
|
|
|
|
}
|
|
|
|
|
}
|