From 008ab92b3bd121fc30beb5d5bd60f5b02d38d11f Mon Sep 17 00:00:00 2001 From: Diger Date: Sat, 9 Dec 2023 20:43:54 +0900 Subject: [PATCH] Refactor GoalProof Domain Column --- .../GoalProofApplicationService.kt | 16 ++++++++++------ .../controller/betting/BettingController.kt | 14 +++++++------- .../controller/goal/GoalController.kt | 2 +- .../controller/goalproof/GoalProofController.kt | 4 ++-- .../controller/goalproof/GoalProofDto.kt | 15 +++++++++++---- .../raisedragon/domain/goalproof/GoalProof.kt | 9 +++++---- .../domain/goalproof/GoalProofEntity.kt | 14 +++++++++----- .../domain/goalproof/GoalProofService.kt | 7 +++++-- .../src/main/resources/ddl/V1_DDL.sql | 2 ++ 9 files changed, 52 insertions(+), 31 deletions(-) diff --git a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/applicationservice/GoalProofApplicationService.kt b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/applicationservice/GoalProofApplicationService.kt index 1380df9..85070e8 100644 --- a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/applicationservice/GoalProofApplicationService.kt +++ b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/applicationservice/GoalProofApplicationService.kt @@ -2,11 +2,11 @@ package com.whatever.raisedragon.applicationservice import com.whatever.raisedragon.controller.goalproof.GoalProofCreateUpdateResponse import com.whatever.raisedragon.controller.goalproof.GoalProofRetrieveResponse +import com.whatever.raisedragon.domain.gifticon.URL import com.whatever.raisedragon.domain.goal.GoalService -import com.whatever.raisedragon.domain.goalproof.Document +import com.whatever.raisedragon.domain.goalproof.Comment import com.whatever.raisedragon.domain.goalproof.GoalProofService import com.whatever.raisedragon.domain.user.UserService -import com.whatever.raisedragon.security.authentication.UserInfo import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -21,19 +21,22 @@ class GoalProofApplicationService( fun create( userId: Long, goalId: Long, - document: Document + url: String, + comment: String ): GoalProofCreateUpdateResponse { val goalProof = goalProofService.create( user = userService.loadById(userId), goal = goalService.loadById(goalId), - document = document + url = URL(url), + comment = Comment(comment) ) return GoalProofCreateUpdateResponse( GoalProofRetrieveResponse( id = goalProof.id, userId = goalProof.userId, goalId = goalProof.goalId, - document = document + url = goalProof.url, + comment = goalProof.comment ) ) } @@ -43,7 +46,8 @@ class GoalProofApplicationService( id = 0L, userId = 0L, goalId = 0L, - document = Document("Fake Document") + url = URL("goalProof.url"), + comment = Comment("goalProof.comment") ) } } \ No newline at end of file diff --git a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/betting/BettingController.kt b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/betting/BettingController.kt index 080baa5..763d073 100644 --- a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/betting/BettingController.kt +++ b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/betting/BettingController.kt @@ -41,13 +41,13 @@ class BettingController( return Response.success(bettingApplicationService.retrieve()) } - @Operation(summary = "Betting update API", description = "Update Betting") - @PutMapping - fun update( - @RequestBody bettingUpdateRequest: BettingUpdateRequest - ): Response { - return Response.success(bettingApplicationService.create()) - } +// @Operation(summary = "Betting update API", description = "Update Betting") +// @PutMapping +// fun update( +// @RequestBody bettingUpdateRequest: BettingUpdateRequest +// ): Response { +// return Response.success(bettingApplicationService.create()) +// } @Operation(summary = "Betting delete API", description = "Delete Betting") @DeleteMapping("{bettingId}") diff --git a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goal/GoalController.kt b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goal/GoalController.kt index 7133f9e..2a3c42d 100644 --- a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goal/GoalController.kt +++ b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goal/GoalController.kt @@ -35,7 +35,7 @@ class GoalController( threshold = Threshold(request.threshold), startDate = request.startDate, endDate = request.endDate, - userId = userInfo.id + userId = userinfo.id ) ) ) diff --git a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goalproof/GoalProofController.kt b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goalproof/GoalProofController.kt index 4ec4f0b..cb3e1fa 100644 --- a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goalproof/GoalProofController.kt +++ b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goalproof/GoalProofController.kt @@ -2,7 +2,6 @@ package com.whatever.raisedragon.controller.goalproof import com.whatever.raisedragon.applicationservice.GoalProofApplicationService import com.whatever.raisedragon.common.Response -import com.whatever.raisedragon.domain.goalproof.Document import com.whatever.raisedragon.security.authentication.UserInfo import com.whatever.raisedragon.security.resolver.GetAuth import io.swagger.v3.oas.annotations.Operation @@ -29,7 +28,8 @@ class GoalProofController( goalProofApplicationService.create( userId = userInfo.id, goalId = goalProofCreateRequest.goalId, - document = Document(goalProofCreateRequest.document) + url = goalProofCreateRequest.url, + comment = goalProofCreateRequest.comment, ) ) } diff --git a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goalproof/GoalProofDto.kt b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goalproof/GoalProofDto.kt index 4922f4a..0b045c8 100644 --- a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goalproof/GoalProofDto.kt +++ b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/controller/goalproof/GoalProofDto.kt @@ -1,6 +1,7 @@ package com.whatever.raisedragon.controller.goalproof -import com.whatever.raisedragon.domain.goalproof.Document +import com.whatever.raisedragon.domain.gifticon.URL +import com.whatever.raisedragon.domain.goalproof.Comment import io.swagger.v3.oas.annotations.media.Schema @Schema(description = "[Request] 인증내역 생성") @@ -9,7 +10,10 @@ data class GoalProofCreateRequest( val goalId: Long, @Schema(description = "다짐 인증에 대한 PresignedURL") - val document: String + val url: String, + + @Schema(description = "다짐 인증에 대한 부연설명") + val comment: String ) @Schema(description = "[Request] 인증내역 수정") @@ -36,6 +40,9 @@ data class GoalProofRetrieveResponse( @Schema(description = "GoalId") val goalId: Long, - @Schema(description = "인증 상세") - val document: Document + @Schema(description = "인증 사진") + val url: URL, + + @Schema(description = "인증 부연설명") + val comment: Comment, ) \ No newline at end of file diff --git a/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProof.kt b/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProof.kt index d9f7ea7..51407f8 100644 --- a/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProof.kt +++ b/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProof.kt @@ -1,14 +1,14 @@ package com.whatever.raisedragon.domain.goalproof -import com.whatever.raisedragon.domain.goal.Goal -import com.whatever.raisedragon.domain.user.User +import com.whatever.raisedragon.domain.gifticon.URL import java.time.LocalDateTime data class GoalProof( val id: Long, val userId: Long, val goalId: Long, - val document: Document, + val url: URL, + val comment: Comment, var deletedAt: LocalDateTime?, var createdAt: LocalDateTime?, var updatedAt: LocalDateTime? @@ -18,7 +18,8 @@ fun GoalProofEntity.toDto(): GoalProof = GoalProof( id = id, userId = userEntity.id, goalId = goalEntity.id, - document = document, + url = url, + comment = comment, deletedAt = deletedAt, createdAt = createdAt, updatedAt = updatedAt diff --git a/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProofEntity.kt b/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProofEntity.kt index 4756e20..c0b0475 100644 --- a/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProofEntity.kt +++ b/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProofEntity.kt @@ -1,6 +1,7 @@ package com.whatever.raisedragon.domain.goalproof import com.whatever.raisedragon.domain.BaseEntity +import com.whatever.raisedragon.domain.gifticon.URL import com.whatever.raisedragon.domain.goal.GoalEntity import com.whatever.raisedragon.domain.user.UserEntity import jakarta.persistence.* @@ -17,13 +18,16 @@ class GoalProofEntity( @JoinColumn(name = "goal_id") val goalEntity: GoalEntity, - @Embedded - val document: Document + @Column(name = "url") + val url: URL, + + @Column(name = "comment") + val comment: Comment ) : BaseEntity() @Embeddable -data class Document( - @Column(name = "document") - val value: String +data class Comment( + @Column(name = "comment") + val value: String, ) \ No newline at end of file diff --git a/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProofService.kt b/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProofService.kt index e15f2ed..31fa55a 100644 --- a/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProofService.kt +++ b/raisedragon-core/src/main/kotlin/com/whatever/raisedragon/domain/goalproof/GoalProofService.kt @@ -1,5 +1,6 @@ package com.whatever.raisedragon.domain.goalproof +import com.whatever.raisedragon.domain.gifticon.URL import com.whatever.raisedragon.domain.goal.Goal import com.whatever.raisedragon.domain.goal.fromDto import com.whatever.raisedragon.domain.user.User @@ -16,13 +17,15 @@ class GoalProofService( fun create( user: User, goal: Goal, - document: Document + url: URL, + comment: Comment ): GoalProof { val goalProof = goalProofRepository.save( GoalProofEntity( userEntity = user.fromDto(), goalEntity = goal.fromDto(), - document = document + url = url, + comment = comment, ) ) return goalProof.toDto() diff --git a/raisedragon-core/src/main/resources/ddl/V1_DDL.sql b/raisedragon-core/src/main/resources/ddl/V1_DDL.sql index b77c5d3..e5ebac0 100644 --- a/raisedragon-core/src/main/resources/ddl/V1_DDL.sql +++ b/raisedragon-core/src/main/resources/ddl/V1_DDL.sql @@ -82,6 +82,8 @@ create table if not exists goal_proof goal_id bigint not null, user_id bigint not null, document varchar(255) not null, + url varchar(255) not null, + comment varchar(255) not null, deleted_at datetime(6) null, created_at datetime(6) not null, updated_at datetime(6) not null