| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';
- import { AreaEntity } from '../areas/area.entity';
- import { DeleteStatus, DisabledStatus } from '../../share/types';
- @Entity({ name: 'locations' })
- export class LocationEntity {
- @PrimaryGeneratedColumn({ unsigned: true, comment: '地点ID' })
- id!: number;
- @Column({ name: 'name', type: 'varchar', length: 255, comment: '地点名称' })
- name!: string;
- @Column({ name: 'province_id', type: 'int', unsigned: true, comment: '省份ID' })
- provinceId!: number;
- @Column({ name: 'city_id', type: 'int', unsigned: true, comment: '城市ID' })
- cityId!: number;
- @Column({ name: 'district_id', type: 'int', unsigned: true, comment: '区县ID' })
- districtId!: number;
- @Column({ name: 'address', type: 'varchar', length: 500, comment: '详细地址' })
- address!: string;
- @Column({ name: 'latitude', type: 'decimal', precision: 10, scale: 6, nullable: true, comment: '纬度' })
- latitude!: number | null;
- @Column({ name: 'longitude', type: 'decimal', precision: 10, scale: 6, nullable: true, comment: '经度' })
- longitude!: number | null;
- // 关联关系 - 省份
- @ManyToOne(() => AreaEntity, { nullable: false })
- @JoinColumn({ name: 'province_id', referencedColumnName: 'id' })
- province!: AreaEntity;
- // 关联关系 - 城市
- @ManyToOne(() => AreaEntity, { nullable: false })
- @JoinColumn({ name: 'city_id', referencedColumnName: 'id' })
- city!: AreaEntity;
- // 关联关系 - 区县
- @ManyToOne(() => AreaEntity, { nullable: false })
- @JoinColumn({ name: 'district_id', referencedColumnName: 'id' })
- district!: AreaEntity;
- @Column({ name: 'is_disabled', type: 'int', default: DisabledStatus.ENABLED, comment: '是否禁用(0:启用,1:禁用)' })
- isDisabled!: DisabledStatus;
- @Column({ name: 'is_deleted', type: 'int', default: DeleteStatus.NOT_DELETED, comment: '是否删除(0:未删除,1:已删除)' })
- isDeleted!: DeleteStatus;
- @Column({ name: 'created_by', type: 'int', nullable: true, comment: '创建人ID' })
- createdBy!: number | null;
- @Column({ name: 'updated_by', type: 'int', nullable: true, comment: '更新人ID' })
- updatedBy!: number | null;
- @CreateDateColumn({ name: 'created_at', type: 'timestamp' })
- createdAt!: Date;
- @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
- updatedAt!: Date;
- constructor(partial?: Partial<LocationEntity>) {
- Object.assign(this, partial);
- }
- }
|