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"sms.controller.js","sourcesContent":["import { Body, Controller, Inject, Post } from \"@nestjs/common\";\n\nimport { SmsRequest } from \"../interfaces/sms-request.interface\";\nimport { SmsService } from \"../services/sms.service\";\n\n@Controller(\"sms\")\nexport class SmsController {\n constructor(@Inject(SmsService) private readonly smsService: SmsService) { }\n\n /**\n * 发送短信接口\n * @param body example: {\"type\": 0, smsRequest: { \"appId\": \"1234567890\", \"templateId\": 123456, \"mobile\": [\"13512345678\"] } }\n */\n @Post(\"sendMessage\")\n async sendMessage(@Body() body: { type: number, smsRequest: SmsRequest }): Promise<{ code: number, message: string }> {\n if (body.type === 0 || body.type === 1) {\n return this.smsService.sendMessageByQCloud(body.type, body.smsRequest);\n }\n return { code: 406, message: \"type参数有误,0为通知类短信(模板无参数),1为验证码类短信(模板有参数)\" };\n }\n\n /**\n * 校验验证码合法性\n *\n * @param body 发送短信的模板ID和验证码\n */\n @Post(\"smsValidator\")\n async smsValidator(@Body() body: { mobile: string, validationCode: number }): Promise<{ code: number, message: string }> {\n const isSuccess = await this.smsService.validator(body.mobile, body.validationCode);\n const code = isSuccess ? 200 : 406;\n const message = isSuccess ? \"验证通过\" : \"验证不通过\";\n return { code, message };\n }\n}\n"]}
\No newline at end of file