Skip to content

Commit 67c1db3

Browse files
committed
유저 신고 수정
1 parent 2996a7a commit 67c1db3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/user-report/user-report.controller.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export class UserReportController {
2222
@Req() req: Request
2323
): Promise<BaseResponse<null>> {
2424
const fromUserId = req.user['id'];
25-
//console.log("fromUserId is ~~~~~~~~~~~~~", fromUserId);
26-
//console.log("createUserReportDto.fromUserId is ~~~~~~~~~~~~~", createUserReportDto.fromUserId);
27-
25+
2826
// jwt 유저와 신고할 유저가 다른 경우
2927
if (fromUserId != createUserReportDto.fromUserId) {
3028
throw UnauthorizedException('신고 권한이 없습니다.');

src/user-report/user-report.service.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ export class UserReportService {
2929
}
3030

3131
// 중복 신고 확인
32-
const existingReport = await this.userReportRepository.findOne({
33-
where: { fromUser: { id: fromUserId }, toUser: { id: toUserId } },
34-
});
32+
const existingReport = await this.userReportRepository
33+
.createQueryBuilder('report')
34+
.where('report.fromUser = :fromUserId', { fromUserId })
35+
.andWhere('report.toUser = :toUserId', { toUserId })
36+
.andWhere('report.reason = :reason', { reason })
37+
.getOne();
3538

3639
if (existingReport) {
3740
throw InvalidInputValueException('이미 해당 유저를 신고하였습니다.');
@@ -41,6 +44,9 @@ export class UserReportService {
4144
fromUser,
4245
toUser,
4346
reason,
47+
createdAt: new Date(),
48+
updatedAt: new Date(),
49+
status: 'activated',
4450
});
4551

4652
await this.userReportRepository.save(userReport);

0 commit comments

Comments
 (0)