-
Notifications
You must be signed in to change notification settings - Fork 1
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 #111 from gague-jinsim-in-jadeul/fix/110_change_ti…
…mezone 🐛 ($chat) fix chat time bug
- Loading branch information
Showing
12 changed files
with
202 additions
and
69 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
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
51 changes: 51 additions & 0 deletions
51
...va/org/gagu/gagubackend/chat/repository/custom/impl/ChatContentsRepositoryCustomImpl.java
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,51 @@ | ||
package org.gagu.gagubackend.chat.repository.custom.impl; | ||
|
||
import com.querydsl.jpa.JPQLQuery; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import jakarta.persistence.EntityManager; | ||
import org.gagu.gagubackend.chat.domain.ChatContents; | ||
import org.gagu.gagubackend.chat.domain.ChatRoomMember; | ||
import org.gagu.gagubackend.chat.domain.QChatContents; | ||
import org.gagu.gagubackend.chat.repository.custom.ChatContentsRepositoryCustom; | ||
import org.gagu.gagubackend.chat.repository.custom.ChatRoomMemberRepositoryCustom; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageImpl; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.support.PageableExecutionUtils; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Service | ||
public class ChatContentsRepositoryCustomImpl implements ChatContentsRepositoryCustom { | ||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
public ChatContentsRepositoryCustomImpl(EntityManager em) { | ||
this.jpaQueryFactory = new JPAQueryFactory(em); | ||
} | ||
|
||
@Override | ||
public Page<ChatContents> pageChatContents(Long roomNumber, Pageable pageable) { | ||
QChatContents qChatContents = QChatContents.chatContents; | ||
|
||
int page = pageable.getPageNumber(); | ||
int pageSize = pageable.getPageSize(); | ||
|
||
long offset = (long) page * pageSize; | ||
|
||
List<ChatContents> chatContentsList = jpaQueryFactory.select(qChatContents) | ||
.from(qChatContents) | ||
.where(qChatContents.chatRoomId.eq(roomNumber)) | ||
.orderBy(qChatContents.sendTime.desc()) | ||
.limit(pageable.getPageSize()) | ||
.offset(offset) | ||
.fetch(); | ||
|
||
JPQLQuery<Long> count = jpaQueryFactory.select(qChatContents.count()) | ||
.from(qChatContents) | ||
.where(qChatContents.chatRoomId.eq(roomNumber)); | ||
|
||
return PageableExecutionUtils.getPage(chatContentsList, pageable, count::fetchOne); | ||
} | ||
} |
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
5 changes: 0 additions & 5 deletions
5
src/main/java/org/gagu/gagubackend/global/service/TimeService.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.