51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
/**
|
||
* @file 用户模块Schema定义
|
||
* @author AI Assistant
|
||
* @date 2024-12-19
|
||
* @lastEditor AI Assistant
|
||
* @lastEditTime 2025-01-07
|
||
* @description 定义用户模块的Schema,包括获取当前用户信息、用户列表查询等
|
||
*/
|
||
|
||
import { t, type Static } from 'elysia';
|
||
import { createPaginationResponseSchema, createQuerySchema } from '@/utils/pagination';
|
||
|
||
/**
|
||
* 用户列表查询参数Schema
|
||
* @description 用户列表查询的请求参数验证规则
|
||
*/
|
||
export const UserListQuerySchema = createQuerySchema(
|
||
t.Object({
|
||
// 用户特有参数
|
||
keyword: t.Optional(
|
||
t.String({
|
||
minLength: 1,
|
||
maxLength: 100,
|
||
description: '搜索关键词,支持用户名、邮箱模糊搜索',
|
||
examples: ['admin', 'test@example.com'],
|
||
}),
|
||
),
|
||
status: t.Optional(
|
||
t.Union([t.Literal('active'), t.Literal('inactive'), t.Literal('pending')], {
|
||
description: '用户状态筛选',
|
||
examples: ['active', 'inactive', 'pending'],
|
||
}),
|
||
),
|
||
gender: t.Optional(
|
||
t.Union([t.Literal(0), t.Literal(1), t.Literal(2), t.Literal('0'), t.Literal('1'), t.Literal('2')], {
|
||
description: '性别筛选:0-未知,1-男,2-女',
|
||
examples: [0, 1, 2],
|
||
}),
|
||
),
|
||
isRoot: t.Optional(
|
||
t.Boolean({
|
||
description: '是否超级管理员筛选',
|
||
examples: [true, false],
|
||
}),
|
||
),
|
||
}),
|
||
);
|
||
|
||
/** 用户列表查询参数类型 */
|
||
export type UserListQueryRequest = Static<typeof UserListQuerySchema>;
|