2021-05-04 07:15:57 -05:00
|
|
|
import { Entity, Index, Column, PrimaryColumn } from 'typeorm';
|
2021-08-19 07:55:45 -05:00
|
|
|
import { id } from '../id';
|
2021-05-04 07:15:57 -05:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class Ad {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 08:58:30 -06:00
|
|
|
comment: 'The created date of the Ad.',
|
2021-05-04 07:15:57 -05:00
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 08:58:30 -06:00
|
|
|
comment: 'The expired date of the Ad.',
|
2021-05-04 07:15:57 -05:00
|
|
|
})
|
|
|
|
public expiresAt: Date;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 08:58:30 -06:00
|
|
|
length: 32, nullable: false,
|
2021-05-04 07:15:57 -05:00
|
|
|
})
|
|
|
|
public place: string;
|
|
|
|
|
2021-05-07 00:22:13 -05:00
|
|
|
// 今は使われていないが将来的に活用される可能性はある
|
2021-05-04 07:15:57 -05:00
|
|
|
@Column('varchar', {
|
2021-12-09 08:58:30 -06:00
|
|
|
length: 32, nullable: false,
|
2021-05-04 07:15:57 -05:00
|
|
|
})
|
|
|
|
public priority: string;
|
|
|
|
|
2021-05-07 00:22:13 -05:00
|
|
|
@Column('integer', {
|
2021-12-09 08:58:30 -06:00
|
|
|
default: 1, nullable: false,
|
2021-05-07 00:22:13 -05:00
|
|
|
})
|
|
|
|
public ratio: number;
|
|
|
|
|
2021-05-04 07:15:57 -05:00
|
|
|
@Column('varchar', {
|
2021-12-09 08:58:30 -06:00
|
|
|
length: 1024, nullable: false,
|
2021-05-04 07:15:57 -05:00
|
|
|
})
|
|
|
|
public url: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 08:58:30 -06:00
|
|
|
length: 1024, nullable: false,
|
2021-05-04 07:15:57 -05:00
|
|
|
})
|
|
|
|
public imageUrl: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 08:58:30 -06:00
|
|
|
length: 8192, nullable: false,
|
2021-05-04 07:15:57 -05:00
|
|
|
})
|
|
|
|
public memo: string;
|
|
|
|
|
|
|
|
constructor(data: Partial<Ad>) {
|
|
|
|
if (data == null) return;
|
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(data)) {
|
|
|
|
(this as any)[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|