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

GoalProof 도메인을 리팩터링합니다. #25

Merged
merged 1 commit into from
Dec 9, 2023
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
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 Document")
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 @@ -35,7 +35,7 @@ class GoalController(
threshold = Threshold(request.threshold),
startDate = request.startDate,
endDate = request.endDate,
userId = userInfo.id
userId = userinfo.id
)
)
)
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,7 +28,8 @@ class GoalProofController(
goalProofApplicationService.create(
userId = userInfo.id,
goalId = goalProofCreateRequest.goalId,
document = Document(goalProofCreateRequest.document)
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 All @@ -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] 인증내역 수정")
Expand All @@ -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,
)
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,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,
)
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
2 changes: 2 additions & 0 deletions raisedragon-core/src/main/resources/ddl/V1_DDL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down