import { Authority } from './authority.entity';
import { <%_ if (databaseType === 'mongodb') { _%> ObjectIdColumn <%_ } else { _%> PrimaryGeneratedColumn <%_ } _%>, Entity, Column<%_ if (databaseType !== 'mongodb') { _%>, ManyToMany, JoinTable <%_ } _%> } from 'typeorm';
import { BaseEntity } from './base/base.entity';
import { Exclude } from 'class-transformer';

@Entity('<%- jhiTablePrefix %>_user')
export class <%= user.persistClass %> extends BaseEntity {

<%_ if (databaseTypeMongodb) { _%>
  @ObjectIdColumn({ name: '_<%- user.primaryKey.name %>' })
<%_ } else if (databaseTypeSql) { _%>
  @PrimaryGeneratedColumn(<%- user.primaryKey.typeUUID ? "'uuid'" : '' %>)
<%_ } _%>
  <%- user.primaryKey.name %>?: <%- user.primaryKey.tsType %>;

  @Column({ unique: true })
  login: string;
  @Column({ nullable: true })
  firstName?: string;
  @Column({ nullable: true })
  lastName?: string;
  @Column()
  email: string;
  @Column({ default: false})
  activated?: boolean;
  @Column({default: 'en'})
  langKey?: string;

  <%_ if (databaseType === 'mongodb') { _%>
  @Column()
  authorities?: Authority[];
  <%_ } else { _%>
  @ManyToMany(() => Authority)
  @JoinTable()
  authorities?: any[];
  <%_ } _%>

  @Column({
    type: "varchar"
  })
  @Exclude()
  password: string;
  @Column({ nullable: true })
  imageUrl?: string;
  @Column({ nullable: true })
  activationKey?: string;
  @Column({ nullable: true })
  resetKey?: string;
  @Column({ nullable: true })
  resetDate?: Date;
}
