-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from KUSITMS-29th-TEAM-B/feat/flight-56
feat: JD 등록, 자소서 등록 API 구현(#56)
- Loading branch information
Showing
50 changed files
with
1,509 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,3 @@ jobs: | |
- name: Build With Gradle | ||
run: | | ||
./gradlew build | ||
./gradlew bootJar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[[Job-Description-API]] | ||
== Job-Description-API | ||
|
||
[[CREATE-JD]] | ||
=== JD 등록 | ||
|
||
operation::JobDescriptionControllerTest/createJobDescription[snippets='http-request,request-headers,request-fields,http-response,response-fields'] | ||
|
||
[[CREATE-JD-EXCEPTION]] | ||
==== JD 등록 시 예외 (빈 값, 또는 NULL이 들어올 경우) | ||
|
||
operation::JobDescriptionControllerTest/createJobDescriptionWithEmptyValue[snippets='http-request,request-headers,http-response'] | ||
|
||
[[CREATE-JD-EXCEPTION-2]] | ||
==== JD 등록 시 예외 (시작일이 종료일보다 늦을 경우) | ||
|
||
operation::JobDescriptionControllerTest/createJobDescriptionWithInvalidDate[snippets='http-request,request-headers,http-response'] | ||
|
||
[[CREATE-APPLY]] | ||
=== JD 자소서 등록 | ||
|
||
operation::JobDescriptionControllerTest/createApply[snippets='http-request,request-headers,request-fields,http-response'] | ||
|
||
[[CREATE-APPLY-EXCEPTION]] | ||
==== JD 자소서 등록 시 예외 (제목이 비어있는 경우) | ||
|
||
operation::JobDescriptionControllerTest/createApplyWithEmptyTitle[snippets='http-request,request-headers,http-response'] | ||
|
||
[[CREATE-APPLY-EXCEPTION-2]] | ||
==== JD 자소서 등록 시 예외 (내용이 비어있는 경우) | ||
|
||
operation::JobDescriptionControllerTest/createApplyWithEmptyContent[snippets='http-request,request-headers,http-response'] | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...ain/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApply.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.application.dto | ||
|
||
class CreateApply { | ||
|
||
data class Request( | ||
val title: String, | ||
val contents : List<CreateApplyContent> | ||
) | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...lin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApplyContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.application.dto | ||
|
||
data class CreateApplyContent ( | ||
val question: String, | ||
val answer: String | ||
) | ||
|
21 changes: 21 additions & 0 deletions
21
...n/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateJobDescription.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.application.dto | ||
|
||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
class CreateJobDescription { | ||
|
||
data class Request( | ||
val enterpriseName: String, | ||
val title: String, | ||
val content: String, | ||
val link: String, | ||
val startedAt: LocalDateTime, | ||
val endedAt: LocalDateTime | ||
) | ||
|
||
data class Response( | ||
val jobDescriptionId: UUID | ||
) | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...com/bamyanggang/apimodule/domain/jobDescription/application/service/ApplyCreateService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.application.service | ||
|
||
import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateApply | ||
import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyAppender | ||
import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyContentAppender | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
import java.util.* | ||
|
||
@Service | ||
class ApplyCreateService( | ||
private val applyAppender: ApplyAppender, | ||
private val applyContentAppender: ApplyContentAppender | ||
) { | ||
@Transactional | ||
fun createApply(request: CreateApply.Request, jobDescriptionId: UUID) { | ||
applyAppender.appendApply( | ||
jobDescriptionId = jobDescriptionId, | ||
title = request.title | ||
).also { apply -> | ||
request.contents.forEach { content -> | ||
applyContentAppender.appendApplyContent( | ||
applyId = apply.id, | ||
question = content.question, | ||
answer = content.answer | ||
) | ||
} | ||
} | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...nggang/apimodule/domain/jobDescription/application/service/JobDescriptionCreateService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.application.service | ||
|
||
import com.bamyanggang.apimodule.common.getAuthenticationPrincipal | ||
import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateJobDescription | ||
import com.bamyanggang.domainmodule.domain.jobDescription.service.JobDescriptionAppender | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
class JobDescriptionCreateService( | ||
private val jobDescriptionAppender: JobDescriptionAppender | ||
) { | ||
|
||
@Transactional | ||
fun createJobDescription(request: CreateJobDescription.Request): CreateJobDescription.Response { | ||
getAuthenticationPrincipal().run { | ||
jobDescriptionAppender.appendJobDescription( | ||
enterpriseName = request.enterpriseName, | ||
title = request.title, | ||
content = request.content, | ||
link = request.link, | ||
startedAt = request.startedAt, | ||
endedAt = request.endedAt, | ||
userId = this | ||
) | ||
}.also { return CreateJobDescription.Response(jobDescriptionId = it.id) } | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
.../kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.presentation | ||
|
||
object JobDescriptionApi { | ||
const val BASE_URL = "/api/job-description" | ||
const val APPLY = "${BASE_URL}/apply/{jobDescriptionId}" | ||
} |
30 changes: 30 additions & 0 deletions
30
.../com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.presentation | ||
|
||
import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateApply | ||
import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateJobDescription | ||
import com.bamyanggang.apimodule.domain.jobDescription.application.service.ApplyCreateService | ||
import com.bamyanggang.apimodule.domain.jobDescription.application.service.JobDescriptionCreateService | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RestController | ||
import java.util.UUID | ||
|
||
@RestController | ||
class JobDescriptionController( | ||
private val jobDescriptionCreateService: JobDescriptionCreateService, | ||
private val applyCreateService: ApplyCreateService | ||
) { | ||
|
||
@PostMapping(JobDescriptionApi.BASE_URL) | ||
fun createJobDescription( | ||
@RequestBody request: CreateJobDescription.Request | ||
): CreateJobDescription.Response = jobDescriptionCreateService.createJobDescription(request) | ||
|
||
@PostMapping(JobDescriptionApi.APPLY) | ||
fun createApply( | ||
@PathVariable("jobDescriptionId") jobDescriptionId: UUID, | ||
@RequestBody request: CreateApply.Request | ||
) = applyCreateService.createApply(request, jobDescriptionId) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,4 @@ private val jwtEntryPoint: JwtEntryPoint) { | |
} | ||
return httpSecurity.build() | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...lin/com/bamyanggang/apimodule/domain/jobDescription/application/ApplyCreateServiceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.application | ||
|
||
import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateApply | ||
import com.bamyanggang.apimodule.domain.jobDescription.application.service.ApplyCreateService | ||
import com.bamyanggang.commonmodule.fixture.generateFixture | ||
import com.bamyanggang.domainmodule.domain.jobDescription.aggregate.Apply | ||
import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyAppender | ||
import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyContentAppender | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import java.util.* | ||
|
||
|
||
class ApplyCreateServiceTest : BehaviorSpec({ | ||
val applyAppender = mockk<ApplyAppender>() | ||
val applyContentAppender = mockk<ApplyContentAppender>() | ||
val applyCreateService = ApplyCreateService(applyAppender, applyContentAppender) | ||
|
||
given("ApplyCreateService.createApply") { | ||
`when`("request가 주어지면") { | ||
val request: CreateApply.Request = generateFixture() | ||
val jobDescriptionId: UUID = generateFixture() | ||
val apply: Apply = generateFixture() | ||
every { applyAppender.appendApply(any(), any()) } returns apply | ||
every { applyContentAppender.appendApplyContent(any(), any(), any()) } returns Unit | ||
|
||
applyCreateService.createApply(request, jobDescriptionId) | ||
|
||
then("appendApply가 호출된다.") { | ||
verify { applyAppender.appendApply( request.title,jobDescriptionId) } | ||
} | ||
|
||
then("appendApplyContent가 호출된다.") { | ||
request.contents.forEach { content -> | ||
verify { applyContentAppender.appendApplyContent(apply.id, content.question, content.answer) } | ||
} | ||
} | ||
} | ||
} | ||
}) |
60 changes: 60 additions & 0 deletions
60
...amyanggang/apimodule/domain/jobDescription/application/JobDescriptionCreateServiceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.application | ||
|
||
import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateJobDescription | ||
import com.bamyanggang.apimodule.domain.jobDescription.application.service.JobDescriptionCreateService | ||
import com.bamyanggang.commonmodule.fixture.generateFixture | ||
import com.bamyanggang.domainmodule.domain.jobDescription.service.JobDescriptionAppender | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.mockkStatic | ||
import org.springframework.security.core.Authentication | ||
import org.springframework.security.core.context.SecurityContext | ||
import org.springframework.security.core.context.SecurityContextHolder | ||
import io.mockk.verify | ||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
/** | ||
* Todo: securityContext를 어떻게 처리하지? | ||
*/ | ||
//class JobDescriptionCreateServiceTest : BehaviorSpec({ | ||
// val mockJobDescriptionAppender = mockk<JobDescriptionAppender>(relaxed = true) | ||
// val service = JobDescriptionCreateService(mockJobDescriptionAppender) | ||
// mockkStatic(SecurityContextHolder::class) | ||
// val securityContext = mockk<SecurityContext>() | ||
// val authentication = mockk<Authentication>() | ||
// | ||
// given("JobDescriptionCreateService.createJobDescription") { | ||
// val request: CreateJobDescription.Request = generateFixture { | ||
// it.set("enterpriseName", "기업 이름") | ||
// it.set("title", "직무 공고 제목") | ||
// it.set("content", "직무 공고 내용") | ||
// it.set("link", "직무 공고 링크") | ||
// it.set("startedAt", LocalDateTime.now()) | ||
// it.set("endedAt", LocalDateTime.now()) | ||
// } | ||
// val userId : UUID = generateFixture() | ||
// every { SecurityContextHolder.getContext() } returns securityContext | ||
// every { securityContext.authentication } returns authentication | ||
// every { authentication.principal } returns userId | ||
// | ||
// `when`("request가 주어지면") { | ||
// service.createJobDescription(request) | ||
// | ||
// then("appendJobDescription이 호출된다.") { | ||
// verify { | ||
// mockJobDescriptionAppender.appendJobDescription( | ||
// enterpriseName = request.enterpriseName, | ||
// title = request.title, | ||
// content = request.content, | ||
// link = request.link, | ||
// startedAt = request.startedAt, | ||
// endedAt = request.endedAt, | ||
// userId = userId | ||
// ) | ||
// } | ||
// } | ||
// } | ||
// } | ||
//}) |
Oops, something went wrong.