Skip to content

Commit

Permalink
feat/#108: add and modify columns in user entity, update login_type
Browse files Browse the repository at this point in the history
  • Loading branch information
ohchanghoon committed Jan 18, 2024
1 parent dcfc13d commit 1d21ec4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/apis/users/constants/user.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export enum UserGender {

export enum UserLoginType {
Email = 'email',
Kakao = 'KAKAO',
Google = 'GOOGLE',
Naver = 'NAVER',
}

export enum UserStatus {
Expand Down
6 changes: 6 additions & 0 deletions src/apis/users/dto/create-user-request-body.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export class CreateUserRequestBodyDto
@IsEnum(UserLoginType)
loginType: UserLoginType;

@ApiProperty({
description: 'snsId',
})
snsId: string;

@ApiProperty({
description: 'name',
minLength: USER_NAME_LENGTH.MIN,
Expand Down Expand Up @@ -68,6 +73,7 @@ export class CreateUserRequestBodyDto
pattern: String(USER_PASSWORD_REGEXP),
})
@Matches(USER_PASSWORD_REGEXP)
@IsOptional()
@ValidateIf((object, value) => {
if (object.loginType === UserLoginType.Email) {
return true;
Expand Down
7 changes: 7 additions & 0 deletions src/apis/users/dto/user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { PHONE_NUMBER_REGEXP } from '@src/constants/regexp.constant';
import { BaseDto } from '@src/dto/base.dto';
import { User } from '@src/entities/User';
import { Exclude } from 'class-transformer';
import { IsOptional } from 'class-validator';

export class UserDto
extends BaseDto
Expand Down Expand Up @@ -46,6 +47,12 @@ export class UserDto
})
email: string;

@ApiProperty({
description: 'SNS 토큰',
})
@IsOptional()
snsToken: string;

@ApiProperty({
description: '유저 로그인 타입',
enum: UserLoginType,
Expand Down
15 changes: 14 additions & 1 deletion src/entities/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,27 @@ export class User {
})
studentNumber: string | null;

@Column('varchar', {
name: 'sns_id',
comment: '소셜 고유 ID',
nullable: true,
length: 255,
})
snsId: string | null;

@Column('enum', {
name: 'login_type',
comment: '로그인 타입',
enum: UserLoginType,
})
loginType: UserLoginType;

@Column('varchar', { name: 'name', comment: '유저 이름', length: 20 })
@Column('varchar', {
name: 'name',
nullable: true,
comment: '유저 이름',
length: 20
})
name: string;

@Column('varchar', {
Expand Down

0 comments on commit 1d21ec4

Please sign in to comment.