2023-01-13 05:40:33 +01:00
|
|
|
import { Entity, Index, Column, PrimaryColumn } from "typeorm";
|
|
|
|
import { id } from "../id.js";
|
2021-05-04 14:15:57 +02:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class Ad {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("timestamp with time zone", {
|
|
|
|
comment: "The created date of the Ad.",
|
2021-05-04 14:15:57 +02:00
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Index()
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("timestamp with time zone", {
|
|
|
|
comment: "The expired date of the Ad.",
|
2021-05-04 14:15:57 +02:00
|
|
|
})
|
|
|
|
public expiresAt: Date;
|
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("varchar", {
|
|
|
|
length: 32,
|
|
|
|
nullable: false,
|
2021-05-04 14:15:57 +02:00
|
|
|
})
|
|
|
|
public place: string;
|
|
|
|
|
2021-05-07 07:22:13 +02:00
|
|
|
// 今は使われていないが将来的に活用される可能性はある
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("varchar", {
|
|
|
|
length: 32,
|
|
|
|
nullable: false,
|
2021-05-04 14:15:57 +02:00
|
|
|
})
|
|
|
|
public priority: string;
|
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("integer", {
|
|
|
|
default: 1,
|
|
|
|
nullable: false,
|
2021-05-07 07:22:13 +02:00
|
|
|
})
|
|
|
|
public ratio: number;
|
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("varchar", {
|
|
|
|
length: 1024,
|
|
|
|
nullable: false,
|
2021-05-04 14:15:57 +02:00
|
|
|
})
|
|
|
|
public url: string;
|
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("varchar", {
|
|
|
|
length: 1024,
|
|
|
|
nullable: false,
|
2021-05-04 14:15:57 +02:00
|
|
|
})
|
|
|
|
public imageUrl: string;
|
|
|
|
|
2023-05-29 18:31:02 +02:00
|
|
|
@Column("varchar", {
|
|
|
|
length: 8192,
|
|
|
|
nullable: false,
|
2021-05-04 14:15:57 +02: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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|