summaryrefslogtreecommitdiff
path: root/src/models/entities/ad.ts
blob: b2fc04c4f03e4cc3764fe96fefa2538d4c121a8b (plain)
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 { Entity, Index, Column, PrimaryColumn } from 'typeorm';
import { id } from '../id';

@Entity()
export class Ad {
	@PrimaryColumn(id())
	public id: string;

	@Index()
	@Column('timestamp with time zone', {
		comment: 'The created date of the Ad.'
	})
	public createdAt: Date;

	@Index()
	@Column('timestamp with time zone', {
		comment: 'The expired date of the Ad.'
	})
	public expiresAt: Date;

	@Column('varchar', {
		length: 32, nullable: false
	})
	public place: string;

	// 今は使われていないが将来的に活用される可能性はある
	@Column('varchar', {
		length: 32, nullable: false
	})
	public priority: string;

	@Column('integer', {
		default: 1, nullable: false
	})
	public ratio: number;

	@Column('varchar', {
		length: 1024, nullable: false
	})
	public url: string;

	@Column('varchar', {
		length: 1024, nullable: false
	})
	public imageUrl: string;

	@Column('varchar', {
		length: 8192, nullable: false
	})
	public memo: string;

	constructor(data: Partial<Ad>) {
		if (data == null) return;

		for (const [k, v] of Object.entries(data)) {
			(this as any)[k] = v;
		}
	}
}