Skip to content

Commit

Permalink
feat(share): update type PageOrderByRule
Browse files Browse the repository at this point in the history
accept generics TCol and TOrder
  • Loading branch information
waitingsong committed Feb 2, 2024
1 parent 69ce0e4 commit aac4e3e
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions packages/share/src/lib/common.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,32 @@ import { Rule } from '@midwayjs/validate'
import { commonValidSchemas } from './validation-schema/common.schema.js'


/** 查询排序规则 */
export class PageOrderByRule {
/**
* 查询排序规则
* @example `
* class UserDTO {
* id: number
* name: string
* }
* class UserRule extends PageOrderByRule<keyof UserDTO> {
* @ApiProperty({ example: 'id', description: '' })
* declare column
* }
* class UserRule extends PageOrderByRule<'id' | 'name'> {
* @ApiProperty({ example: 'id', description: '' })
* declare column
* }
* `
**/
export class PageOrderByRule<TCol = string, TOrder = 'ASC' | 'DESC' | 'asc' | 'desc'> {
@ApiProperty({ example: 'ctime', description: '排序字段' })
column: string
column: TCol

/**
* @default ASC
*/
@ApiProperty({ example: 'ASC', description: '排序顺序 默认升序' })
order?: 'ASC' | 'DESC' | 'asc' | 'desc'
order?: TOrder | undefined
}


Expand Down

0 comments on commit aac4e3e

Please sign in to comment.