init6
This commit is contained in:
129
shared/types/index.ts
Normal file
129
shared/types/index.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* 类型定义统一导出
|
||||
* Unified type definitions export
|
||||
*
|
||||
* 共享类型定义文件
|
||||
* 用于前后端类型一致性
|
||||
*/
|
||||
|
||||
// 基础类型
|
||||
export * from './base'
|
||||
|
||||
// 用户相关类型
|
||||
export * from './user'
|
||||
|
||||
// 飞书相关类型
|
||||
export * from './feishu'
|
||||
|
||||
// 上海CIM相关类型
|
||||
export * from './cim'
|
||||
|
||||
// 验证相关类型和工具
|
||||
export * from '../src/schemas/user'
|
||||
export * from '../utils/validation'
|
||||
|
||||
// ==================== API 响应类型 ====================
|
||||
|
||||
/**
|
||||
* API 响应类型
|
||||
* @template T 响应数据类型
|
||||
*/
|
||||
export interface ApiResponse<T = any> {
|
||||
success: boolean
|
||||
data?: T
|
||||
message?: string
|
||||
error?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页参数类型
|
||||
*/
|
||||
export interface PaginationParams {
|
||||
page?: number
|
||||
limit?: number
|
||||
search?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页响应类型
|
||||
* @template T 数据项类型
|
||||
*/
|
||||
export interface PaginatedResponse<T> {
|
||||
data: T[]
|
||||
total: number
|
||||
page: number
|
||||
limit: number
|
||||
totalPages: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单验证规则类型
|
||||
*/
|
||||
export interface FormRule {
|
||||
required?: boolean
|
||||
message?: string
|
||||
trigger?: string | string[]
|
||||
min?: number
|
||||
max?: number
|
||||
pattern?: RegExp
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格列配置类型
|
||||
*/
|
||||
export interface TableColumn {
|
||||
prop: string
|
||||
label: string
|
||||
width?: string | number
|
||||
sortable?: boolean
|
||||
formatter?: (row: any, column: any, cellValue: any) => string
|
||||
}
|
||||
|
||||
// ==================== 通用 CRUD 类型定义 ====================
|
||||
|
||||
/**
|
||||
* 通用查询参数接口
|
||||
*/
|
||||
export interface BaseQueryParams extends PaginationParams {
|
||||
orderBy?: string
|
||||
orderDirection?: 'asc' | 'desc'
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用创建输入类型
|
||||
*/
|
||||
export interface BaseCreateInput {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用更新输入类型
|
||||
*/
|
||||
export interface BaseUpdateInput {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/**
|
||||
* CRUD 操作选项
|
||||
*/
|
||||
export interface CrudOptions {
|
||||
// 是否启用软删除
|
||||
softDelete?: boolean
|
||||
// 默认排序字段
|
||||
defaultOrderBy?: string
|
||||
// 默认排序方向
|
||||
defaultOrderDirection?: 'asc' | 'desc'
|
||||
// 可搜索字段
|
||||
searchableFields?: string[]
|
||||
// 唯一字段验证
|
||||
uniqueFields?: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩展的API响应类型,包含验证错误
|
||||
* @template T 响应数据类型
|
||||
*/
|
||||
export interface ExtendedApiResponse<T = any> extends ApiResponse<T> {
|
||||
validationErrors?: ValidationError[]
|
||||
}
|
||||
Reference in New Issue
Block a user