Skip to content

Commit 3fd5ca4

Browse files
authored
[feat #264] 신고하기 기능 추가 (#265)
* comment : 주석 추가 * feat : 신고한 게시물을 올린 사람의 모든 컨텐츠를 차단 * feat : 신고게시물 조회 시 deleted false 조건 추가
1 parent 44a8769 commit 3fd5ca4

File tree

2 files changed

+11
-4
lines changed
  • adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/content/impl
  • application/src/main/kotlin/com/pokit/content/port/service

2 files changed

+11
-4
lines changed

adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/content/impl/ContentAdapter.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,32 @@ class ContentAdapter(
6464
isPrivate: Boolean,
6565
pageable: Pageable,
6666
): Slice<ContentsResult> {
67+
val reportedUserIds = queryFactory.select(contentEntity.userId)
68+
.from(reportedContentEntity)
69+
.join(contentEntity).on(reportedContentEntity.contentId.eq(contentEntity.id))
70+
.where(
71+
reportedContentEntity.reporterId.eq(userId),
72+
contentEntity.deleted.isFalse,
73+
reportedContentEntity.isDeleted.isFalse
74+
)
75+
6776
val query = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count(), bookmarkEntity.count())
6877
.from(contentEntity)
6978
.leftJoin(userLogEntity).on(userLogEntity.contentId.eq(contentEntity.id))
7079
.join(categoryEntity).on(categoryEntity.id.eq(contentEntity.categoryId))
71-
.leftJoin(reportedContentEntity).on(reportedContentEntity.contentId.eq(contentEntity.id))
7280
.leftJoin(bookmarkEntity).on(bookmarkEntity.contentId.eq(contentEntity.id).and(bookmarkEntity.deleted.isFalse))
7381

7482
FavoriteOrNot(condition.favorites, userId, query) // 북마크 조인 여부
7583

7684
query.where(
7785
if (isPrivate) categoryEntity.userId.eq(userId) else null,
78-
reportedContentEntity.id.isNull.or(reportedContentEntity.reporterId.ne(userId)),
86+
contentEntity.userId.notIn(reportedUserIds),
7987
condition.categoryId?.let { categoryEntity.id.eq(it) },
8088
isUnread(condition.isRead, userId),
8189
contentEntity.deleted.isFalse,
8290
dateBetween(condition.startDate, condition.endDate),
8391
categoryIn(condition.categoryIds),
8492
containsWord(condition.searchWord),
85-
contentEntity.deleted.isFalse,
8693
)
8794
.offset(pageable.offset)
8895
.groupBy(contentEntity)

application/src/main/kotlin/com/pokit/content/port/service/ContentService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class ContentService(
243243
)
244244

245245
val reportedContent = ReportedContent(
246-
reporterId = userId,
246+
reporterId = userId, // 신고자 ID
247247
contentId = contentId,
248248
)
249249

0 commit comments

Comments
 (0)