import { Body, Controller, Post } from '@nestjs/common'
import { ApiTags } from '@nestjs/swagger'
import { SendCodeDto, VerifyCodeDto } from './dto/sms.dto'
import { SmsService } from './sms.service'
import { Public } from '../auth/public.decorator'

@ApiTags('sms')
@Controller('/sms')
export class SmsController {
    constructor(private readonly smsService: SmsService) {}

    @Public()
    @Post('/sendVerify')
    public async sendVerify(@Body() body: SendCodeDto) {
        return await this.smsService.sendVerify(body)
    }

    @Public()
    @Post('/verify')
    public async verify(@Body() body: VerifyCodeDto) {
        return {
            result: await this.smsService.verify(body.phone, body.code)
        }
    }
}
