-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathForum.ts
More file actions
59 lines (49 loc) · 1.42 KB
/
Forum.ts
File metadata and controls
59 lines (49 loc) · 1.42 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Transform, Type } from 'class-transformer';
import { IsDateString, IsInt, IsOptional, IsString, Min, ValidateNested } from 'class-validator';
import { Column, Entity, JoinTable, ManyToMany, ManyToOne } from 'typeorm';
import { ListChunk } from '../Base';
import { Place } from '../Organization';
import { User } from '../User';
import { Activity, ActivityBase } from './Activity';
@Entity()
export class Forum extends ActivityBase {
@IsString()
@Column()
title: string;
@IsString()
@IsOptional()
@Column({ nullable: true })
summary?: string;
@Type(() => User)
@Transform(({ value }) => (Array.isArray(value) ? value.map(user => User.from(user)) : []))
@ValidateNested({ each: true })
@ManyToMany(() => User)
@JoinTable()
producers: User[];
@IsDateString()
@Column('date')
startTime: string;
@IsDateString()
@Column('date')
endTime: string;
@Type(() => Place)
@Transform(({ value }) => Place.from(value))
@ValidateNested()
@ManyToOne(() => Place)
place: Place;
}
export abstract class ForumBase extends ActivityBase {
@Type(() => Forum)
@Transform(({ value }) => Forum.from(value))
@ValidateNested()
@ManyToOne(() => Forum)
forum: Forum;
}
export class ForumListChunk implements ListChunk<Forum> {
@IsInt()
@Min(0)
count: number;
@Type(() => Forum)
@ValidateNested({ each: true })
list: Forum[];
}