Skip to content

Commit

Permalink
fix : 깃 충돌 해결(#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
isprogrammingfun committed May 17, 2024
2 parents e7a3991 + d70d571 commit a9d27d3
Show file tree
Hide file tree
Showing 35 changed files with 646 additions and 52 deletions.
1 change: 0 additions & 1 deletion .github/workflows/CI-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ jobs:
- name: Build With Gradle
run: |
./gradlew build
./gradlew bootJar
27 changes: 27 additions & 0 deletions Api-Module/src/docs/asciidoc/Tag.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[[Tag-API]]
== Tag-API

[[CreateParentTagTest]]
=== 상위 태그 등록 API

operation::TagControllerTest/createParentTagTest/[snippets='http-request,request-fields,http-response,response-fields']

[[CreateChildTagTest]]
=== 하위 태그 등록 API

operation::TagControllerTest/createChildTagTest/[snippets='http-request,path-parameters,request-fields,http-response,response-fields']

[[duplicatedParentTagTest]]
=== 상위 태그 이름 중복 예외

operation::TagControllerTest/duplicatedParentTagTest/[snippets='http-request,request-fields,http-response,response-fields']

[[duplicatedChildTagTest]]
=== 하위 태그 이름 중복 예외

operation::TagControllerTest/duplicatedChildTagTest/[snippets='http-request,path-parameters,request-fields,http-response,response-fields']

[[overTagCountLimitTest]]
=== 태그 개수 제한 이상 등록 요청 예외

operation::TagControllerTest/overTagCountLimitTest/[snippets='http-request,path-parameters,request-fields,http-response,response-fields']
1 change: 1 addition & 0 deletions Api-Module/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
include::Auth.adoc[]
include::User.adoc[]
include::StrongPoint.adoc[]
include::Tag.adoc[]
include::JobDescription.adoc[]


Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.bamyanggang.apimodule.domain.strongpoint.application.service

import com.bamyanggang.apimodule.common.getAuthenticationPrincipal
import com.bamyanggang.apimodule.domain.strongpoint.application.dto.CreateStrongPoint
import com.bamyanggang.domainmodule.domain.strongpoint.aggregate.StrongPoint
import com.bamyanggang.domainmodule.domain.strongpoint.exception.StrongPointException
import com.bamyanggang.domainmodule.domain.strongpoint.service.StrongPointAppender
import com.bamyanggang.domainmodule.domain.strongpoint.service.StrongPointReader
Expand All @@ -15,13 +16,19 @@ class StrongPointCreateService(
fun createStrongPoint(request: CreateStrongPoint.Request): CreateStrongPoint.Response {
return getAuthenticationPrincipal()
.also {
strongPointReader.findAllByUserId(it).forEach { strongPoint ->
if(strongPoint.isDuplicated(request.name))
throw StrongPointException.DuplicatedStrongPointName()
}
val userStrongPoints = strongPointReader.readAllByUserId(it)
validateDuplicatedStrongPointName(userStrongPoints, request.name)
}.let {
val newStrongPointId = strongPointAppender.appendStrongPoint(request.name, it)
CreateStrongPoint.Response(newStrongPointId)
}
}
}

private fun validateDuplicatedStrongPointName(userStrongPoints: List<StrongPoint>, name: String) {
userStrongPoints.forEach { strongPoint ->
if (strongPoint.isDuplicated(name)) {
throw StrongPointException.DuplicatedStrongPointName()
}
}
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.bamyanggang.apimodule.domain.tag.application.dto

import java.util.UUID

class CreateTag {
data class Request(val name: String)
data class Response(val id: UUID)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.bamyanggang.apimodule.domain.tag.application.service

import com.bamyanggang.apimodule.common.getAuthenticationPrincipal
import com.bamyanggang.apimodule.domain.tag.application.dto.CreateTag
import com.bamyanggang.domainmodule.domain.tag.aggregate.Tag
import com.bamyanggang.domainmodule.domain.tag.exception.TagException
import com.bamyanggang.domainmodule.domain.tag.service.TagAppender
import com.bamyanggang.domainmodule.domain.tag.service.TagReader
import org.springframework.stereotype.Service
import java.util.*

@Service
class TagCreateService(
private val tagAppender: TagAppender,
private val tagReader: TagReader,
) {
fun createChildTag(request: CreateTag.Request, parentTagId: UUID): CreateTag.Response {
return getAuthenticationPrincipal()
.also {
val userChildTags = tagReader.readAllChildTagsByUserId(it, parentTagId)
validateTagCountLimit(userChildTags.size)
validateDuplicatedName(userChildTags, request.name)
}.let {
val newChildTagId = tagAppender.appendChildTag(request.name, parentTagId, it)
CreateTag.Response(newChildTagId)
}
}

fun createParentTag(request: CreateTag.Request): CreateTag.Response {
return getAuthenticationPrincipal()
.also {
val userParentTags = tagReader.readAllParentTagsByUserId(it)
validateTagCountLimit(userParentTags.size)
validateDuplicatedName(userParentTags, request.name)
}.let {
val newParentTagId = tagAppender.appendParentTag(request.name, it)
CreateTag.Response(newParentTagId)
}
}

private fun validateDuplicatedName(userParentTags: List<Tag>, name: String) {
userParentTags.forEach {
if (it.isDuplicatedName(name)) {
throw TagException.DuplicatedTagName()
}
}
}

private fun validateTagCountLimit(size: Int) {
val limit = 10
if (size > limit) {
throw TagException.OverTagCountLimit()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.bamyanggang.apimodule.domain.tag.application.service

import com.bamyanggang.domainmodule.domain.tag.service.TagRemover
import org.springframework.stereotype.Service
import java.util.*

@Service
class TagDeleteService(
private val tagRemover: TagRemover
) {
fun deleteTag(tagId: UUID) {
tagRemover.removeTag(tagId)
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.bamyanggang.apimodule.domain.tag.presentation

object TagApi {
const val BASE_URL = "/api/tags"
const val TAG_PATH_VARIABLE_URL = "$BASE_URL/{tagId}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.bamyanggang.apimodule.domain.tag.presentation

import com.bamyanggang.apimodule.domain.tag.application.dto.CreateTag
import com.bamyanggang.apimodule.domain.tag.application.service.TagCreateService
import com.bamyanggang.apimodule.domain.tag.application.service.TagDeleteService
import org.springframework.web.bind.annotation.*
import java.util.*

@RestController
class TagController(
private val tagCreateService: TagCreateService,
private val tagDeleteService: TagDeleteService
) {
@PostMapping(TagApi.BASE_URL, TagApi.TAG_PATH_VARIABLE_URL)
fun createTag(
@PathVariable("tagId", required = false) parentTagId: UUID?,
@RequestBody request: CreateTag.Request,
): CreateTag.Response {
return when {
parentTagId == null -> tagCreateService.createParentTag(request)
else -> tagCreateService.createChildTag(request, parentTagId)
}
}

@DeleteMapping(TagApi.TAG_PATH_VARIABLE_URL)
fun deleteTag( @PathVariable("tagId", required = false) tagId: UUID) {
tagDeleteService.deleteTag(tagId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ private val jwtEntryPoint: JwtEntryPoint) {
}
return httpSecurity.build()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ class JobDescriptionControllerTest : BaseRestDocsTest() {
val createJobDescriptionResponse: CreateJobDescription.Response = generateFixture {
it.set("jobDescriptionId", UUID.randomUUID())
}

given(jobDescriptionCreateService.createJobDescription(createJobDescriptionRequest)).willReturn(createJobDescriptionResponse)

val request = RestDocumentationRequestBuilders.post(JobDescriptionApi.BASE_URL)
.header("Authorization", "Bearer Access Token")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(objectMapper.writeValueAsString(createJobDescriptionRequest))
given(jobDescriptionCreateService.createJobDescription(createJobDescriptionRequest)).willReturn(createJobDescriptionResponse)
//when
val result = mockMvc.perform(request)
//then
Expand Down Expand Up @@ -88,11 +90,13 @@ class JobDescriptionControllerTest : BaseRestDocsTest() {
it.set("startedAt", LocalDateTime.now())
it.set("endedAt", LocalDateTime.now())
}

given(jobDescriptionCreateService.createJobDescription(createJobDescriptionRequest)).willThrow(IllegalArgumentException("내용은 필수입니다."))

val request = RestDocumentationRequestBuilders.post(JobDescriptionApi.BASE_URL)
.header("Authorization", "Bearer Access Token")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(objectMapper.writeValueAsString(createJobDescriptionRequest))
given(jobDescriptionCreateService.createJobDescription(createJobDescriptionRequest)).willThrow(IllegalArgumentException("내용은 필수입니다."))

//when
val result = mockMvc.perform(request)
Expand Down Expand Up @@ -124,11 +128,13 @@ class JobDescriptionControllerTest : BaseRestDocsTest() {
it.set("startedAt", LocalDateTime.now())
it.set("endedAt", LocalDateTime.now().minusDays(1))
}

given(jobDescriptionCreateService.createJobDescription(createJobDescriptionRequest)).willThrow(IllegalArgumentException("시작일은 종료일보다 빨라야 합니다."))

val request = RestDocumentationRequestBuilders.post(JobDescriptionApi.BASE_URL)
.header("Authorization", "Bearer Access Token")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(objectMapper.writeValueAsString(createJobDescriptionRequest))
given(jobDescriptionCreateService.createJobDescription(createJobDescriptionRequest)).willThrow(IllegalArgumentException("시작일은 종료일보다 빨라야 합니다."))

//when
val result = mockMvc.perform(request)
Expand Down Expand Up @@ -197,11 +203,13 @@ class JobDescriptionControllerTest : BaseRestDocsTest() {
it.set("title", "")
it.set("contents", listOf(createApplyContentRequest))
}

given(applyCreateService.createApply(createApplyRequest, jobDescriptionId)).willThrow(IllegalArgumentException("제목은 필수입니다."))

val request = RestDocumentationRequestBuilders.post(JobDescriptionApi.APPLY, jobDescriptionId)
.header("Authorization", "Bearer Access Token")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(objectMapper.writeValueAsString(createApplyRequest))
given(applyCreateService.createApply(createApplyRequest, jobDescriptionId)).willThrow(IllegalArgumentException("제목은 필수입니다."))

//when
val result = mockMvc.perform(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.bamyanggang.apimodule.domain.strongpoint.presentation
import com.bamyanggang.apimodule.BaseRestDocsTest
import com.bamyanggang.apimodule.domain.strongpoint.application.dto.CreateStrongPoint
import com.bamyanggang.commonmodule.fixture.generateFixture
import com.bamyanggang.domainmodule.domain.strongpoint.exception.StrongPointException
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.mockito.BDDMockito.given
Expand Down Expand Up @@ -46,16 +45,4 @@ class StrongPointControllerTest : BaseRestDocsTest() {
)
)
}

@Test
@DisplayName("중복된 역량 키워드 등록 시 등록하지 않고 예외를 반환한다.")
fun duplicatedStrongPointNameTest() {

val duplicatedRequest = CreateStrongPoint.Request("duplicatedName")

strongPointController.createStrongPoint(duplicatedRequest)
strongPointController.createStrongPoint(duplicatedRequest)

given(strongPointController.createStrongPoint(duplicatedRequest)).willThrow(StrongPointException.DuplicatedStrongPointName())
}
}
Loading

0 comments on commit a9d27d3

Please sign in to comment.