Skip to content

Commit

Permalink
Refactor GoalProof Domain Column
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Diger committed Dec 9, 2023
1 parent ea3e8f2 commit 7ace84e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
)
)
}
Expand All @@ -43,7 +46,8 @@ class GoalProofApplicationService(
id = 0L,
userId = 0L,
goalId = 0L,
document = Document("Fake URL", "Fake Comment")
url = URL("goalProof.url"),
comment = Comment("goalProof.comment")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<BettingCreateUpdateResponse> {
return Response.success(bettingApplicationService.create())
}
// @Operation(summary = "Betting update API", description = "Update Betting")
// @PutMapping
// fun update(
// @RequestBody bettingUpdateRequest: BettingUpdateRequest
// ): Response<BettingCreateUpdateResponse> {
// return Response.success(bettingApplicationService.create())
// }

@Operation(summary = "Betting delete API", description = "Delete Betting")
@DeleteMapping("{bettingId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,10 +28,8 @@ class GoalProofController(
goalProofApplicationService.create(
userId = userInfo.id,
goalId = goalProofCreateRequest.goalId,
document = Document(
goalProofCreateRequest.url,
goalProofCreateRequest.comment,
)
url = goalProofCreateRequest.url,
comment = goalProofCreateRequest.comment,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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] 인증내역 생성")
Expand Down Expand Up @@ -39,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,
)
Original file line number Diff line number Diff line change
@@ -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?
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*
Expand All @@ -17,16 +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 = "url")
val url: String,

data class Comment(
@Column(name = "comment")
val comment: String,
val value: String,
)
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 7ace84e

Please sign in to comment.