2

Am developing the SignUp feature and my users can be either student teacher or admin like shown in this diagram: Class Diagram
And this is the code to implemente

@Entity()
@TableInheritance({ column: { type: 'varchar', name: 'type' } })
export abstract class User extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ unique: true })
  cin: string;

  @Column()
  email: string;

  @Column()
  password: string;
}

@ChildEntity()
export class Admin extends User {

}

@ChildEntity()
export class Professeur extends User {
}

@ChildEntity()
export class Etudiant extends User {
  @Column({ unique: true })
  cne: string;
}

Now I have a problem in the sign up feature, when new user want to sign up what is the best way to define my DTOs and should it be one DTO or one for each type of user?

0 Answers0