Skip to content

Commit

Permalink
Hotfix: Fix main page orderby exception. (#142)
Browse files Browse the repository at this point in the history
* Hotfix: Add field for order_by

* Hotfix: handle null exception for titleForMain.
  • Loading branch information
huGgW authored Sep 19, 2023
1 parent 6227d30 commit 2c79108
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ class MainRepositoryImpl(
MainNoticeResponse::class.java,
noticeEntity.id,
noticeEntity.title,
noticeEntity.createdAt
)
noticeEntity.createdAt,
noticeEntity.isPinned,
),
).from(noticeEntity)
.where(noticeEntity.isDeleted.eq(false), noticeEntity.isPrivate.eq(false))
.orderBy(noticeEntity.isPinned.desc()).orderBy(noticeEntity.createdAt.desc())
Expand All @@ -70,13 +71,14 @@ class MainRepositoryImpl(
noticeTagEntity.notice.id,
noticeTagEntity.notice.title,
noticeTagEntity.notice.createdAt,
noticeEntity.isPinned,
)
).from(noticeTagEntity)
.rightJoin(noticeEntity).on(noticeTagEntity.notice.eq(noticeEntity))
.rightJoin(tagInNoticeEntity).on(noticeTagEntity.tag.eq(tagInNoticeEntity))
.where(noticeTagEntity.tag.name.eq(tagEnum))
.where(noticeEntity.isDeleted.eq(false), noticeEntity.isPrivate.eq(true))
.orderBy(noticeEntity.isPinned.desc()).orderBy(noticeEntity.createdAt.desc())
.orderBy(noticeEntity.isPinned.desc()).orderBy(noticeTagEntity.notice.createdAt.desc())
.limit(6).distinct().fetch()
}

Expand All @@ -86,7 +88,7 @@ class MainRepositoryImpl(
mainImportantResponses.add(
MainImportantResponse(
id = it.id,
title = it.titleForMain!!,
title = it.titleForMain ?: it.title,
description = it.description,
createdAt = it.createdAt,
category = "notice"
Expand All @@ -98,7 +100,7 @@ class MainRepositoryImpl(
mainImportantResponses.add(
MainImportantResponse(
id = it.id,
title = it.titleForMain!!,
title = it.titleForMain ?: it.title,
description = it.description,
createdAt = it.createdAt,
category = "news"
Expand All @@ -110,7 +112,7 @@ class MainRepositoryImpl(
mainImportantResponses.add(
MainImportantResponse(
id = it.id,
title = it.titleForMain!!,
title = it.titleForMain ?: it.title,
description = it.description,
createdAt = it.createdAt,
category = "seminar"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.wafflestudio.csereal.core.main.dto

import com.querydsl.core.annotations.QueryProjection
import java.time.LocalDateTime

data class MainNoticeResponse(
val id: Long,
val title: String,
val createdAt: LocalDateTime?
) {

@QueryProjection constructor (
id: Long, title: String, createdAt: LocalDateTime?, isPinned: Boolean
): this(id, title, createdAt) {
}
}

0 comments on commit 2c79108

Please sign in to comment.