2023-07-27 14:31:52 +09:00
|
|
|
/*
|
2024-02-14 00:50:11 +09:00
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
2023-07-27 14:31:52 +09:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2021-05-04 21:15:57 +09:00
|
|
|
import { Entity, Index, Column, PrimaryColumn } from 'typeorm';
|
2023-09-20 11:33:36 +09:00
|
|
|
import { id } from './util/id.js';
|
2021-05-04 21:15:57 +09:00
|
|
|
|
2023-08-16 17:51:28 +09:00
|
|
|
@Entity('ad')
|
|
|
|
export class MiAd {
|
2021-05-04 21:15:57 +09:00
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 23:58:30 +09:00
|
|
|
comment: 'The expired date of the Ad.',
|
2021-05-04 21:15:57 +09:00
|
|
|
})
|
|
|
|
public expiresAt: Date;
|
|
|
|
|
2023-02-15 14:29:40 +09:00
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
comment: 'The expired date of the Ad.',
|
2023-02-16 22:08:45 +09:00
|
|
|
default: () => 'now()',
|
2023-02-15 14:29:40 +09:00
|
|
|
})
|
2023-02-15 14:31:59 +09:00
|
|
|
public startsAt: Date;
|
2023-02-15 14:29:40 +09:00
|
|
|
|
2021-05-04 21:15:57 +09:00
|
|
|
@Column('varchar', {
|
2021-12-09 23:58:30 +09:00
|
|
|
length: 32, nullable: false,
|
2021-05-04 21:15:57 +09:00
|
|
|
})
|
|
|
|
public place: string;
|
|
|
|
|
2021-05-07 14:22:13 +09:00
|
|
|
// 今は使われていないが将来的に活用される可能性はある
|
2021-05-04 21:15:57 +09:00
|
|
|
@Column('varchar', {
|
2021-12-09 23:58:30 +09:00
|
|
|
length: 32, nullable: false,
|
2021-05-04 21:15:57 +09:00
|
|
|
})
|
|
|
|
public priority: string;
|
|
|
|
|
2021-05-07 14:22:13 +09:00
|
|
|
@Column('integer', {
|
2021-12-09 23:58:30 +09:00
|
|
|
default: 1, nullable: false,
|
2021-05-07 14:22:13 +09:00
|
|
|
})
|
|
|
|
public ratio: number;
|
|
|
|
|
2021-05-04 21:15:57 +09:00
|
|
|
@Column('varchar', {
|
2021-12-09 23:58:30 +09:00
|
|
|
length: 1024, nullable: false,
|
2021-05-04 21:15:57 +09:00
|
|
|
})
|
|
|
|
public url: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 23:58:30 +09:00
|
|
|
length: 1024, nullable: false,
|
2021-05-04 21:15:57 +09:00
|
|
|
})
|
|
|
|
public imageUrl: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 23:58:30 +09:00
|
|
|
length: 8192, nullable: false,
|
2021-05-04 21:15:57 +09:00
|
|
|
})
|
|
|
|
public memo: string;
|
2023-07-08 08:56:11 +09:00
|
|
|
@Column('integer', {
|
|
|
|
default: 0, nullable: false,
|
|
|
|
})
|
|
|
|
public dayOfWeek: number;
|
2023-08-16 17:51:28 +09:00
|
|
|
constructor(data: Partial<MiAd>) {
|
2021-05-04 21:15:57 +09:00
|
|
|
if (data == null) return;
|
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(data)) {
|
|
|
|
(this as any)[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|