修改商城逻辑

This commit is contained in:
2025-08-28 09:14:56 +08:00
parent a1944a573e
commit 691789d5d3
28 changed files with 10842 additions and 292 deletions

View File

@@ -5,6 +5,28 @@ const Dysmsapi20170525 = require('@alicloud/dysmsapi20170525')
const OpenApi = require('@alicloud/openapi-client')
const { Config } = require('@alicloud/openapi-client')
/**
* @swagger
* tags:
* name: SMS
* description: 短信验证码相关接口
*/
/**
* @swagger
* components:
* schemas:
* SMSVerification:
* type: object
* properties:
* phone:
* type: string
* description: 手机号码
* code:
* type: string
* description: 验证码
*/
// 阿里云短信配置
const config = new Config({
// 您的AccessKey ID
@@ -45,7 +67,41 @@ function generateSMSCode() {
}
/**
* 发送短信验证码
* @swagger
* /api/sms/send:
* post:
* summary: 发送短信验证码
* tags: [SMS]
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - phone
* properties:
* phone:
* type: string
* description: 手机号码
* responses:
* 200:
* description: 验证码发送成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* message:
* type: string
* example: 验证码发送成功
* 400:
* description: 参数错误或发送频率限制
* 500:
* description: 服务器错误
*/
router.post('/send', async (req, res) => {
try {
@@ -136,7 +192,52 @@ router.post('/send', async (req, res) => {
});
/**
* 验证短信验证码
* @swagger
* /api/sms/verify:
* post:
* summary: 验证短信验证码
* tags: [SMS]
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - phone
* - code
* properties:
* phone:
* type: string
* description: 手机号码
* code:
* type: string
* description: 验证码
* responses:
* 200:
* description: 验证码验证成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* message:
* type: string
* example: 手机号验证成功
* data:
* type: object
* properties:
* phone:
* type: string
* verified:
* type: boolean
* 400:
* description: 参数错误或验证码错误
* 500:
* description: 服务器错误
*/
router.post('/verify', async (req, res) => {
try {