-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from BookJamm/feat/35-report-user
✨ [Feat]: 사용자 신고 API 구현
- Loading branch information
Showing
19 changed files
with
207 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; | ||
import { BaseException } from 'src/global/base/base-exception'; | ||
import { UserResponseCode } from 'src/user/exception/user-response-code'; | ||
import { UserService } from 'src/user/user.service'; | ||
|
||
@Injectable() | ||
export class UserExistsValidationPipe implements PipeTransform { | ||
constructor(private readonly userService: UserService) {} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
async transform(value: number, metadata: ArgumentMetadata) { | ||
const isValid = await this.userService.isUserExists(value); | ||
if (!isValid) { | ||
throw BaseException.of(UserResponseCode.USER_NOT_FOUND); | ||
} | ||
|
||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsEnum, IsNotEmpty } from 'class-validator'; | ||
import { UserReportReason } from 'src/user/enum/user-report-reason'; | ||
|
||
export class ReportUserReqeust { | ||
@ApiProperty({ description: '신고 사유', enum: Object.keys(UserReportReason) }) | ||
@IsNotEmpty({ message: '신고 사유는 필수입니다.' }) | ||
@IsEnum(UserReportReason, { | ||
message: `신고 사유는 ${Object.keys(UserReportReason)} 중 하나입니다.`, | ||
}) | ||
readonly reason: string; | ||
} |
2 changes: 1 addition & 1 deletion
2
src/user/dto/sign-up-request.dto.ts → src/user/dto/reqeust/sign-up-request.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class ReportUserResponse { | ||
@ApiProperty({ description: '신고 당한 사용자의 아이디', example: 1 }) | ||
reportedUserId: number; | ||
@ApiProperty({ description: '신고 시간', example: new Date() }) | ||
reportedAt: Date; | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { BaseEntity } from 'src/global/base/base.entity'; | ||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; | ||
import { User } from './user.entity'; | ||
|
||
@Entity('user_reports') | ||
export class UserReport extends BaseEntity { | ||
@PrimaryGeneratedColumn() | ||
reportId: number; | ||
|
||
@Column() | ||
reason: string; | ||
|
||
@ManyToOne(() => User, user => user.userId) | ||
@JoinColumn({ name: 'reporter_id', referencedColumnName: 'userId' }) | ||
reporter: User; | ||
|
||
@ManyToOne(() => User, user => user.userId) | ||
@JoinColumn({ name: 'target_user_id', referencedColumnName: 'userId' }) | ||
targetUser: User; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum UserReportReason { | ||
SCAM = 'SCAM', | ||
INAPPROPRIATE = 'INAPPROPRIATE', | ||
COMMERCIAL = 'COMMERCIAL', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.