/** * @file 样例接口Schema定义 * @author hotok * @date 2025-06-29 * @lastEditor hotok * @lastEditTime 2025-06-29 * @description 样例接口的请求参数和响应数据的TypeBox schema定义 */ import { t, type Static } from 'elysia'; /** * 根据用户名查询用户的请求参数Schema */ export const GetUserByUsernameSchema = t.Object({ /** 用户名,必填,长度2-50字符 */ username: t.String({ minLength: 2, maxLength: 50, description: '用户名,用于查询用户信息', examples: ['admin', 'testuser', 'zhangsan'], }), }); /** * 用户信息返回数据Schema */ export const UserInfoSchema = t.Object({ /** 用户ID */ id: t.Number({ description: '用户唯一标识ID', examples: [1, 2, 100], }), /** 用户名 */ username: t.String({ description: '用户名', examples: ['admin', 'testuser'], }), /** 邮箱 */ email: t.String({ description: '用户邮箱', examples: ['admin@example.com', 'user@test.com'], }), /** 用户昵称 */ nickname: t.Optional(t.String({ description: '用户昵称', examples: ['管理员', '测试用户'], })), /** 用户头像URL */ avatar: t.Optional(t.String({ description: '用户头像URL', examples: ['https://example.com/avatar.jpg'], })), /** 用户状态:0-禁用,1-启用 */ status: t.Number({ description: '用户状态,0-禁用,1-启用', examples: [0, 1], }), /** 创建时间 */ createdAt: t.String({ description: '用户创建时间', examples: ['2024-06-29T10:30:00.000Z'], }), /** 更新时间 */ updatedAt: t.String({ description: '用户最后更新时间', examples: ['2024-06-29T10:30:00.000Z'], }), }); /** * 根据用户名查询用户的请求参数类型 */ export type GetUserByUsernameType = Static; /** * 用户信息数据类型 */ export type UserInfoType = Static;