diff --git a/BE/src/users/entities/social-login.entity.ts b/BE/src/users/entities/social-login.entity.ts new file mode 100644 index 0000000..d9be010 --- /dev/null +++ b/BE/src/users/entities/social-login.entity.ts @@ -0,0 +1,14 @@ +import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; +import { User } from './user.entity'; + +@Entity('social_login') +export class SocialLogin { + @PrimaryGeneratedColumn('increment') + id: number; + + @Column({ length: 10, unique: true }) + name: string; + + @OneToMany(() => User, (user) => user.socials) + users: User[]; +} diff --git a/BE/src/users/entities/user.entity.ts b/BE/src/users/entities/user.entity.ts index 89d152b..39d08c2 100644 --- a/BE/src/users/entities/user.entity.ts +++ b/BE/src/users/entities/user.entity.ts @@ -1,7 +1,15 @@ import { Liked } from 'src/postings/entities/liked.entity'; import { Posting } from 'src/postings/entities/posting.entity'; import { Report } from 'src/postings/entities/report.entity'; -import { Entity, Column, PrimaryColumn, OneToMany } from 'typeorm'; +import { + Entity, + Column, + PrimaryColumn, + OneToMany, + ManyToOne, + JoinColumn, +} from 'typeorm'; +import { SocialLogin } from './social-login.entity'; @Entity() export class User { @@ -14,6 +22,12 @@ export class User { @Column({ length: 255, nullable: true }) avatar: string; + @Column({ length: 255, name: 'resource_id' }) + resourceId: string; + + @Column({ type: 'int', name: 'social_type' }) + socialType: number; + @OneToMany(() => Liked, (liked) => liked.users) likeds: Liked[]; @@ -22,4 +36,8 @@ export class User { @OneToMany(() => Posting, (posting) => posting.writers) postings: Posting[]; + + @ManyToOne(() => SocialLogin, (socialLogin) => socialLogin.users) + @JoinColumn({ name: 'type', referencedColumnName: 'id' }) + socials: SocialLogin; }