Skip to content

Commit

Permalink
[YS-53] feat: Experiment 관련 엔티티 추가 (#21)
Browse files Browse the repository at this point in the history
* feat: add entities related to Experiment

* feat: change enum's type value

* style: add eof line

* test: add eof line

* fix: change phoneNum type from Long to String

* refact: move MemberEntity to member package

* test: fix failed test due to package

* refact: update column's length condition

* chore: add env var for email

* feat: add school column

* refact: rename school field to univName

* refact: some fields from val to var in ExperimentPostEntity

* refact: move Member Model to member package

* feat: add domain model for Experiment's Entity

* feat: add toDomain and fromDomain method
  • Loading branch information
Ji-soo708 authored Jan 8, 2025
1 parent 1f89fb3 commit 03b03d5
Show file tree
Hide file tree
Showing 46 changed files with 458 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.dobby.backend.application.mapper

import com.dobby.backend.infrastructure.database.entity.MemberEntity
import com.dobby.backend.infrastructure.database.entity.ParticipantEntity
import com.dobby.backend.infrastructure.database.entity.ResearcherEntity
import com.dobby.backend.infrastructure.database.entity.member.MemberEntity
import com.dobby.backend.infrastructure.database.entity.member.ParticipantEntity
import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus
import com.dobby.backend.infrastructure.database.entity.enum.RoleType
import com.dobby.backend.presentation.api.dto.request.signup.ParticipantSignupRequest
import com.dobby.backend.infrastructure.database.entity.member.AddressInfo
import com.dobby.backend.infrastructure.database.entity.member.ResearcherEntity
import com.dobby.backend.presentation.api.dto.request.signup.ResearcherSignupRequest
import com.dobby.backend.infrastructure.database.entity.AddressInfo as AddressInfo
import com.dobby.backend.presentation.api.dto.request.signup.AddressInfo as DtoAddressInfo

object SignupMapper {
Expand Down Expand Up @@ -57,7 +57,7 @@ object SignupMapper {
fun toResearcher(
member: MemberEntity,
req: ResearcherSignupRequest
): ResearcherEntity{
): ResearcherEntity {
return ResearcherEntity(
member = member,
univEmail = req.univEmail,
Expand All @@ -67,5 +67,4 @@ object SignupMapper {
labInfo = req.labInfo
)
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.dobby.backend.application.service

import com.dobby.backend.application.usecase.SignupUseCase.email.EmailCodeSendUseCase
import com.dobby.backend.application.usecase.SignupUseCase.email.EmailVerificationUseCase
import com.dobby.backend.application.usecase.signupUseCase.email.EmailCodeSendUseCase
import com.dobby.backend.application.usecase.signupUseCase.email.EmailVerificationUseCase
import com.dobby.backend.presentation.api.dto.request.signup.EmailSendRequest
import com.dobby.backend.presentation.api.dto.request.signup.EmailVerificationRequest
import com.dobby.backend.presentation.api.dto.response.signup.EmailSendResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.dobby.backend.application.service

import com.dobby.backend.application.usecase.SignupUseCase.CreateResearcherUseCase
import com.dobby.backend.application.usecase.SignupUseCase.ParticipantSignupUseCase
import com.dobby.backend.application.usecase.SignupUseCase.VerifyResearcherEmailUseCase
import com.dobby.backend.application.usecase.signupUseCase.CreateResearcherUseCase
import com.dobby.backend.application.usecase.signupUseCase.ParticipantSignupUseCase
import com.dobby.backend.application.usecase.signupUseCase.VerifyResearcherEmailUseCase
import com.dobby.backend.domain.exception.EmailNotValidateException
import com.dobby.backend.presentation.api.dto.request.signup.ParticipantSignupRequest
import com.dobby.backend.presentation.api.dto.request.signup.ResearcherSignupRequest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.dobby.backend.application.usecase

import com.dobby.backend.domain.gateway.MemberGateway
import com.dobby.backend.domain.model.Member
import com.dobby.backend.domain.model.member.Member

class GetMemberById(
private val memberGateway: MemberGateway,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dobby.backend.application.usecase.SignupUseCase
package com.dobby.backend.application.usecase.signupUseCase

import com.dobby.backend.application.mapper.SignupMapper
import com.dobby.backend.application.usecase.UseCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dobby.backend.application.usecase.SignupUseCase
package com.dobby.backend.application.usecase.signupUseCase

import com.dobby.backend.application.mapper.SignupMapper
import com.dobby.backend.application.usecase.UseCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dobby.backend.application.usecase.SignupUseCase
package com.dobby.backend.application.usecase.signupUseCase

import com.dobby.backend.application.usecase.UseCase
import com.dobby.backend.domain.exception.EmailNotValidateException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dobby.backend.application.usecase.SignupUseCase.email
package com.dobby.backend.application.usecase.signupUseCase.email

import com.dobby.backend.application.mapper.VerificationMapper
import com.dobby.backend.application.usecase.UseCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dobby.backend.application.usecase.SignupUseCase.email
package com.dobby.backend.application.usecase.signupUseCase.email

import com.dobby.backend.application.mapper.VerificationMapper
import com.dobby.backend.application.usecase.UseCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.dobby.backend.domain.gateway

import com.dobby.backend.domain.model.Member
import com.dobby.backend.domain.model.member.Member

interface MemberGateway {
fun getById(memberId: Long): Member
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.dobby.backend.domain.gateway

import com.dobby.backend.domain.model.Member
import com.dobby.backend.domain.model.member.Member

interface TokenGateway {
fun generateAccessToken(member: Member): String
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.dobby.backend.domain.model.experiment

data class ApplyMethod(
val id: Long,
val phoneNum: String,
val formUrl: String,
val content: String
) {
companion object {
fun newApplyMethod(
id: Long,
phoneNum: String,
formUrl: String,
content: String
) = ApplyMethod(
id = id,
phoneNum = phoneNum,
formUrl = formUrl,
content = content
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.dobby.backend.domain.model.experiment

data class ExperimentImage(
val id: Long,
val experimentPost: ExperimentPost,
val imageUrl: String
) {
companion object {
fun newExperimentImage(
id: Long,
experimentPost: ExperimentPost,
imageUrl: String
) = ExperimentImage(
id = id,
experimentPost = experimentPost,
imageUrl = imageUrl
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.dobby.backend.domain.model.experiment

import com.dobby.backend.domain.model.member.Member
import com.dobby.backend.infrastructure.database.entity.enum.MatchType
import com.dobby.backend.infrastructure.database.entity.enum.areaInfo.Area
import com.dobby.backend.infrastructure.database.entity.enum.areaInfo.Region
import java.time.LocalDate

data class ExperimentPost(
val id: Long,
val member: Member,
val targetGroup: TargetGroup,
val applyMethod: ApplyMethod,
var views: Int,
val title: String,
val content: String,
var researcherName: String,
val reward: String,
val startDate: LocalDate,
val endDate: LocalDate,
val durationMinutes: Int,
val count: Int,
val matchType: MatchType,
val univName: String,
val region: Region,
val area: Area,
val detailedAddress: String,
val alarmAgree: Boolean,
val images: List<ExperimentImage>
) {
companion object {
fun newExperimentPost(
id: Long,
member: Member,
targetGroup: TargetGroup,
applyMethod: ApplyMethod,
views: Int,
title: String,
content: String,
researcherName: String,
reward: String,
startDate: LocalDate,
endDate: LocalDate,
durationMinutes: Int,
count: Int,
matchType: MatchType,
univName: String,
region: Region,
area: Area,
detailedAddress: String,
alarmAgree: Boolean,
images: List<ExperimentImage>
) = ExperimentPost(
id = id,
member = member,
targetGroup = targetGroup,
applyMethod = applyMethod,
views = views,
title = title,
content = content,
researcherName = researcherName,
reward = reward,
startDate = startDate,
endDate = endDate,
durationMinutes = durationMinutes,
count = count,
matchType = matchType,
univName = univName,
region = region,
area = area,
detailedAddress = detailedAddress,
alarmAgree = alarmAgree,
images = images
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.dobby.backend.domain.model.experiment

import com.dobby.backend.infrastructure.database.entity.enum.GenderType

data class TargetGroup(
val id: Long,
val startAge: Int,
val endAge: Int,
val genderType: GenderType,
val otherCondition: String
) {
companion object {
fun newTargetGroup(
id: Long,
startAge: Int,
endAge: Int,
genderType: GenderType,
otherCondition: String
) = TargetGroup(
id = id,
startAge = startAge,
endAge = endAge,
genderType = genderType,
otherCondition = otherCondition
)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.dobby.backend.domain.model
package com.dobby.backend.domain.model.member

import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus
import com.dobby.backend.infrastructure.database.entity.enum.ProviderType
import com.dobby.backend.infrastructure.database.entity.enum.RoleType
import java.time.LocalDate

data class Member(
val memberId: Long,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.dobby.backend.infrastructure.database.entity.enum

enum class GenderType {
MALE, FEMALE, SECRET
}
MALE, FEMALE, ALL
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.dobby.backend.infrastructure.database.entity.enum

enum class MatchType {
OFFLINE, ONLINE, HYBRID
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package com.dobby.backend.infrastructure.database.entity.enum
enum class MemberStatus {
HOLD,
ACTIVE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ enum class Region(val displayName: String) {
return displayNameMap[name]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.dobby.backend.infrastructure.database.entity.experiment

import com.dobby.backend.domain.model.experiment.ApplyMethod
import jakarta.persistence.*

@Entity(name = "apply_method")
class ApplyMethodEntity (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long,

@Column(name = "phone_num", length = 50)
val phoneNum: String,

@Column(name = "form_url", length = 100)
val formUrl: String,

@Column(name = "content", nullable = false, length = 200)
val content: String,
) {
fun toDomain(): ApplyMethod = ApplyMethod(
id = id,
phoneNum = phoneNum,
formUrl = formUrl,
content = content
)

companion object {
fun fromDomain(applyMethod: ApplyMethod) = with(applyMethod) {
ApplyMethodEntity(
id = id,
phoneNum = phoneNum,
formUrl = formUrl,
content = content
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.dobby.backend.infrastructure.database.entity.experiment

import AuditingEntity
import com.dobby.backend.domain.model.experiment.ExperimentImage
import jakarta.persistence.*

@Entity(name = "experiment_image")
class ExperimentImageEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long,

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "experiment_post_id", nullable = false)
val experimentPost: ExperimentPostEntity,

@Column(name = "image_url", nullable = false)
val imageUrl: String,
) : AuditingEntity() {
fun toDomain(): ExperimentImage = ExperimentImage(
id = id,
experimentPost = experimentPost.toDomain(),
imageUrl = imageUrl
)

companion object {
fun fromDomain(experimentImage: ExperimentImage): ExperimentImageEntity = with(experimentImage) {
ExperimentImageEntity(
id = id,
experimentPost = ExperimentPostEntity.fromDomain(experimentPost),
imageUrl = imageUrl
)
}
}
}
Loading

0 comments on commit 03b03d5

Please sign in to comment.