2018-03-31 03:30:30 +08:00
|
|
|
import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from 'typeorm';
|
|
|
|
import {CameraMetadata, GPSMetadata, ImageSize, PhotoDTO, PhotoMetadata, PositionMetaData} from '../../../../common/entities/PhotoDTO';
|
|
|
|
import {DirectoryEntity} from './DirectoryEntity';
|
2018-11-02 17:40:09 +08:00
|
|
|
import {OrientationTypes} from 'ts-exif-parser';
|
2017-10-20 00:08:07 +08:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class CameraMetadataEntity implements CameraMetadata {
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('text', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
ISO: number;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('text', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
model: string;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('text', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
maker: string;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('int', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
fStop: number;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('int', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
exposure: number;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('int', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
focalLength: number;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('text', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
lens: string;
|
|
|
|
}
|
2016-12-28 03:55:51 +08:00
|
|
|
|
|
|
|
|
2017-12-18 10:34:07 +08:00
|
|
|
@Entity()
|
|
|
|
export class GPSMetadataEntity implements GPSMetadata {
|
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('int', {nullable: true})
|
2017-12-18 10:34:07 +08:00
|
|
|
latitude: number;
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('int', {nullable: true})
|
2017-12-18 10:34:07 +08:00
|
|
|
longitude: number;
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('int', {nullable: true})
|
2017-12-18 10:34:07 +08:00
|
|
|
altitude: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class ImageSizeEntity implements ImageSize {
|
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('int')
|
2017-12-18 10:34:07 +08:00
|
|
|
width: number;
|
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('int')
|
2017-12-18 10:34:07 +08:00
|
|
|
height: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-20 00:08:07 +08:00
|
|
|
@Entity()
|
|
|
|
export class PositionMetaDataEntity implements PositionMetaData {
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-10-20 00:08:07 +08:00
|
|
|
@Column(type => GPSMetadataEntity)
|
|
|
|
GPSData: GPSMetadataEntity;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('text', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
country: string;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('text', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
state: string;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('text', {nullable: true})
|
2017-10-20 00:08:07 +08:00
|
|
|
city: string;
|
|
|
|
}
|
2016-12-28 03:55:51 +08:00
|
|
|
|
|
|
|
|
2017-10-20 00:08:07 +08:00
|
|
|
@Entity()
|
2017-12-18 10:34:07 +08:00
|
|
|
export class PhotoMetadataEntity implements PhotoMetadata {
|
2017-10-20 00:08:07 +08:00
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('simple-array')
|
2017-12-18 10:34:07 +08:00
|
|
|
keywords: Array<string>;
|
|
|
|
|
|
|
|
@Column(type => CameraMetadataEntity)
|
|
|
|
cameraData: CameraMetadataEntity;
|
|
|
|
|
|
|
|
@Column(type => PositionMetaDataEntity)
|
|
|
|
positionData: PositionMetaDataEntity;
|
|
|
|
|
2018-11-02 17:40:09 +08:00
|
|
|
@Column('tinyint')
|
|
|
|
orientation: OrientationTypes;
|
|
|
|
|
2017-12-18 10:34:07 +08:00
|
|
|
@Column(type => ImageSizeEntity)
|
|
|
|
size: ImageSizeEntity;
|
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('bigint')
|
2017-12-18 10:34:07 +08:00
|
|
|
creationDate: number;
|
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('int')
|
2017-12-18 10:34:07 +08:00
|
|
|
fileSize: number;
|
2017-10-20 00:08:07 +08:00
|
|
|
}
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-12-18 10:34:07 +08:00
|
|
|
|
2017-10-20 00:08:07 +08:00
|
|
|
@Entity()
|
2017-12-18 10:34:07 +08:00
|
|
|
export class PhotoEntity implements PhotoDTO {
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-12-18 10:34:07 +08:00
|
|
|
@PrimaryGeneratedColumn()
|
|
|
|
id: number;
|
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column('text')
|
2017-12-18 10:34:07 +08:00
|
|
|
name: string;
|
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@ManyToOne(type => DirectoryEntity, directory => directory.photos, {onDelete: 'CASCADE'})
|
2017-12-18 10:34:07 +08:00
|
|
|
directory: DirectoryEntity;
|
|
|
|
|
|
|
|
@Column(type => PhotoMetadataEntity)
|
|
|
|
metadata: PhotoMetadataEntity;
|
|
|
|
|
|
|
|
readyThumbnails: Array<number> = [];
|
|
|
|
|
2018-05-13 00:19:51 +08:00
|
|
|
readyIcon = false;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-10-20 00:08:07 +08:00
|
|
|
}
|