-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTag.ts
More file actions
43 lines (35 loc) · 981 Bytes
/
Tag.ts
File metadata and controls
43 lines (35 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Type } from 'class-transformer';
import { IsEnum, IsNumber, IsOptional, IsString, ValidateNested } from 'class-validator';
import { Column, Entity } from 'typeorm';
import { ListChunk } from './Base';
import { UserBase, UserBaseFilter, UserInputData } from './User/User';
export enum TagType {
Tag = 'tag',
Category = 'category',
City = 'city',
Cooperation = 'cooperation'
}
@Entity()
export class Tag extends UserBase {
@Column()
@IsString()
name: string = '';
@Column({ type: 'simple-enum', enum: TagType })
@IsEnum(TagType)
type: TagType = TagType.Tag;
}
export class TagFilter extends UserBaseFilter implements Partial<UserInputData<Tag>> {
@IsString()
@IsOptional()
name?: string;
@IsEnum(TagType)
@IsOptional()
type?: TagType;
}
export class TagListChunk implements ListChunk<Tag> {
@Type(() => Tag)
@ValidateNested({ each: true })
list: Tag[];
@IsNumber()
count: number;
}