type QueryPage = { "#page": { current?: number; size?: number; }; "#rule"?: R[]; "#order"?: QueryOrder[]; "#group"?: QueryGroup[]; } & { [k in keyof T]?: T[k]; }; type Key = (keyof T) & string; type QueryOrder = [Key, "ASC" | "DESC"]; type QueryGroup = (Key); type Alias = { [alias: string]: keyof T; }; /** 查询规则 */ interface _RuleBase { /** 连接关系 */ or?: any; /** 字段(被比较值) */ field: Key; } interface _RuleBaseNS extends _RuleBase { /** 比较关系 */ logic: "=" | "eq" | "<>" | "ne" | "<=>"; /** 比较值 */ value: ns; } interface _RuleBaseN extends _RuleBase { /** 比较关系 */ logic: ">" | "gt" | ">=" | "ge" | "<" | "lt" | "<=" | "le"; /** 比较值 */ value: number; } interface _RuleBaseS extends _RuleBase { /** 比较关系 */ logic: "like" | "notLike" | "regexp"; /** 比较值 */ value: string; } interface _RuleBaseBetween extends _RuleBase { /** 逻辑关系 */ logic: "between" | "notBetween"; /** 值范围 */ value: [number, number]; } interface _RuleBaseIn extends _RuleBase { /** 逻辑关系 */ logic: "in" | "notIn"; /** 值范围 */ value: ns[]; } interface _RuleBaseNull extends _RuleBase { /** 逻辑关系 */ logic: "isNull" | "isNotNull"; } type _RuleEl = _RuleBaseNS | _RuleBaseN | _RuleBaseS | _RuleBaseBetween | _RuleBaseIn | _RuleBaseNull; type _RuleChildren = { childrenOr?: any; children: R[]; }; type R = _RuleEl | (_RuleEl & _RuleChildren) | _RuleChildren; type Writable = { -readonly [P in keyof T]: T[P]; }; type Rp = { "#rule"?: R[]; "#order"?: QueryOrder[]; "#group"?: QueryGroup[]; "#field"?: Alias; }; type QueryParam = Rp | { id: string | string[]; } | Partial | string | string[]; type FQ = QueryParam; type UpdateParam = ({ id: any; } & Partial) | ({ "#entity": Partial; } & FQ) | Update;