Skip to content

Commit

Permalink
merge: #90 user 테이블 수정, social_login 테이블 추가
Browse files Browse the repository at this point in the history
[refactor] user 테이블 수정, social_login 테이블 추가
  • Loading branch information
kmi0817 authored Nov 22, 2023
2 parents 449c358 + c631a09 commit da3b778
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
14 changes: 14 additions & 0 deletions BE/src/users/entities/social-login.entity.ts
Original file line number Diff line number Diff line change
@@ -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[];
}
20 changes: 19 additions & 1 deletion BE/src/users/entities/user.entity.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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[];

Expand All @@ -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;
}

0 comments on commit da3b778

Please sign in to comment.