style(verification): 添加类注释,完善代码规范

范围:src/core/utils/verification/
- 为VerificationService添加完整的类注释,包含职责、主要方法和使用场景说明
- 为VerificationModule添加完整的类注释,包含模块职责和功能说明
- 更新文件修改记录和版本号(1.0.1  1.0.2)
- 更新@lastModified时间戳为2026-01-12
This commit is contained in:
moyin
2026-01-12 19:21:30 +08:00
parent 7abd27aed0
commit ac989fe985
2 changed files with 47 additions and 4 deletions

View File

@@ -17,13 +17,14 @@
* - 手机短信验证码
*
* 最近修改:
* - 2026-01-12: 代码规范优化 - 添加VerificationService类注释完善职责和方法说明 (修改者: moyin)
* - 2026-01-07: 代码规范优化 - 清理未使用的导入(ConfigService)和多余空行
* - 2026-01-07: 代码规范优化 - 完善文件头注释和修改记录规范
*
* @author moyin
* @version 1.0.1
* @version 1.0.2
* @since 2025-12-17
* @lastModified 2026-01-07
* @lastModified 2026-01-12
*/
import { Injectable, Logger, BadRequestException, HttpException, HttpStatus, Inject } from '@nestjs/common';
@@ -52,6 +53,29 @@ export interface VerificationCodeInfo {
maxAttempts: number;
}
/**
* 验证码管理服务
*
* 职责:
* - 生成和管理各种类型的验证码(邮箱、密码重置、短信)
* - 提供验证码验证和尝试次数控制机制
* - 实现防刷机制和频率限制功能
* - 管理Redis缓存中的验证码存储和过期
*
* 主要方法:
* - generateCode() - 生成指定类型的验证码
* - verifyCode() - 验证用户输入的验证码
* - codeExists() - 检查验证码是否存在
* - deleteCode() - 删除指定验证码
* - getCodeTTL() - 获取验证码剩余时间
* - clearCooldown() - 清除发送冷却时间
*
* 使用场景:
* - 用户注册时的邮箱验证
* - 密码重置流程的安全验证
* - 短信验证码的生成和校验
* - 防止验证码恶意刷取和暴力破解
*/
@Injectable()
export class VerificationService {
private readonly logger = new Logger(VerificationService.name);