Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify/#325/add constrants #326

Merged
merged 26 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9855377
conflict(#325): resolve conflict
hobiJeong Mar 7, 2024
edccc42
refactor(#325): modify folder route
hobiJeong Mar 7, 2024
e99e92b
refactor(#325): modify banned user reason length constraint
hobiJeong Mar 7, 2024
4da821d
modify(#325): setting constraints with the banned user constant
hobiJeong Mar 7, 2024
578f305
refactor(#325): add help me board head constrant
hobiJeong Mar 7, 2024
54f18d8
refactor(#325): add mentor board head constrant
hobiJeong Mar 7, 2024
a467823
modify(#325): setting constraints with help me board constant
hobiJeong Mar 7, 2024
b960320
modify(#325): setting constraints with help me board constant
hobiJeong Mar 7, 2024
53924c5
modify(#325): setting constraints with mentor board constant
hobiJeong Mar 7, 2024
80e7c08
refactor(#325): modify folder route
hobiJeong Mar 7, 2024
8353f04
refactor(#325): modify folder route
hobiJeong Mar 7, 2024
c12eb1a
refactor(#325): modify folder route
hobiJeong Mar 7, 2024
deee59b
refactor(#325): modify folder route
hobiJeong Mar 7, 2024
6862ddf
refactor(#325): add user constrant
hobiJeong Mar 7, 2024
e094445
refactor(#325): setting constraints with user constant
hobiJeong Mar 7, 2024
a2882d5
modify(#325): setting constraints with help me board constant
hobiJeong Mar 7, 2024
26bbcd5
modify(#325): add report reason length constraint
hobiJeong Mar 7, 2024
a9f37a3
modify(#325): add mentor review length constraint
hobiJeong Mar 7, 2024
73a9889
modify(#325): setting constraints with mentor review constant
hobiJeong Mar 7, 2024
6818be0
conflict(#325): resolve conflict
hobiJeong Mar 8, 2024
1b21616
refactor(#325): modify help me board constranits
hobiJeong Mar 8, 2024
a0f9ee3
refactor(#325): modify mentor board constranits
hobiJeong Mar 8, 2024
4404432
refactor(#325): modify help me board constranits
hobiJeong Mar 8, 2024
9bbdc6e
refactor(#325): modify help me board constranits
hobiJeong Mar 8, 2024
1da660f
bugfix(#325): modify entity's field name in query
hobiJeong Mar 8, 2024
3f7cbc6
setting(#325): modify head length constraint
hobiJeong Mar 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/admins/banned-user/constants/banned-user.constant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const BANNED_USER_REASON_LENGTH = {
MIN: 1,
MAX: 255,
MAX: 200,
} as const;
4 changes: 2 additions & 2 deletions src/admins/banned-user/dtos/create-banned-user-body.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 8 additions & 0 deletions src/boards/constants/mentor-board/mentor-board.constant.ts
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 3 additions & 2 deletions src/boards/dto/helpMeBoard/create.help.me.board.dto.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
15 changes: 12 additions & 3 deletions src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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({
Expand Down
7 changes: 6 additions & 1 deletion src/boards/dto/helpMeBoard/help-me-board.dto.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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: '도와주세요 게시판 글 내용' })
Expand Down
5 changes: 3 additions & 2 deletions src/boards/dto/helpMeBoard/update.help.me.board.dto.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
5 changes: 3 additions & 2 deletions src/boards/dto/mentorBoard/create.mentor.board.dto.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
15 changes: 12 additions & 3 deletions src/boards/dto/mentorBoard/mentor-board-page-query.dto.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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({
Expand Down
7 changes: 6 additions & 1 deletion src/boards/dto/mentorBoard/mentor-board.dto.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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: '멘토 게시판 글 내용' })
Expand Down
5 changes: 3 additions & 2 deletions src/boards/dto/mentorBoard/update.mentor.board.dto.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/boards/repository/help.me.board.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/boards/repository/mentor.boards.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/category/services/category.service.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/common/types/order-field-for-helper.type.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/entities/HelpMeBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class HelpMeBoard {
@Column('varchar', {
name: 'head',
comment: '도와주세요 게시글 제목',
length: 30,
length: 50,
})
head: string;

Expand Down
2 changes: 1 addition & 1 deletion src/entities/MentorBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '멘토 게시글 본문' })
Expand Down
7 changes: 5 additions & 2 deletions src/mentors/dtos/mentor-list-page-query.dto.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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({
Expand Down
8 changes: 8 additions & 0 deletions src/mentors/dtos/user-intro-response.dto.ts
Original file line number Diff line number Diff line change
@@ -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<UserIntro, 'shortIntro' | 'customCategory'>
{
@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;
}
6 changes: 6 additions & 0 deletions src/mentors/dtos/user-with-image-and-intro.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -14,6 +15,8 @@ export class UserWithImageAndIntroDto extends PickType(UserForJoinDto, [

@ApiProperty({
description: '유저 이름',
minLength: USER_NAME_LENGTH.MIN,
maxLength: USER_NAME_LENGTH.MAX,
})
name: string;

Expand All @@ -22,6 +25,7 @@ export class UserWithImageAndIntroDto extends PickType(UserForJoinDto, [

@ApiProperty({
description: '유저 랭크',
format: 'integer',
})
rank: number;

Expand All @@ -32,11 +36,13 @@ export class UserWithImageAndIntroDto extends PickType(UserForJoinDto, [

@ApiProperty({
description: '멘토 리뷰 후기 당한 개수',
format: 'integer',
})
mentorReviewCount: number;

@ApiProperty({
description: '멘토 게시판 글쓴 갯수',
format: 'integer',
})
mentorBoardCount: number;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const MENTOR_REVIEW_REVIEW_LENGTH = {
MIN: 1,
MAX: 200,
} as const;
Original file line number Diff line number Diff line change
@@ -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<MentorReviewDto>
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -20,6 +22,7 @@ export class MentorReviewPageQueryDto extends PageQueryDto {
@ApiPropertyOptional({
description: '멘티 고유 ID 필터링',
format: 'integer',
minimum: 1,
})
@IsOptional()
@IsPositiveInt()
Expand Down Expand Up @@ -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({
Expand Down
Loading