1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/backend/model/mysql/enitites/DirectoryEntity.ts

40 lines
918 B
TypeScript
Raw Normal View History

2017-07-15 23:48:29 +08:00
import {Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn} from "typeorm";
2016-12-28 03:55:51 +08:00
import {DirectoryDTO} from "../../../../common/entities/DirectoryDTO";
import {PhotoEntity} from "./PhotoEntity";
2017-02-05 23:19:35 +08:00
@Entity()
export class DirectoryEntity implements DirectoryDTO {
2016-12-28 03:55:51 +08:00
2017-07-15 23:48:29 +08:00
@PrimaryGeneratedColumn()
id: number;
2016-12-28 03:55:51 +08:00
2017-07-15 23:48:29 +08:00
@Column({
length: 500
})
name: string;
2016-12-28 03:55:51 +08:00
2017-07-15 23:48:29 +08:00
@Column({
length: 500
})
path: string;
2016-12-28 03:55:51 +08:00
2017-07-15 23:48:29 +08:00
@Column('number')
2017-07-20 02:47:09 +08:00
public lastModified: number;
@Column('number')
public lastScanned: number;
2016-12-28 03:55:51 +08:00
2017-07-15 23:48:29 +08:00
@Column({type: 'smallint', length: 1})
public scanned: boolean;
2016-12-28 22:35:27 +08:00
2017-07-18 05:12:12 +08:00
@ManyToOne(type => DirectoryEntity, directory => directory.directories, {onDelete: "CASCADE"})
2017-07-15 23:48:29 +08:00
public parent: DirectoryEntity;
2016-12-28 03:55:51 +08:00
2017-07-15 23:48:29 +08:00
@OneToMany(type => DirectoryEntity, dir => dir.parent)
public directories: Array<DirectoryEntity>;
2016-12-28 03:55:51 +08:00
2017-07-15 23:48:29 +08:00
@OneToMany(type => PhotoEntity, photo => photo.directory)
public photos: Array<PhotoEntity>;
2016-12-28 03:55:51 +08:00
2017-07-15 23:48:29 +08:00
}