Skip to content

Commit

Permalink
refactor(be): requestDTO 추가 #152
Browse files Browse the repository at this point in the history
  • Loading branch information
namhyo01 committed Dec 15, 2022
1 parent b36c2b6 commit 3b1fd39
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 95 deletions.
2 changes: 1 addition & 1 deletion server/src/database/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
UserDuplicateNicknameException,
UserNotFoundException,
} from '../exception/user.exception';
import { SearchUserListDto } from 'src/domain/user/dto/search-user-list.dto';
import { SEARCH_USER_LIMIT } from '../constants/pagination.constants';
import { SearchUserListDto } from 'src/domain/user/dto/request.dto';

@Injectable()
export class UserRepository {
Expand Down
13 changes: 0 additions & 13 deletions server/src/domain/user/dto/get-update-password.dto.ts

This file was deleted.

79 changes: 79 additions & 0 deletions server/src/domain/user/dto/request.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import {
IsString,
MaxLength,
IsNotEmpty,
Matches,
IsByteLength,
IsOptional,
IsEmail,
IsNumber,
} from 'class-validator';

export class UserUpdateDto {
@IsString()
@IsOptional()
@MaxLength(500)
bio: string;

@IsOptional()
@IsNotEmpty()
@IsString()
@Matches(/^[a-zA-Z---\d_]{1,16}$/)
@IsByteLength(1, 16)
nickname: string;
}
export class UserProfileDto {
@IsNotEmpty()
@IsString()
userid: string;

@IsNotEmpty()
@IsString()
nickname: string;

@IsEmail()
@IsNotEmpty()
email: string;

@IsNotEmpty()
@IsString()
profileimg = '';

@IsNotEmpty()
@IsString()
bio = '';

@IsNotEmpty()
@IsNumber()
postcount: number;

@IsNotEmpty()
@IsNumber()
follower: number;

@IsNotEmpty()
@IsNumber()
following: number;

@IsNotEmpty()
state: boolean;
}
export class SearchUserListDto {
@IsString()
keyword = '';

@IsString()
@IsOptional()
next = '';
}
export class GetUserUpdatePasswordDto {
@IsNotEmpty()
@IsString()
@Matches(/^[a-zA-Z\d!@#$%^&*()-_=+]{6,16}$/)
prevPassword: string;

@IsNotEmpty()
@IsString()
@Matches(/^[a-zA-Z\d!@#$%^&*()-_=+]{6,16}$/)
newPassword: string;
}
10 changes: 0 additions & 10 deletions server/src/domain/user/dto/search-user-list.dto.ts

This file was deleted.

42 changes: 0 additions & 42 deletions server/src/domain/user/dto/user-profile.dto.ts

This file was deleted.

22 changes: 0 additions & 22 deletions server/src/domain/user/dto/user-update.dto.ts

This file was deleted.

8 changes: 5 additions & 3 deletions server/src/domain/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ import {
} from '@nestjs/common';
import { UserService } from './user.service';
import { User } from 'src/database/user.schema';
import { UserUpdateDto } from './dto/user-update.dto';
import { UpdateAuthGuard } from 'src/guard/update-user.guard';
import { JwtAuthGuard } from 'src/guard/jwt-auth.guard';
import { GetUser } from 'src/decorator/get-user.decorator';
import { NcloudService } from 'src/domain/ncloud/ncloud.service';
import { FileInterceptor } from '@nestjs/platform-express';
import { GetUserUpdatePasswordDto } from './dto/get-update-password.dto';
import { MoheyumInterceptor } from 'src/cache/cache.interceptor';
import { CacheEvict } from 'src/cache/cache-evict.decorator';
import { CacheIndividual } from 'src/cache/cahce-individual.decorator';
import { CachePagination } from 'src/cache/cache-next-ttl.decorator';
import { SearchUserListDto } from './dto/search-user-list.dto';
import {
GetUserUpdatePasswordDto,
SearchUserListDto,
UserUpdateDto,
} from './dto/request.dto';

@Controller('user')
@UseInterceptors(MoheyumInterceptor)
Expand Down
10 changes: 6 additions & 4 deletions server/src/domain/user/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { UserProfileDto } from './dto/user-profile.dto';
import { UserUpdateDto } from './dto/user-update.dto';
import { UserRepository } from 'src/database/user.repository';
import { FollowRepository } from 'src/database/follow.repository';
import * as bcrypt from 'bcrypt';
import { ConfigService } from '@nestjs/config';
import { GetUserUpdatePasswordDto } from './dto/get-update-password.dto';
import { SearchUserListDto } from './dto/search-user-list.dto';
import { SEARCH_USER_LIMIT } from 'src/constants/pagination.constants';
import {
GetUserUpdatePasswordDto,
SearchUserListDto,
UserProfileDto,
UserUpdateDto,
} from './dto/request.dto';

@Injectable()
export class UserService {
Expand Down

0 comments on commit 3b1fd39

Please sign in to comment.