| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import { z } from '@hono/zod-openapi';
- import { UserSchemaMt } from '@d8d/user-module-mt';
- export const LoginSchema = z.object({
- username: z.string().min(3).openapi({
- example: 'admin',
- description: '用户名'
- }),
- password: z.string().min(6).openapi({
- example: 'admin123',
- description: '密码'
- })
- });
- export const RegisterSchema = z.object({
- username: z.string().min(3).openapi({
- example: 'john_doe',
- description: '用户名'
- }),
- password: z.string().min(6).openapi({
- example: 'password123',
- description: '密码'
- }),
- email: z.string().email().openapi({
- example: 'john@example.com',
- description: '邮箱'
- }).optional()
- });
- export const MiniLoginSchema = z.object({
- code: z.string().openapi({
- example: '08123456789012345678901234567890',
- description: '小程序登录code'
- }),
- userInfo: z.object({
- nickName: z.string().optional(),
- avatarUrl: z.string().optional()
- }).optional()
- });
- export const UserResponseSchema = UserSchemaMt.omit({ password: true });
- export const TokenResponseSchema = z.object({
- token: z.string().openapi({
- example: 'jwt.token.here',
- description: 'JWT Token'
- }),
- user: UserResponseSchema
- });
- export const MiniLoginResponseSchema = z.object({
- token: z.string().openapi({
- example: 'jwt.token.here',
- description: 'JWT Token'
- }),
- user: z.object({
- id: z.number(),
- username: z.string(),
- nickname: z.string().nullable(),
- phone: z.string().nullable(),
- email: z.string().nullable(),
- avatarFileId: z.number().nullable(),
- registrationSource: z.string()
- }),
- isNewUser: z.boolean().openapi({
- example: true,
- description: '是否为新注册用户'
- })
- });
- export const SuccessSchema = z.object({
- message: z.string().openapi({ example: '登出成功' })
- });
- export const PhoneDecryptSchema = z.object({
- encryptedData: z.string().openapi({
- example: 'encrypted_phone_data_here',
- description: '微信小程序加密的手机号数据'
- }),
- iv: z.string().openapi({
- example: 'encryption_iv_here',
- description: '加密算法的初始向量'
- })
- });
- export const PhoneDecryptResponseSchema = z.object({
- phoneNumber: z.string().openapi({
- example: '13800138000',
- description: '解密后的手机号'
- }),
- user: z.object({
- id: z.number(),
- username: z.string(),
- nickname: z.string().nullable(),
- phone: z.string().nullable(),
- email: z.string().nullable(),
- avatarFileId: z.number().nullable(),
- registrationSource: z.string()
- })
- });
|