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

[YS-54] feat: 실험자 공고 등록 API 구현 #24

Merged
merged 43 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
593ca56
feat: implements participant signup
chock-cho Jan 3, 2025
399fcbb
test: add test codes for SignupMapper and ParticipantSignupUseCase
chock-cho Jan 3, 2025
44e0b73
fix: resolve duplicate requested authentication
chock-cho Jan 3, 2025
699fa1f
refact: move DB Transaction to seperate responsibility to satisfy clean
chock-cho Jan 3, 2025
6741665
refact: Applay automatic Component Scan for UseCase classes
chock-cho Jan 3, 2025
dcf3ac6
style: rename API endpoint signup to meet the convention rule
chock-cho Jan 3, 2025
af04963
refact: update annotations to validate DateTime Format
chock-cho Jan 3, 2025
81375b2
refact: rename mapper function to match its usecase
chock-cho Jan 3, 2025
9bee38c
fix: reflect updated codes to test code
chock-cho Jan 3, 2025
2af113f
feat: merge from dev branch
chock-cho Jan 4, 2025
e84a874
feat: implement researcher member signup
chock-cho Jan 4, 2025
66f6e27
test: update test codes for adjust additional logic
chock-cho Jan 4, 2025
6b8e640
test: add test codes for AuthenticationUtils
chock-cho Jan 4, 2025
83f3275
test: add test codes to UseCases and Service related to signup logic
chock-cho Jan 4, 2025
7016272
feat: add verification entity
chock-cho Jan 6, 2025
813436f
feat: implement Email Send Code and Verification using SMTP
chock-cho Jan 6, 2025
fe7229f
fix: add exception codes for Email Verification logic
chock-cho Jan 6, 2025
672a2e9
docs: add application-yml file to .gitignore
chock-cho Jan 6, 2025
7b2fd25
fix: resolve merge conflicts with dev branch
chock-cho Jan 6, 2025
faa6ca0
fix: resolve merge conflicts with dev branch
chock-cho Jan 6, 2025
e4659db
chore: move packages structure
chock-cho Jan 6, 2025
b88a38b
fix: adjust test codes for non-failed test configuration
chock-cho Jan 7, 2025
ab97b8c
test: add test codes for Email send verification logic
chock-cho Jan 7, 2025
6e9a2b8
feat: add email verification condition to researcherSignup
chock-cho Jan 7, 2025
ad9310c
fix: add test codes for SignupServiceTest to meet the code coverage
chock-cho Jan 7, 2025
9e7d3c6
refact: reflect updation from the code review
chock-cho Jan 7, 2025
1450322
Merge branch 'dev' of https://github.com/YAPP-Github/25th-Web-Team-2-…
chock-cho Jan 9, 2025
737f933
fix: resolve merge conflicts
chock-cho Jan 9, 2025
0378cc3
refact: refactor email verification logic for clean architecture and …
chock-cho Jan 9, 2025
012533c
fix: resolve dependency error
chock-cho Jan 9, 2025
d19d2e6
refact: refactor researcher signup logic for clean architecture and D…
chock-cho Jan 9, 2025
4a25a6d
refact: refactor participant signup logic for clean architecture and …
chock-cho Jan 9, 2025
01565c8
fix: hold the test codes to go thorugh CI workflow
chock-cho Jan 9, 2025
e4e6da8
fix: resolve conflicts merging from dev
chock-cho Jan 9, 2025
e7c1942
refact: verify some logics for ResearcherSignup Logic
chock-cho Jan 9, 2025
3d1da84
fix: ensure proper ID handling in saved entities
chock-cho Jan 9, 2025
f0d503d
refact: update some logics for validate participantSignup Response
chock-cho Jan 9, 2025
7f667a5
fix: add MemberGateway mockk object to resolve test failed
chock-cho Jan 9, 2025
92e32c7
feat: add createPost logic for researcher
chock-cho Jan 10, 2025
d9b4b37
fix: delete ServiceTestCode for CI workflow succeed
chock-cho Jan 10, 2025
b672f5e
feat: add autocomplete api logic for createPost Logic
chock-cho Jan 10, 2025
600fea5
feat: update some revisions for registering experiment post
chock-cho Jan 11, 2025
381410c
docs: fix Participant to Researcher in Swagger Docs
chock-cho Jan 11, 2025
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
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ dependencyManagement {
}
}

dependencies {
implementation("org.slf4j:slf4j-api")
implementation("ch.qos.logback:logback-classic")
}

kotlin {
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.dobby.backend.application.mapper

import com.dobby.backend.application.usecase.signup.CreateResearcherUseCase
import com.dobby.backend.application.usecase.signup.CreateParticipantUseCase
import com.dobby.backend.domain.model.member.Participant
import com.dobby.backend.domain.model.member.Researcher
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.presentation.api.dto.request.signup.AddressInfo as DtoAddressInfo

object SignupMapper {
Expand All @@ -29,7 +31,7 @@ object SignupMapper {
)
}

fun toResearcherMember(req: ResearcherSignupRequest): MemberEntity {
fun toResearcherMember(req: CreateResearcherUseCase.Input): MemberEntity {
return MemberEntity(
id = 0, // Auto-generated
oauthEmail = req.oauthEmail,
Expand All @@ -45,6 +47,7 @@ object SignupMapper {
req: ParticipantSignupRequest
): ParticipantEntity {
return ParticipantEntity(
id = 0,
member = member,
basicAddressInfo = toAddressInfo(req.basicAddressInfo),
additionalAddressInfo = req.additionalAddressInfo?.let { toAddressInfo(it) },
Expand All @@ -56,9 +59,10 @@ object SignupMapper {

fun toResearcher(
member: MemberEntity,
req: ResearcherSignupRequest
req: CreateResearcherUseCase.Input
): ResearcherEntity {
return ResearcherEntity(
id = 0,
member = member,
univEmail = req.univEmail,
emailVerified = req.emailVerified,
Expand All @@ -67,4 +71,26 @@ object SignupMapper {
labInfo = req.labInfo
)
}

fun modelToResearcherRes(newResearcher: Researcher)
: CreateResearcherUseCase.MemberResponse {
return CreateResearcherUseCase.MemberResponse(
memberId = newResearcher.member.id,
name = newResearcher.member.name,
oauthEmail = newResearcher.member.oauthEmail,
provider = newResearcher.member.provider,
role = newResearcher.member.role
)
}

fun modelToParticipantRes(newParticipant: Participant)
: CreateParticipantUseCase.MemberResponse {
return CreateParticipantUseCase.MemberResponse(
memberId = newParticipant.member.id,
name = newParticipant.member.name,
oauthEmail = newParticipant.member.oauthEmail,
provider = newParticipant.member.provider,
role = newParticipant.member.role
)
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
package com.dobby.backend.application.mapper

import com.dobby.backend.application.usecase.signup.email.EmailCodeSendUseCase
import com.dobby.backend.application.usecase.signup.email.EmailVerificationUseCase
import com.dobby.backend.infrastructure.database.entity.VerificationEntity
import com.dobby.backend.infrastructure.database.entity.enum.VerificationStatus
import com.dobby.backend.presentation.api.dto.request.signup.EmailSendRequest
import com.dobby.backend.presentation.api.dto.response.signup.EmailSendResponse
import com.dobby.backend.presentation.api.dto.response.signup.EmailVerificationResponse

object VerificationMapper {
fun toEntity(req: EmailSendRequest, code : String): VerificationEntity {
return VerificationEntity(
id= 0,
univMail = req.univEmail,
univEmail = req.univEmail,
verificationCode = code,
status = VerificationStatus.HOLD,
expiresAt = null
)
}

fun toSendResDto() : EmailSendResponse{
return EmailSendResponse(
isSuccess = true,
message = "해당 학교 이메일로 성공적으로 코드를 전송했습니다. 10분 이내로 인증을 완료해주세요."
fun toSendResDto(isSuccess: Boolean, message: String) : EmailCodeSendUseCase.Output{
return EmailCodeSendUseCase.Output(
isSuccess = isSuccess,
message = message
)
}

fun toVerifyResDto() : EmailVerificationResponse {
return EmailVerificationResponse(
isSuccess = true,
message = "학교 메일 인증이 완료되었습니다."
fun toVerifyResDto(isSuccess: Boolean, message: String) : EmailVerificationUseCase.Output {
return EmailVerificationUseCase.Output(
isSuccess = isSuccess,
message = message
)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.dobby.backend.application.service

import com.dobby.backend.application.usecase.*
import com.dobby.backend.application.usecase.auth.FetchGoogleUserInfoUseCase
import com.dobby.backend.application.usecase.auth.FetchNaverUserInfoUseCase
import org.springframework.stereotype.Service

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +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.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
import com.dobby.backend.presentation.api.dto.response.signup.EmailVerificationResponse
import com.dobby.backend.application.usecase.signup.email.EmailCodeSendUseCase
import com.dobby.backend.application.usecase.signup.email.EmailVerificationUseCase
import jakarta.transaction.Transactional
import org.springframework.stereotype.Service

Expand All @@ -15,12 +11,12 @@ class EmailService(
private val emailVerificationUseCase: EmailVerificationUseCase
) {
@Transactional
fun sendEmail(req: EmailSendRequest) : EmailSendResponse{
fun sendEmail(req: EmailCodeSendUseCase.Input) : EmailCodeSendUseCase.Output{
return emailCodeSendUseCase.execute(req)
}

@Transactional
fun verifyCode(req: EmailVerificationRequest) : EmailVerificationResponse {
fun verifyCode(req: EmailVerificationUseCase.Input) : EmailVerificationUseCase.Output {
return emailVerificationUseCase.execute(req)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.dobby.backend.application.service

import com.dobby.backend.application.usecase.experiment.CreatePostUseCase
import com.dobby.backend.application.usecase.experiment.GetResearcherInfoUseCase
import jakarta.transaction.Transactional
import org.springframework.stereotype.Service

@Service
class PostService(
private val createPostUseCase: CreatePostUseCase,
private val getResearcherInfoUseCase: GetResearcherInfoUseCase
) {
@Transactional
fun createNewExperimentPost(input: CreatePostUseCase.Input): CreatePostUseCase.Output {
return createPostUseCase.execute(input)
}

fun getDefaultInfo(): GetResearcherInfoUseCase.Output {
return getResearcherInfoUseCase.execute(Unit)
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
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.domain.exception.EmailNotValidateException
import com.dobby.backend.presentation.api.dto.request.signup.ParticipantSignupRequest
import com.dobby.backend.presentation.api.dto.request.signup.ResearcherSignupRequest
import com.dobby.backend.presentation.api.dto.response.signup.SignupResponse
import com.dobby.backend.application.usecase.signup.CreateParticipantUseCase
import com.dobby.backend.application.usecase.signup.CreateResearcherUseCase
import com.dobby.backend.application.usecase.signup.VerifyResearcherEmailUseCase
import com.dobby.backend.domain.exception.SignupOauthEmailDuplicateException
import com.dobby.backend.domain.gateway.MemberGateway
import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus
import jakarta.transaction.Transactional
import org.springframework.stereotype.Service

@Service
class SignupService(
private val participantSignupUseCase: ParticipantSignupUseCase,
private val memberGateway: MemberGateway,
private val createParticipantUseCase: CreateParticipantUseCase,
private val createResearcherUseCase: CreateResearcherUseCase,
private val verifyResearcherEmailUseCase: VerifyResearcherEmailUseCase
) {
@Transactional
fun participantSignup(input: ParticipantSignupRequest): SignupResponse {
return participantSignupUseCase.execute(input)
fun participantSignup(input: CreateParticipantUseCase.Input): CreateParticipantUseCase.Output {
return createParticipantUseCase.execute(input)
}

@Transactional
fun researcherSignup(input: ResearcherSignupRequest) : SignupResponse{
if(!input.emailVerified) {
throw EmailNotValidateException()
}
verifyResearcherEmailUseCase.execute(input.univEmail)
fun researcherSignup(input: CreateResearcherUseCase.Input) : CreateResearcherUseCase.Output{
val existingMember = memberGateway.findByOauthEmailAndStatus(input.oauthEmail, MemberStatus.ACTIVE)
if(existingMember!= null) throw SignupOauthEmailDuplicateException()

verifyResearcherEmailUseCase.execute(input.univEmail)
return createResearcherUseCase.execute(input)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dobby.backend.application.usecase
package com.dobby.backend.application.usecase.auth

import com.dobby.backend.application.usecase.UseCase
import com.dobby.backend.domain.gateway.MemberGateway
import com.dobby.backend.domain.gateway.TokenGateway
import com.dobby.backend.domain.gateway.feign.GoogleAuthGateway
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dobby.backend.application.usecase
package com.dobby.backend.application.usecase.auth

import com.dobby.backend.application.usecase.UseCase
import com.dobby.backend.domain.gateway.MemberGateway
import com.dobby.backend.domain.gateway.feign.NaverAuthGateway
import com.dobby.backend.domain.gateway.TokenGateway
Expand Down
Loading
Loading