cursor-init/src/modules/auth/auth.schema.ts
expressgy 9a76d91307 feat: 实现用户注册接口 (任务1.0)
- 新增auth.schema.ts: 用户注册请求参数Schema定义和类型导出

- 新增auth.response.ts: 注册成功/失败响应格式定义

- 新增auth.service.ts: 注册业务逻辑,包含验证码验证、用户名邮箱唯一性检查、密码加密

- 新增auth.controller.ts: POST /api/auth/register路由实现,包含错误处理

- 新增auth.test.ts: 完整测试用例覆盖正常、异常、边界场景(14个测试全通过)

- 修复数据库日期时间插入问题和路由路径重复问题

关联PRD: M2-基础用户系统,任务1.0完成
2025-07-06 01:21:09 +08:00

51 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file 认证模块Schema定义
* @author AI Assistant
* @date 2024-12-19
* @description 定义认证模块的用户注册Schema
*/
import { t, type Static } from 'elysia';
/**
* 用户注册Schema
* @description 用户注册请求参数验证规则基于sys_users表结构
*/
export const RegisterSchema = t.Object({
/** 用户名2-50字符对应sys_users.username */
username: t.String({
minLength: 2,
maxLength: 50,
description: '用户名2-50字符',
examples: ['admin', 'testuser']
}),
/** 邮箱地址对应sys_users.email */
email: t.String({
format: 'email',
maxLength: 100,
description: '邮箱地址',
examples: ['user@example.com']
}),
/** 密码6-50字符 */
password: t.String({
minLength: 6,
maxLength: 50,
description: '密码6-50字符',
examples: ['password123']
}),
/** 图形验证码 */
captcha: t.String({
minLength: 4,
maxLength: 6,
description: '图形验证码',
examples: ['a1b2']
}),
/** 验证码会话ID */
captchaId: t.String({
description: '验证码会话ID',
examples: ['uuid-string-here']
})
});
/** 用户注册请求类型 */
export type RegisterRequest = Static<typeof RegisterSchema>;