hippofish/packages/backend/src/models/entities/Ad.ts

70 lines
1.3 KiB
TypeScript
Raw Normal View History

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