Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 데이터 저장 시 createdAt과 updatedAt 다른 이슈 수정 #141

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = "dev.jxmen"
version = "1.3.4"
version = "1.3.5"

java {
sourceCompatibility = JavaVersion.VERSION_21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.MappedSuperclass
import jakarta.persistence.PrePersist
import org.hibernate.annotations.Comment
import org.springframework.data.annotation.CreatedDate
import org.springframework.data.annotation.LastModifiedDate
Expand All @@ -25,4 +26,11 @@ abstract class BaseEntity {
@LastModifiedDate
@Comment("수정일")
var updatedAt: LocalDateTime = LocalDateTime.now()

@PrePersist
fun initDates() {
val now = LocalDateTime.now()
createdAt = now
updatedAt = now
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -438,16 +438,19 @@ class SubjectApiTest :
.header("Authorization", "Bearer token"),
).andExpect(status().isOk)
.andExpect(jsonPath("$.success").value(true))
.andExpect(jsonPath("$.data.length()").value(3))
.andExpect(jsonPath("$.data[0].message").value("스레드와 프로세스의 차이점은 무엇인가요?"))
.andExpect(jsonPath("$.data[0].score").doesNotExist())
.andExpect(jsonPath("$.data[0].type").value("question"))
.andExpect(jsonPath("$.data[0].createdAt").doesNotExist())
.andExpect(jsonPath("$.data[1].message").value("스레드는 프로세스 내에서 실행되는 작업의 단위이고, 프로세스는 실행 중인 프로그램의 인스턴스입니다."))
.andExpect(jsonPath("$.data[1].score").value(100))
.andExpect(jsonPath("$.data[1].score").value(20))
.andExpect(jsonPath("$.data[1].type").value("answer"))
.andExpect(jsonPath("$.data[1].createdAt").value("2024-08-15T21:00:00"))
.andExpect(jsonPath("$.data[2]").doesNotExist())
.andExpect(jsonPath("$.error").isEmpty())
.andExpect(jsonPath("$.data[2].message").value("그렇다면 멀티스레드와 멀티프로세스의 차이점은 무엇인가요?"))
.andExpect(jsonPath("$.data[2].score").doesNotExist())
.andExpect(jsonPath("$.data[2].type").value("question"))
.andExpect(jsonPath("$.data[2].createdAt").doesNotExist())
.andDo(
document(
identifier = "get-chat-message",
Expand Down Expand Up @@ -831,9 +834,14 @@ class SubjectApiTest :
subject = subject,
member = member,
answer = "스레드는 프로세스 내에서 실행되는 작업의 단위이고, 프로세스는 실행 중인 프로그램의 인스턴스입니다.",
score = 100,
score = 20,
createdAt = date,
),
Chat.createQuestion(
subject = subject,
member = member,
message = "그렇다면 멀티스레드와 멀티프로세스의 차이점은 무엇인가요?",
),
)
}
}