diff --git a/src/admins/banned-user/constants/banned-user.constant.ts b/src/admins/banned-user/constants/banned-user.constant.ts index 829e703a..798833a9 100644 --- a/src/admins/banned-user/constants/banned-user.constant.ts +++ b/src/admins/banned-user/constants/banned-user.constant.ts @@ -1,4 +1,4 @@ export const BANNED_USER_REASON_LENGTH = { MIN: 1, - MAX: 255, + MAX: 200, } as const; diff --git a/src/admins/banned-user/dtos/create-banned-user-body.dto.ts b/src/admins/banned-user/dtos/create-banned-user-body.dto.ts index 40d52fa2..85d29d0e 100644 --- a/src/admins/banned-user/dtos/create-banned-user-body.dto.ts +++ b/src/admins/banned-user/dtos/create-banned-user-body.dto.ts @@ -10,8 +10,8 @@ export class CreateBannedUserBodyDto { @ApiProperty({ description: '정지 사유', - minLength: 1, - maxLength: 255, + minLength: BANNED_USER_REASON_LENGTH.MIN, + maxLength: BANNED_USER_REASON_LENGTH.MAX, }) @Length(BANNED_USER_REASON_LENGTH.MIN, BANNED_USER_REASON_LENGTH.MAX) reason: string; diff --git a/src/boards/constants/help-me-board-order-field.enum.ts b/src/boards/constants/help-me-board/help-me-board-order-field.enum.ts similarity index 100% rename from src/boards/constants/help-me-board-order-field.enum.ts rename to src/boards/constants/help-me-board/help-me-board-order-field.enum.ts diff --git a/src/boards/constants/help-me-board/help-me-board.constant.ts b/src/boards/constants/help-me-board/help-me-board.constant.ts new file mode 100644 index 00000000..ad92b640 --- /dev/null +++ b/src/boards/constants/help-me-board/help-me-board.constant.ts @@ -0,0 +1,8 @@ +export const HELP_ME_BOARD_HEAD_LENGTH = { + MIN: 5, + MAX: 50, +} as const; + +export const HELP_ME_BOARD_BODY_LENGTH = { + MIN: 10, +} as const; diff --git a/src/boards/constants/mentor-board-order-field.enum.ts b/src/boards/constants/mentor-board/mentor-board-order-field.enum.ts similarity index 100% rename from src/boards/constants/mentor-board-order-field.enum.ts rename to src/boards/constants/mentor-board/mentor-board-order-field.enum.ts diff --git a/src/boards/constants/mentor-board/mentor-board.constant.ts b/src/boards/constants/mentor-board/mentor-board.constant.ts new file mode 100644 index 00000000..d3717240 --- /dev/null +++ b/src/boards/constants/mentor-board/mentor-board.constant.ts @@ -0,0 +1,8 @@ +export const MENTOR_BOARD_HEAD_LENGTH = { + MIN: 5, + MAX: 50, +} as const; + +export const MENTOR_BOARD_BODY_LENGTH = { + MIN: 10, +} as const; diff --git a/src/boards/dto/helpMeBoard/create.help.me.board.dto.ts b/src/boards/dto/helpMeBoard/create.help.me.board.dto.ts index 6a325bba..7e58bcb3 100644 --- a/src/boards/dto/helpMeBoard/create.help.me.board.dto.ts +++ b/src/boards/dto/helpMeBoard/create.help.me.board.dto.ts @@ -1,7 +1,8 @@ -import { IsNumber, IsString } from 'class-validator'; +import { HELP_ME_BOARD_HEAD_LENGTH } from '@src/boards/constants/help-me-board/help-me-board.constant'; +import { IsNumber, IsString, Length } from 'class-validator'; export class CreateHelpMeBoardDto { - @IsString() + @Length(HELP_ME_BOARD_HEAD_LENGTH.MIN, HELP_ME_BOARD_HEAD_LENGTH.MAX) head: string; @IsString() diff --git a/src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts b/src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts index 13457aa6..3233268c 100644 --- a/src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts +++ b/src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts @@ -1,11 +1,18 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator'; +import { + IsBoolean, + IsEnum, + IsNotEmpty, + IsOptional, + Length, +} from 'class-validator'; import { PageQueryDto } from '@src/common/dto/page-query.dto'; import { IsPositiveInt } from '@src/common/decorators/validators/is-positive-int.decorator'; -import { HelpMeBoardOrderField } from '@src/boards/constants/help-me-board-order-field.enum'; +import { HelpMeBoardOrderField } from '@src/boards/constants/help-me-board/help-me-board-order-field.enum'; import { SortOrder } from '@src/common/constants/sort-order.enum'; import { stringToBoolean } from '@src/common/decorators/transformer/string-to-boolean.transformer'; import { Transform } from 'class-transformer'; +import { HELP_ME_BOARD_HEAD_LENGTH } from '@src/boards/constants/help-me-board/help-me-board.constant'; export class HelpMeBoardPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ @@ -26,9 +33,11 @@ export class HelpMeBoardPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ description: '제목 필터링', + minLength: HELP_ME_BOARD_HEAD_LENGTH.MIN, + maxLength: HELP_ME_BOARD_HEAD_LENGTH.MAX, }) @IsOptional() - @IsNotEmpty() + @Length(HELP_ME_BOARD_HEAD_LENGTH.MIN, HELP_ME_BOARD_HEAD_LENGTH.MAX) head?: string; @ApiPropertyOptional({ diff --git a/src/boards/dto/helpMeBoard/help-me-board.dto.ts b/src/boards/dto/helpMeBoard/help-me-board.dto.ts index 949fb912..3fda007c 100644 --- a/src/boards/dto/helpMeBoard/help-me-board.dto.ts +++ b/src/boards/dto/helpMeBoard/help-me-board.dto.ts @@ -1,4 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; +import { HELP_ME_BOARD_HEAD_LENGTH } from '@src/boards/constants/help-me-board/help-me-board.constant'; import { HelpMeBoard } from '@src/entities/HelpMeBoard'; import { Exclude } from 'class-transformer'; @@ -22,7 +23,11 @@ export class HelpMeBoardDto }) userId: number; - @ApiProperty({ description: '도와주세요 게시판 글 제목' }) + @ApiProperty({ + description: '도와주세요 게시판 글 제목', + minLength: HELP_ME_BOARD_HEAD_LENGTH.MIN, + maxLength: HELP_ME_BOARD_HEAD_LENGTH.MAX, + }) head: string; @ApiProperty({ description: '도와주세요 게시판 글 내용' }) diff --git a/src/boards/dto/helpMeBoard/update.help.me.board.dto.ts b/src/boards/dto/helpMeBoard/update.help.me.board.dto.ts index b9cecbff..ab7c8a3b 100644 --- a/src/boards/dto/helpMeBoard/update.help.me.board.dto.ts +++ b/src/boards/dto/helpMeBoard/update.help.me.board.dto.ts @@ -1,7 +1,8 @@ -import { IsNumber, IsString } from 'class-validator'; +import { HELP_ME_BOARD_HEAD_LENGTH } from '@src/boards/constants/help-me-board/help-me-board.constant'; +import { IsNumber, IsString, Length } from 'class-validator'; export class UpdateHelpMeBoardDto { - @IsString() + @Length(HELP_ME_BOARD_HEAD_LENGTH.MIN, HELP_ME_BOARD_HEAD_LENGTH.MAX) head: string; @IsString() diff --git a/src/boards/dto/mentorBoard/create.mentor.board.dto.ts b/src/boards/dto/mentorBoard/create.mentor.board.dto.ts index f9eb8fef..c94c824c 100644 --- a/src/boards/dto/mentorBoard/create.mentor.board.dto.ts +++ b/src/boards/dto/mentorBoard/create.mentor.board.dto.ts @@ -1,7 +1,8 @@ -import { IsNumber, IsString } from 'class-validator'; +import { MENTOR_BOARD_HEAD_LENGTH } from '@src/boards/constants/mentor-board/mentor-board.constant'; +import { IsNumber, IsString, Length } from 'class-validator'; export class CreateMentorBoardDto { - @IsString() + @Length(MENTOR_BOARD_HEAD_LENGTH.MIN, MENTOR_BOARD_HEAD_LENGTH.MAX) head: string; @IsString() diff --git a/src/boards/dto/mentorBoard/mentor-board-page-query.dto.ts b/src/boards/dto/mentorBoard/mentor-board-page-query.dto.ts index c0300542..2c83a6da 100644 --- a/src/boards/dto/mentorBoard/mentor-board-page-query.dto.ts +++ b/src/boards/dto/mentorBoard/mentor-board-page-query.dto.ts @@ -1,12 +1,19 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator'; -import { MentorBoardOrderField } from '@src/boards/constants/mentor-board-order-field.enum'; +import { + IsBoolean, + IsEnum, + IsNotEmpty, + IsOptional, + Length, +} from 'class-validator'; +import { MentorBoardOrderField } from '@src/boards/constants/mentor-board/mentor-board-order-field.enum'; import { PageQueryDto } from '@src/common/dto/page-query.dto'; import { IsPositiveInt } from '@src/common/decorators/validators/is-positive-int.decorator'; import { SortOrder } from '@src/common/constants/sort-order.enum'; import { Transform } from 'class-transformer'; import { stringToBoolean } from '@src/common/decorators/transformer/string-to-boolean.transformer'; +import { MENTOR_BOARD_HEAD_LENGTH } from '@src/boards/constants/mentor-board/mentor-board.constant'; export class MentorBoardPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ @@ -27,9 +34,11 @@ export class MentorBoardPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ description: '제목 필터링', + minLength: MENTOR_BOARD_HEAD_LENGTH.MIN, + maxLength: MENTOR_BOARD_HEAD_LENGTH.MAX, }) @IsOptional() - @IsNotEmpty() + @Length(MENTOR_BOARD_HEAD_LENGTH.MIN, MENTOR_BOARD_HEAD_LENGTH.MAX) head?: string; @ApiPropertyOptional({ diff --git a/src/boards/dto/mentorBoard/mentor-board.dto.ts b/src/boards/dto/mentorBoard/mentor-board.dto.ts index 6d9a3578..5459c9f9 100644 --- a/src/boards/dto/mentorBoard/mentor-board.dto.ts +++ b/src/boards/dto/mentorBoard/mentor-board.dto.ts @@ -1,4 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; +import { MENTOR_BOARD_HEAD_LENGTH } from '@src/boards/constants/mentor-board/mentor-board.constant'; import { MentorBoard } from '@src/entities/MentorBoard'; import { Exclude } from 'class-transformer'; @@ -19,7 +20,11 @@ export class MentorBoardDto }) userId: number; - @ApiProperty({ description: '멘토 게시판 글 제목' }) + @ApiProperty({ + description: '멘토 게시판 글 제목', + minLength: MENTOR_BOARD_HEAD_LENGTH.MIN, + maxLength: MENTOR_BOARD_HEAD_LENGTH.MAX, + }) head: string; @ApiProperty({ description: '멘토 게시판 글 내용' }) diff --git a/src/boards/dto/mentorBoard/update.mentor.board.dto.ts b/src/boards/dto/mentorBoard/update.mentor.board.dto.ts index 6a361f04..7c56b08e 100644 --- a/src/boards/dto/mentorBoard/update.mentor.board.dto.ts +++ b/src/boards/dto/mentorBoard/update.mentor.board.dto.ts @@ -1,7 +1,8 @@ -import { IsNumber, IsString } from 'class-validator'; +import { MENTOR_BOARD_HEAD_LENGTH } from '@src/boards/constants/mentor-board/mentor-board.constant'; +import { IsNumber, IsString, Length } from 'class-validator'; export class UpdateMentorBoardDto { - @IsString() + @Length(MENTOR_BOARD_HEAD_LENGTH.MIN, MENTOR_BOARD_HEAD_LENGTH.MAX) head: string; @IsString() diff --git a/src/boards/repository/help.me.board.repository.ts b/src/boards/repository/help.me.board.repository.ts index 02c9ebfd..98c56376 100644 --- a/src/boards/repository/help.me.board.repository.ts +++ b/src/boards/repository/help.me.board.repository.ts @@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common'; import { SortOrder } from '@src/common/constants/sort-order.enum'; import { QueryBuilderHelper } from '@src/helpers/query-builder.helper'; import { HelpYouCommentOrderField } from '@src/comments/constants/help-you-comment-order-field.enum'; -import { HelpMeBoardOrderField } from '@src/boards/constants/help-me-board-order-field.enum'; +import { HelpMeBoardOrderField } from '@src/boards/constants/help-me-board/help-me-board-order-field.enum'; import { CreateHelpMeBoardDto } from '@src/boards/dto/helpMeBoard/create.help.me.board.dto'; import { UpdateHelpMeBoardDto } from '@src/boards/dto/helpMeBoard/update.help.me.board.dto'; import { HelpMeBoard } from '@src/entities/HelpMeBoard'; diff --git a/src/boards/repository/mentor.boards.repository.ts b/src/boards/repository/mentor.boards.repository.ts index f78d71ab..4110bbda 100644 --- a/src/boards/repository/mentor.boards.repository.ts +++ b/src/boards/repository/mentor.boards.repository.ts @@ -8,7 +8,7 @@ import { Injectable } from '@nestjs/common'; import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity'; import { QueryBuilderHelper } from '@src/helpers/query-builder.helper'; import { SortOrder } from '@src/common/constants/sort-order.enum'; -import { MentorBoardOrderField } from '@src/boards/constants/mentor-board-order-field.enum'; +import { MentorBoardOrderField } from '@src/boards/constants/mentor-board/mentor-board-order-field.enum'; import { CreateMentorBoardDto } from '@src/boards/dto/mentorBoard/create.mentor.board.dto'; import { MentorBoardDto } from '@src/boards/dto/mentorBoard/mentor-board.dto'; import { UpdateMentorBoardDto } from '@src/boards/dto/mentorBoard/update.mentor.board.dto'; diff --git a/src/category/dto/category-list.dto.ts b/src/category/dto/category.dto.ts similarity index 100% rename from src/category/dto/category-list.dto.ts rename to src/category/dto/category.dto.ts diff --git a/src/category/services/category.service.ts b/src/category/services/category.service.ts index 46446d90..55def158 100644 --- a/src/category/services/category.service.ts +++ b/src/category/services/category.service.ts @@ -1,5 +1,5 @@ import { Injectable, NotFoundException } from '@nestjs/common'; -import { CategoryDto } from '@src/category/dto/category-list.dto'; +import { CategoryDto } from '@src/category/dto/category.dto'; import { CategoryRepository } from '@src/category/repositories/category.repository'; @Injectable() diff --git a/src/common/types/order-field-for-helper.type.ts b/src/common/types/order-field-for-helper.type.ts index dc298f68..45644aa4 100644 --- a/src/common/types/order-field-for-helper.type.ts +++ b/src/common/types/order-field-for-helper.type.ts @@ -1,6 +1,6 @@ import { BannedUserOrderField } from '@src/admins/banned-user/constants/banned-user-order-field.enum'; -import { HelpMeBoardOrderField } from '@src/boards/constants/help-me-board-order-field.enum'; -import { MentorBoardOrderField } from '@src/boards/constants/mentor-board-order-field.enum'; +import { HelpMeBoardOrderField } from '@src/boards/constants/help-me-board/help-me-board-order-field.enum'; +import { MentorBoardOrderField } from '@src/boards/constants/mentor-board/mentor-board-order-field.enum'; import { HelpYouCommentOrderField } from '@src/comments/constants/help-you-comment-order-field.enum'; import { MentorOrderField } from '@src/mentors/constants/mentor-order-field.enum'; diff --git a/src/entities/HelpMeBoard.ts b/src/entities/HelpMeBoard.ts index 26ff7ec4..c826ca5b 100644 --- a/src/entities/HelpMeBoard.ts +++ b/src/entities/HelpMeBoard.ts @@ -43,7 +43,7 @@ export class HelpMeBoard { @Column('varchar', { name: 'head', comment: '도와주세요 게시글 제목', - length: 30, + length: 50, }) head: string; diff --git a/src/entities/MentorBoard.ts b/src/entities/MentorBoard.ts index dda5d0ac..e2806e9d 100644 --- a/src/entities/MentorBoard.ts +++ b/src/entities/MentorBoard.ts @@ -40,7 +40,7 @@ export class MentorBoard { }) categoryId: number; - @Column('varchar', { name: 'head', comment: '멘토 게시글 제목', length: 30 }) + @Column('varchar', { name: 'head', comment: '멘토 게시글 제목', length: 50 }) head: string; @Column('text', { name: 'body', comment: '멘토 게시글 본문' }) diff --git a/src/mentors/dtos/mentor-list-page-query.dto.ts b/src/mentors/dtos/mentor-list-page-query.dto.ts index 92988ee3..f596ed4f 100644 --- a/src/mentors/dtos/mentor-list-page-query.dto.ts +++ b/src/mentors/dtos/mentor-list-page-query.dto.ts @@ -1,10 +1,11 @@ import { PageQueryDto } from '@src/common/dto/page-query.dto'; import { SortOrder } from '@src/common/constants/sort-order.enum'; import { ApiPropertyOptional } from '@nestjs/swagger'; -import { IsEnum, IsNotEmpty, IsOptional } from 'class-validator'; +import { IsEnum, IsOptional, Length } from 'class-validator'; import { IsPositiveInt } from '@src/common/decorators/validators/is-positive-int.decorator'; import { MentorOrderField } from '@src/mentors/constants/mentor-order-field.enum'; import { User } from '@src/entities/User'; +import { USER_NAME_LENGTH } from '@src/users/constants/user.constant'; export class MentorListPageQueryDto extends PageQueryDto @@ -20,9 +21,11 @@ export class MentorListPageQueryDto @ApiPropertyOptional({ description: '멘토 이름 필터링', + minLength: USER_NAME_LENGTH.MIN, + maxLength: USER_NAME_LENGTH.MAX, }) @IsOptional() - @IsNotEmpty() + @Length(USER_NAME_LENGTH.MIN, USER_NAME_LENGTH.MAX) name?: string; @ApiPropertyOptional({ diff --git a/src/mentors/dtos/user-intro-response.dto.ts b/src/mentors/dtos/user-intro-response.dto.ts index 0730732d..6109703a 100644 --- a/src/mentors/dtos/user-intro-response.dto.ts +++ b/src/mentors/dtos/user-intro-response.dto.ts @@ -1,16 +1,24 @@ import { ApiProperty } from '@nestjs/swagger'; import { UserIntro } from '@src/entities/UserIntro'; +import { + USER_CUSTOM_CATEGORY_LENGTH, + USER_SHORT_INTRO_LENGTH, +} from '@src/users/constants/user.constant'; export class UserIntroResponseDto implements Pick { @ApiProperty({ description: '멘토 짧은 소개', + minLength: USER_SHORT_INTRO_LENGTH.MIN, + maxLength: USER_SHORT_INTRO_LENGTH.MAX, }) shortIntro: string; @ApiProperty({ description: '멘토 커스텀 카테고리', + minLength: USER_CUSTOM_CATEGORY_LENGTH.MIN, + maxLength: USER_CUSTOM_CATEGORY_LENGTH.MAX, }) customCategory: string; } diff --git a/src/mentors/dtos/user-with-image-and-intro.dto.ts b/src/mentors/dtos/user-with-image-and-intro.dto.ts index 6d1629e4..14fa6e13 100644 --- a/src/mentors/dtos/user-with-image-and-intro.dto.ts +++ b/src/mentors/dtos/user-with-image-and-intro.dto.ts @@ -2,6 +2,7 @@ import { ApiProperty, PickType } from '@nestjs/swagger'; import { Exclude } from 'class-transformer'; import { UserForJoinDto } from '@src/users/dtos/user-for-join.dto'; import { UserIntroResponseDto } from '@src/mentors/dtos/user-intro-response.dto'; +import { USER_NAME_LENGTH } from '@src/users/constants/user.constant'; export class UserWithImageAndIntroDto extends PickType(UserForJoinDto, [ 'userImage', @@ -14,6 +15,8 @@ export class UserWithImageAndIntroDto extends PickType(UserForJoinDto, [ @ApiProperty({ description: '유저 이름', + minLength: USER_NAME_LENGTH.MIN, + maxLength: USER_NAME_LENGTH.MAX, }) name: string; @@ -22,6 +25,7 @@ export class UserWithImageAndIntroDto extends PickType(UserForJoinDto, [ @ApiProperty({ description: '유저 랭크', + format: 'integer', }) rank: number; @@ -32,11 +36,13 @@ export class UserWithImageAndIntroDto extends PickType(UserForJoinDto, [ @ApiProperty({ description: '멘토 리뷰 후기 당한 개수', + format: 'integer', }) mentorReviewCount: number; @ApiProperty({ description: '멘토 게시판 글쓴 갯수', + format: 'integer', }) mentorBoardCount: number; diff --git a/src/mentors/mentor-reviews/constants/mentor-review.constant.ts b/src/mentors/mentor-reviews/constants/mentor-review.constant.ts new file mode 100644 index 00000000..ce8b842c --- /dev/null +++ b/src/mentors/mentor-reviews/constants/mentor-review.constant.ts @@ -0,0 +1,4 @@ +export const MENTOR_REVIEW_REVIEW_LENGTH = { + MIN: 1, + MAX: 200, +} as const; diff --git a/src/mentors/mentor-reviews/dtos/create-mentor-review-request-body.dto.ts b/src/mentors/mentor-reviews/dtos/create-mentor-review-request-body.dto.ts index a138d741..f5d0eadb 100644 --- a/src/mentors/mentor-reviews/dtos/create-mentor-review-request-body.dto.ts +++ b/src/mentors/mentor-reviews/dtos/create-mentor-review-request-body.dto.ts @@ -1,9 +1,10 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { IsNotEmpty, IsOptional, ValidateNested } from 'class-validator'; +import { IsOptional, Length, ValidateNested } from 'class-validator'; import { Type } from 'class-transformer'; import { IsNotEmptyObjectAndAllFalse } from '@src/common/decorators/validators/is-not-empty-object-and-all-false.decorator'; import { MentorReviewDto } from '@src/mentors/mentor-reviews/dtos/mentor-review.dto'; import { CreateMentorReviewChecklistRequestBodyDto } from '@src/mentors/mentor-reviews/dtos/create-mentor-review-checklist-request-body.dto'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; export class CreateMentorReviewRequestBodyDto implements Partial @@ -19,8 +20,10 @@ export class CreateMentorReviewRequestBodyDto @ApiPropertyOptional({ description: '멘토 리뷰 내용', + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) @IsOptional() - @IsNotEmpty() + @Length(MENTOR_REVIEW_REVIEW_LENGTH.MIN, MENTOR_REVIEW_REVIEW_LENGTH.MAX) review?: string; } diff --git a/src/mentors/mentor-reviews/dtos/mentor-review-page-query-dto.ts b/src/mentors/mentor-reviews/dtos/mentor-review-page-query-dto.ts index 0d958019..b5dfea66 100644 --- a/src/mentors/mentor-reviews/dtos/mentor-review-page-query-dto.ts +++ b/src/mentors/mentor-reviews/dtos/mentor-review-page-query-dto.ts @@ -1,17 +1,19 @@ import { ApiPropertyOptional } from '@nestjs/swagger'; -import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator'; +import { IsBoolean, IsEnum, IsOptional, Length } from 'class-validator'; import { PageQueryDto } from '@src/common/dto/page-query.dto'; import { SortOrder } from '@src/common/constants/sort-order.enum'; import { IsPositiveInt } from '@src/common/decorators/validators/is-positive-int.decorator'; import { MentorReviewOrderField } from '@src/mentors/mentor-reviews/constants/mentor-review-order-field.enum'; import { Transform } from 'class-transformer'; import { stringToBoolean } from '@src/common/decorators/transformer/string-to-boolean.transformer'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; export class MentorReviewPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ description: '리뷰 고유 ID 필터링', format: 'integer', + minimum: 1, }) @IsOptional() @IsPositiveInt() @@ -20,6 +22,7 @@ export class MentorReviewPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ description: '멘티 고유 ID 필터링', format: 'integer', + minimum: 1, }) @IsOptional() @IsPositiveInt() @@ -107,9 +110,11 @@ export class MentorReviewPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ description: '리뷰 내용 필터링', + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) @IsOptional() - @IsNotEmpty() + @Length(MENTOR_REVIEW_REVIEW_LENGTH.MIN, MENTOR_REVIEW_REVIEW_LENGTH.MAX) review?: string; @ApiPropertyOptional({ diff --git a/src/mentors/mentor-reviews/dtos/mentor-review.dto.ts b/src/mentors/mentor-reviews/dtos/mentor-review.dto.ts index 03ec4eb6..bbf42c25 100644 --- a/src/mentors/mentor-reviews/dtos/mentor-review.dto.ts +++ b/src/mentors/mentor-reviews/dtos/mentor-review.dto.ts @@ -1,5 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { MentorReview } from '@src/entities/MentorReview'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; import { Exclude } from 'class-transformer'; export class MentorReviewDto @@ -30,6 +31,8 @@ export class MentorReviewDto description: '멘티가 작성한 리뷰', nullable: true, type: () => String, + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) review: string | null; diff --git a/src/mentors/mentor-reviews/dtos/mentor-reviews-item-response.dto.ts b/src/mentors/mentor-reviews/dtos/mentor-reviews-item-response.dto.ts index ea7d9571..c06e9924 100644 --- a/src/mentors/mentor-reviews/dtos/mentor-reviews-item-response.dto.ts +++ b/src/mentors/mentor-reviews/dtos/mentor-reviews-item-response.dto.ts @@ -1,7 +1,14 @@ import { ApiProperty } from '@nestjs/swagger'; import { UserImage } from '@src/entities/UserImage'; import { UserIntro } from '@src/entities/UserIntro'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; import { MentorReviewDto } from '@src/mentors/mentor-reviews/dtos/mentor-review.dto'; +import { + USER_CAREER_LENGTH, + USER_CUSTOM_CATEGORY_LENGTH, + USER_NAME_LENGTH, + USER_SHORT_INTRO_LENGTH, +} from '@src/users/constants/user.constant'; import { UserInfoDto } from '@src/users/dtos/user-info.dto'; import { Exclude } from 'class-transformer'; @@ -17,16 +24,22 @@ class UserIntroDto { @ApiProperty({ description: '커스텀 카테고리', + minLength: USER_CUSTOM_CATEGORY_LENGTH.MIN, + maxLength: USER_CUSTOM_CATEGORY_LENGTH.MAX, }) customCategory: string; @ApiProperty({ description: '유저 커리어', + minLength: USER_CAREER_LENGTH.MIN, + maxLength: USER_CAREER_LENGTH.MAX, }) career: string; @ApiProperty({ description: '멘토 소개', + minLength: USER_SHORT_INTRO_LENGTH.MIN, + maxLength: USER_SHORT_INTRO_LENGTH.MAX, }) shortIntro: string; } @@ -40,16 +53,19 @@ class Mentee implements Pick { @ApiProperty({ description: '유저 이름', + minLength: USER_NAME_LENGTH.MIN, + maxLength: USER_NAME_LENGTH.MAX, }) name: string; @ApiProperty({ description: '유저 랭크', + format: 'integer', }) rank: number; @ApiProperty({ - description: '유저 랭크', + description: '유저 이미지 객체', }) userImage: UserImageDto; @@ -80,6 +96,8 @@ export class MentorReviewsItemResponseDto description: '멘티가 작성한 리뷰', nullable: true, type: () => String, + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) review: string | null; diff --git a/src/mentors/mentor-reviews/dtos/patch-update-mentor-review.dto.ts b/src/mentors/mentor-reviews/dtos/patch-update-mentor-review.dto.ts index 86211603..6b99ab09 100644 --- a/src/mentors/mentor-reviews/dtos/patch-update-mentor-review.dto.ts +++ b/src/mentors/mentor-reviews/dtos/patch-update-mentor-review.dto.ts @@ -1,8 +1,9 @@ import { ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; -import { IsNotEmpty, IsOptional, ValidateNested } from 'class-validator'; +import { IsOptional, Length, ValidateNested } from 'class-validator'; import { IsNotEmptyObjectAndAllFalse } from '@src/common/decorators/validators/is-not-empty-object-and-all-false.decorator'; import { CreateMentorReviewChecklistRequestBodyDto } from '@src/mentors/mentor-reviews/dtos/create-mentor-review-checklist-request-body.dto'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; export class PatchUpdateMentorReviewDto { @ApiPropertyOptional({ @@ -17,8 +18,10 @@ export class PatchUpdateMentorReviewDto { @ApiPropertyOptional({ description: '멘토 리뷰 내용', + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) @IsOptional() - @IsNotEmpty() + @Length(MENTOR_REVIEW_REVIEW_LENGTH.MIN, MENTOR_REVIEW_REVIEW_LENGTH.MAX) review?: string; } diff --git a/src/mentors/repositories/mentor.repository.ts b/src/mentors/repositories/mentor.repository.ts index 8dfd1c8e..9180a5bb 100644 --- a/src/mentors/repositories/mentor.repository.ts +++ b/src/mentors/repositories/mentor.repository.ts @@ -33,16 +33,16 @@ export class MentorRepository { .createQueryBuilder('user') .innerJoin('user.userImage', 'userImage') .innerJoin('user.userIntro', 'userIntro') - .leftJoin('user.mentor', 'mentor') - .leftJoin('user.mentorBoard', 'mentorBoard') + .leftJoin('user.reviewed', 'reviewed') + .leftJoin('user.mentorBoards', 'mentorBoards') .select([ 'user.id as id', 'user.name as name', 'user.rank as user_rank', 'JSON_OBJECT("imageUrl", userImage.imageUrl) as userImage', 'JSON_OBJECT("shortIntro", userIntro.shortIntro, "customCategory", userIntro.customCategory) as userIntro', - 'COUNT(DISTINCT mentor.id) as mentorReviewCount', - 'COUNT(DISTINCT mentorBoard.id) as mentorBoardCount', + 'COUNT(DISTINCT reviewed.id) as mentorReviewCount', + 'COUNT(DISTINCT mentorBoards.id) as mentorBoardCount', ]) .where('user.isMentor = true'); diff --git a/src/migrations/__utils/util.ts b/src/migrations/__utils/util.ts index a5c48e98..74d9e749 100644 --- a/src/migrations/__utils/util.ts +++ b/src/migrations/__utils/util.ts @@ -45,7 +45,7 @@ export const generateHeadColumn = ( return { name: 'head', type: 'varchar', - length: '30', + length: '50', isNullable: false, comment, }; diff --git a/src/reports/constants/report.constant.ts b/src/reports/constants/report.constant.ts index f6e32afd..af534891 100644 --- a/src/reports/constants/report.constant.ts +++ b/src/reports/constants/report.constant.ts @@ -1,4 +1,4 @@ export const REPORT_REASON_LENGTH = { MIN: 1, - MAX: 255, + MAX: 200, } as const; diff --git a/src/search/dtos/search-all-help-me-board.dto.ts b/src/search/dtos/search-all-help-me-board.dto.ts index b11ff298..2d9161bc 100644 --- a/src/search/dtos/search-all-help-me-board.dto.ts +++ b/src/search/dtos/search-all-help-me-board.dto.ts @@ -3,6 +3,7 @@ import { Exclude } from 'class-transformer'; import { SearchUserDto } from '@src/search/dtos/search-user-dto'; import { HelpMeBoard } from '@src/entities/HelpMeBoard'; import { Category } from '@src/entities/Category'; +import { HELP_ME_BOARD_HEAD_LENGTH } from '@src/boards/constants/help-me-board/help-me-board.constant'; export class SearchAllHelpMeBoardDto implements @@ -26,6 +27,8 @@ export class SearchAllHelpMeBoardDto @ApiProperty({ description: '도와주세요 게시글 제목', + minLength: HELP_ME_BOARD_HEAD_LENGTH.MIN, + maxLength: HELP_ME_BOARD_HEAD_LENGTH.MAX, }) head: string; diff --git a/src/search/dtos/search-all-mentor.dto.ts b/src/search/dtos/search-all-mentor.dto.ts index 4817ee91..ce5b4cfe 100644 --- a/src/search/dtos/search-all-mentor.dto.ts +++ b/src/search/dtos/search-all-mentor.dto.ts @@ -2,6 +2,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { User } from '@src/entities/User'; import { UserImage } from '@src/entities/UserImage'; import { UserIntro } from '@src/entities/UserIntro'; +import { USER_NAME_LENGTH } from '@src/users/constants/user.constant'; export class SearchAllMentorDto implements Pick @@ -13,6 +14,8 @@ export class SearchAllMentorDto @ApiProperty({ description: '멘토 유저 이름', + minLength: USER_NAME_LENGTH.MIN, + maxLength: USER_NAME_LENGTH.MAX, }) name: string; diff --git a/src/search/dtos/search-user-dto.ts b/src/search/dtos/search-user-dto.ts index 5001e762..6c693516 100644 --- a/src/search/dtos/search-user-dto.ts +++ b/src/search/dtos/search-user-dto.ts @@ -1,6 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { User } from '@src/entities/User'; import { UserImage } from '@src/entities/UserImage'; +import { USER_NAME_LENGTH } from '@src/users/constants/user.constant'; export class SearchUserDto implements Pick { @ApiProperty({ @@ -11,6 +12,8 @@ export class SearchUserDto implements Pick { @ApiProperty({ description: '작성자 이름', + minLength: USER_NAME_LENGTH.MIN, + maxLength: USER_NAME_LENGTH.MAX, }) name: string; diff --git a/src/users/constants/user.constant.ts b/src/users/constants/user.constant.ts new file mode 100644 index 00000000..c481847e --- /dev/null +++ b/src/users/constants/user.constant.ts @@ -0,0 +1,39 @@ +export const USER_NAME_LENGTH = { + MIN: 1, + MAX: 20, +} as const; + +export const USER_SHORT_INTRO_LENGTH = { + MIN: 1, + MAX: 50, +} as const; + +export const USER_CUSTOM_CATEGORY_LENGTH = { + MIN: 1, + MAX: 200, +} as const; + +export const USER_CAREER_LENGTH = { + MIN: 1, + MAX: 200, +} as const; + +export const USER_DETAIL_LENGTH = { + MIN: 1, + MAX: 200, +} as const; + +export const USER_PORTFOLIO_LENGTH = { + MIN: 1, + MAX: 100, +} as const; + +export const USER_SNS_LENGTH = { + MIN: 1, + MAX: 100, +} as const; + +export const USER_EMAIL_LENGTH = { + MIN: 1, + MAX: 50, +} as const; diff --git a/src/users/dtos/create-user.dto.ts b/src/users/dtos/create-user.dto.ts index 124ff05d..11cc4c3d 100644 --- a/src/users/dtos/create-user.dto.ts +++ b/src/users/dtos/create-user.dto.ts @@ -1,9 +1,10 @@ +import { UserProvider } from '@src/auth/enums/user-provider.enum'; import { UserRole } from '@src/users/constants/user-role.enum'; -import { IsBoolean, IsEmail, IsString } from 'class-validator'; +import { IsBoolean, IsEmail, IsEnum, IsString } from 'class-validator'; export class CreateUserDto { - @IsString() - readonly provider: string; + @IsEnum(UserProvider) + readonly provider: UserProvider; @IsString() readonly name: string; diff --git a/src/users/dtos/get-my-intro.dto.ts b/src/users/dtos/get-my-intro.dto.ts index 71922db0..09aa63d8 100644 --- a/src/users/dtos/get-my-intro.dto.ts +++ b/src/users/dtos/get-my-intro.dto.ts @@ -1,5 +1,13 @@ import { ApiProperty } from '@nestjs/swagger'; import { UserIntro } from '@src/entities/UserIntro'; +import { + USER_CAREER_LENGTH, + USER_CUSTOM_CATEGORY_LENGTH, + USER_DETAIL_LENGTH, + USER_PORTFOLIO_LENGTH, + USER_SHORT_INTRO_LENGTH, + USER_SNS_LENGTH, +} from '@src/users/constants/user.constant'; import { Exclude } from 'class-transformer'; export class MyIntroDto implements Omit { @@ -11,31 +19,43 @@ export class MyIntroDto implements Omit { @ApiProperty({ description: '커스텀 카테고리', + minLength: USER_CUSTOM_CATEGORY_LENGTH.MIN, + maxLength: USER_CUSTOM_CATEGORY_LENGTH.MAX, }) customCategory: string; @ApiProperty({ description: '한 줄 소개', + minLength: USER_SHORT_INTRO_LENGTH.MIN, + maxLength: USER_SHORT_INTRO_LENGTH.MAX, }) shortIntro: string; @ApiProperty({ description: '경력', + minLength: USER_CAREER_LENGTH.MIN, + maxLength: USER_CAREER_LENGTH.MAX, }) career: string; @ApiProperty({ description: '세부 사항', + minLength: USER_DETAIL_LENGTH.MIN, + maxLength: USER_DETAIL_LENGTH.MAX, }) detail: string; @ApiProperty({ description: '포트폴리오', + minLength: USER_PORTFOLIO_LENGTH.MIN, + maxLength: USER_PORTFOLIO_LENGTH.MAX, }) portfolio: string; @ApiProperty({ description: 'SNS', + minLength: USER_SNS_LENGTH.MIN, + maxLength: USER_SNS_LENGTH.MAX, }) sns: string; diff --git a/src/users/dtos/update-user-intro-dto.ts b/src/users/dtos/update-user-intro-dto.ts index 0ea6f806..b1e02b7a 100644 --- a/src/users/dtos/update-user-intro-dto.ts +++ b/src/users/dtos/update-user-intro-dto.ts @@ -1,54 +1,75 @@ -import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { IsBoolean, IsNumber, IsOptional, IsString } from 'class-validator'; +import { ApiPropertyOptional } from '@nestjs/swagger'; +import { IsPositiveInt } from '@src/common/decorators/validators/is-positive-int.decorator'; +import { + USER_CAREER_LENGTH, + USER_CUSTOM_CATEGORY_LENGTH, + USER_DETAIL_LENGTH, + USER_PORTFOLIO_LENGTH, + USER_SHORT_INTRO_LENGTH, + USER_SNS_LENGTH, +} from '@src/users/constants/user.constant'; +import { IsBoolean, IsOptional, Length } from 'class-validator'; export class UpdateUserIntroDTO { @ApiPropertyOptional({ example: '안녕하세요', description: '한 줄 소개', + minLength: USER_SHORT_INTRO_LENGTH.MIN, + maxLength: USER_SHORT_INTRO_LENGTH.MAX, }) @IsOptional() - @IsString() + @Length(USER_SHORT_INTRO_LENGTH.MIN, USER_SHORT_INTRO_LENGTH.MAX) shortIntro?: string; @ApiPropertyOptional({ example: '숨쉬기 경력 20년', description: '경력', + minLength: USER_CAREER_LENGTH.MIN, + maxLength: USER_CAREER_LENGTH.MAX, }) @IsOptional() - @IsString() + @Length(USER_CAREER_LENGTH.MIN, USER_CAREER_LENGTH.MAX) career?: string; @ApiPropertyOptional({ example: '코로 숨쉬기, 입으로 숨쉬기', description: '커스텀 카테고리', + minLength: USER_CUSTOM_CATEGORY_LENGTH.MIN, + maxLength: USER_CUSTOM_CATEGORY_LENGTH.MAX, }) @IsOptional() - @IsString() + @Length(USER_CUSTOM_CATEGORY_LENGTH.MIN, USER_CUSTOM_CATEGORY_LENGTH.MAX) customCategory?: string; @ApiPropertyOptional({ example: '안녕하세요. 저는 트위치에서 방송을 하고 있는 스트리머 케인입니다.', description: '상세 소개(옵션)', + minLength: USER_DETAIL_LENGTH.MIN, + maxLength: USER_DETAIL_LENGTH.MAX, }) @IsOptional() - @IsString() + @Length(USER_DETAIL_LENGTH.MIN, USER_DETAIL_LENGTH.MAX) detail?: string; @ApiPropertyOptional({ example: 'https://www.naver.com', description: '포트폴리오 링크', + minLength: USER_PORTFOLIO_LENGTH.MIN, + maxLength: USER_PORTFOLIO_LENGTH.MAX, }) @IsOptional() - @IsString() + @Length(USER_PORTFOLIO_LENGTH.MIN, USER_PORTFOLIO_LENGTH.MAX) portfolio?: string; @ApiPropertyOptional({ example: 'https://www.naver.com', description: 'sns 링크', + minLength: USER_SNS_LENGTH.MIN, + maxLength: USER_SNS_LENGTH.MAX, }) @IsOptional() - @IsString() + @Length(USER_SNS_LENGTH.MIN, USER_SNS_LENGTH.MAX) sns?: string; @ApiPropertyOptional({ @@ -56,7 +77,7 @@ export class UpdateUserIntroDTO { description: '희망 카테고리 id', }) @IsOptional() - @IsNumber() + @IsPositiveInt() hopeCategoryId?: number; @ApiPropertyOptional({ @@ -64,7 +85,7 @@ export class UpdateUserIntroDTO { description: '활동 카테고리 id', }) @IsOptional() - @IsNumber() + @IsPositiveInt() activityCategoryId?: number; @ApiPropertyOptional({ diff --git a/src/users/dtos/user-info.dto.ts b/src/users/dtos/user-info.dto.ts index 98ac7e43..8f0b1936 100644 --- a/src/users/dtos/user-info.dto.ts +++ b/src/users/dtos/user-info.dto.ts @@ -4,6 +4,10 @@ import { UserStatus } from '@src/users/constants/user-status.enum'; import { UserProvider } from '@src/auth/enums/user-provider.enum'; import { UserRole } from '@src/users/constants/user-role.enum'; import { User } from '@src/entities/User'; +import { + USER_EMAIL_LENGTH, + USER_NAME_LENGTH, +} from '@src/users/constants/user.constant'; export class UserInfoDto implements @@ -33,16 +37,23 @@ export class UserInfoDto { @ApiProperty({ description: '유저 아이디', + format: 'integer', + minLength: 1, }) id: number; @ApiProperty({ - description: '이름', + description: '유저 이름', + minLength: USER_NAME_LENGTH.MIN, + maxLength: USER_NAME_LENGTH.MAX, }) name: string; @ApiProperty({ - description: '이메일', + description: '유저 이메일', + format: 'email', + minLength: USER_EMAIL_LENGTH.MIN, + maxLength: USER_EMAIL_LENGTH.MAX, }) email: string; @@ -59,22 +70,29 @@ export class UserInfoDto @ApiProperty({ description: '희망 카테고리 id', + format: 'integer', + minimum: 1, }) hopeCategoryId: number; @ApiProperty({ description: '활동 카테고리 id', + format: 'integer', + minimum: 1, }) activityCategoryId: number; @ApiProperty({ - description: '점수', + description: '등급', + format: 'integer', + minimum: 1, }) rank: number; @ApiProperty({ description: '휴대폰 인증 여부', nullable: true, + type: () => String, }) phone: string | null;