Skip to content

Commit

Permalink
Merge branch 'feat/flight-115' of github.com:KUSITMS-29th-TEAM-B/Back…
Browse files Browse the repository at this point in the history
…end into feat/flight-115
  • Loading branch information
whereami2048 committed May 21, 2024
2 parents 6b24765 + 48858c8 commit 036e217
Show file tree
Hide file tree
Showing 51 changed files with 527 additions and 105 deletions.
2 changes: 1 addition & 1 deletion Api-Module/src/docs/asciidoc/Auth.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ operation::AuthControllerTest/reissueToken[snippets='http-request,http-response,
[[Auth-Logout]]
=== 로그아웃

operation::AuthControllerTest/logout[snippets='http-request,http-response,request-fields']
operation::AuthControllerTest/logout[snippets='http-request,request-headers,http-response']

25 changes: 20 additions & 5 deletions Api-Module/src/docs/asciidoc/Tag.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,26 @@ operation::TagControllerTest/createParentTagTest/[snippets='http-request,request

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

[[DeleteTagTest]]
=== 태그 삭제 API

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

[[GetAllTagTest]]
=== 상위 & 하위 태그 전체 조회 API

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

[[GetParentTagTest]]
=== 상위 태그 조회 API

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

[[GetChildTagTest]]
=== 하위 태그 전체 조회 API

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

[[GetTopRankTagTest]]
=== 연도 내 경험 최근 추가 순 태그 조회 API

Expand All @@ -26,16 +41,16 @@ operation::TagControllerTest/getTopRankParentTagTest/[snippets='http-request,req

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

[[GetChildTagTest]]
=== 하위 태그 전체 조회 API

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

[[GetChildTagsByFilter]]
=== 상위 태그 내 하위 태그 조회 API

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

[[GetYearsByParentTagId]]
=== 상위 태그 내 존재 연도 조회 API

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
package com.bamyanggang.apimodule.domain.experience.application.dto

import java.util.*

class ExperienceYear {
data class Response(
val years : List<Int>
val years : List<Int>,
val yearTagInfos: List<YearTagInfo>
)

data class YearTagInfo(
val year: Int,
val tags: List<TagDetail>
)

data class TagDetail(
val id: UUID,
val name: String,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,29 @@ class ExperienceGetService(
fun getAllYearsByExistExperience(): ExperienceYear.Response {
val currentUserId = getAuthenticationPrincipal()

return experienceReader.readAllYearsByExistExperience(currentUserId)
.let { ExperienceYear.Response(it) }
val years = experienceReader.readAllYearsByExistExperience(currentUserId)
val yearTagInfos = years.map { year ->
val parentTagIds = experienceReader.readByUserIDAndYearDesc(year, currentUserId)
.distinctBy { it.parentTagId }
.map { it.parentTagId }

val tagDetails = tagReader.readByIds(parentTagIds).map {
ExperienceYear.TagDetail(
id = it.id,
name = it.name
)
}

ExperienceYear.YearTagInfo(
year,
tagDetails
)
}

return ExperienceYear.Response(
years,
yearTagInfos
)
}

@Transactional(readOnly = true)
Expand All @@ -47,7 +68,7 @@ class ExperienceGetService(

@Transactional(readOnly = true)
fun getExperienceByYearAndChildTag(year: Int, childTagId: UUID): GetExperience.Response {
val experiences = experienceReader.readByYearAndChildTagId(year, childTagId).map {
val experiences = experienceReader.readByChildTagIdAndYear(year, childTagId).map {
createExperienceDetailResponse(it)
}

Expand Down Expand Up @@ -162,4 +183,12 @@ class ExperienceGetService(
)
}
}
}

fun getAllExperienceByYear(year: Int): GetExperience.Response {
val experiences = experienceReader.readByYear(year).map {
createExperienceDetailResponse(it)
}

return GetExperience.Response(experiences)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ class ExperienceController(

@GetMapping(ExperienceApi.BASE_URL)
fun getExperienceByFilter(@RequestParam("year") year: Int,
@RequestParam("parent-tag") parentTagId: UUID,
@RequestParam("parent-tag", required = false) parentTagId: UUID?,
@RequestParam("child-tag", required = false) childTagId: UUID?
) : GetExperience.Response =
when (childTagId){
null -> experienceGetService.getExperienceByYearAndParentTag(year, parentTagId)
else -> experienceGetService.getExperienceByYearAndChildTag(year, childTagId)
when {
childTagId == null && parentTagId == null -> experienceGetService.getAllExperienceByYear(year)
childTagId == null && parentTagId != null -> experienceGetService.getExperienceByYearAndParentTag(year, parentTagId)
else -> experienceGetService.getExperienceByYearAndChildTag(year, childTagId!!)
}

@GetMapping(ExperienceApi.EXPERIENCE_PATH_VARIABLE_URL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bamyanggang.apimodule.domain.jobDescription.application.dto

import com.bamyanggang.domainmodule.domain.jobDescription.enums.WriteStatus

class ApplyInfo {

sealed class Request {
Expand All @@ -10,7 +12,8 @@ class ApplyInfo {
}

data class Response(
val applyContentList: List<ContentInfo>
val applyContentList: List<ContentInfo>,
val writeStatus: WriteStatus
)

data class ContentInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.bamyanggang.apimodule.domain.jobDescription.application.service

import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateApply
import com.bamyanggang.domainmodule.domain.jobDescription.aggregate.ApplyContent
import com.bamyanggang.domainmodule.domain.jobDescription.enums.WriteStatus
import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyAppender
import com.bamyanggang.domainmodule.domain.jobDescription.service.JobDescriptionModifier
import com.bamyanggang.domainmodule.domain.jobDescription.service.JobDescriptionReader
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@ package com.bamyanggang.apimodule.domain.jobDescription.application.service

import com.bamyanggang.apimodule.domain.jobDescription.application.dto.ApplyInfo
import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyReader
import com.bamyanggang.domainmodule.domain.jobDescription.service.JobDescriptionReader
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.util.*

@Service
class ApplyInfoGetService(
private val applyReader: ApplyReader
private val applyReader: ApplyReader,
private val jobDescriptionReader: JobDescriptionReader
) {

@Transactional(readOnly = true)
fun getApplyInfo(jobDescriptionId: UUID): ApplyInfo.Response {
return applyReader.readApplyByJobDescriptionId(jobDescriptionId).contents.map {
ApplyInfo.ContentInfo(
it.question,
it.answer
)
}.let {
ApplyInfo.Response(it)
val jobDescription = jobDescriptionReader.readJobDescriptionById(jobDescriptionId)
val contents = applyReader.readApplyByJobDescriptionId(jobDescriptionId).contents.map {
ApplyInfo.ContentInfo(it.question, it.answer)
}
return ApplyInfo.Response(contents, jobDescription.writeStatus)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ class JobDescriptionInfoUpdateService(
request.link, request.startedAt, request.endedAt)
}

@Transactional
fun invoke() {
jobDescriptionModifier.invoke()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.bamyanggang.apimodule.domain.jobDescription.scheduler

import com.bamyanggang.apimodule.domain.jobDescription.application.service.JobDescriptionInfoUpdateService
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component

@Component
class UpdateWriteStatusScheduler(
private val jobDescriptionInfoUpdateService: JobDescriptionInfoUpdateService
) {

// 1분마다 돌아감
@Scheduled(cron = "0 * * * * *", zone = "Asia/Seoul")
fun changeJobDescriptionWritingStatus() = jobDescriptionInfoUpdateService.invoke()

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ class GetParentTag {
val strongPointCount: Int,
val experienceCount: Int
)

data class Years(
val years: List<Int>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.bamyanggang.apimodule.domain.tag.application.dto

import java.util.*

class GetTag {
data class Response(
val tags: List<ParentTagDetail>
)

data class ParentTagDetail(
val id: UUID,
val name: String,
val childTags: List<ChildTagDetail>
)

data class ChildTagDetail(
val id: UUID,
val name: String,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TagCreateService(
fun createChildTag(request: CreateTag.Request, parentTagId: UUID): CreateTag.Response {
return getAuthenticationPrincipal()
.also {
val userChildTags = tagReader.readAllChildTagsByUserId(it, parentTagId)
val userChildTags = tagReader.readAllChildTagsByUserIdAndParentTagId(it, parentTagId)
validateTagCountLimit(userChildTags.size)
validateDuplicatedName(userChildTags, request.name)
}.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.bamyanggang.apimodule.domain.tag.application.service
import com.bamyanggang.apimodule.common.getAuthenticationPrincipal
import com.bamyanggang.apimodule.domain.tag.application.dto.GetChildTag
import com.bamyanggang.apimodule.domain.tag.application.dto.GetParentTag
import com.bamyanggang.apimodule.domain.tag.application.dto.GetTag
import com.bamyanggang.domainmodule.domain.experience.service.ExperienceReader
import com.bamyanggang.domainmodule.domain.tag.service.TagReader
import org.springframework.stereotype.Service
Expand All @@ -28,7 +29,7 @@ class TagGetService(
@Transactional(readOnly = true)
fun getAllChildTagsByParentTagId(parentTagId: UUID): GetChildTag.Response {
val tagDetails = getAuthenticationPrincipal().let {
tagReader.readAllChildTagsByUserId(it, parentTagId).map { tag ->
tagReader.readAllChildTagsByUserIdAndParentTagId(it, parentTagId).map { tag ->
GetParentTag.TagDetail(tag.id, tag.name)
}
}
Expand All @@ -39,7 +40,7 @@ class TagGetService(
@Transactional(readOnly = true)
fun getParentTagsByYearAndLimit(year: Int, limit: Int): GetParentTag.Response {
val currentUserId = getAuthenticationPrincipal()
val topParentTagIds = experienceReader.readByYearDesc(year, currentUserId)
val topParentTagIds = experienceReader.readByUserIDAndYearDesc(year, currentUserId)
.distinctBy { it.parentTagId }
.take(limit)
.map { it.parentTagId }
Expand All @@ -54,7 +55,7 @@ class TagGetService(
@Transactional(readOnly = true)
fun getAllParentTagsByYear(year: Int): GetParentTag.TotalTagInfo {
val currentUserId = getAuthenticationPrincipal()
val experiences = experienceReader.readByYearDesc(year, currentUserId)
val experiences = experienceReader.readByUserIDAndYearDesc(year, currentUserId)

val experienceGroup = experiences.groupBy { it.parentTagId }

Expand Down Expand Up @@ -84,23 +85,60 @@ class TagGetService(

@Transactional(readOnly = true)
fun getAllChildTagsByYearAndParentTagId(year: Int, parentTagId: UUID): GetChildTag.TotalTagInfo {
val currentUserId = getAuthenticationPrincipal()
val experiences = experienceReader.readByYearDesc(year, currentUserId)
val experienceGroup = experiences.groupBy { it.childTagId }

val tagSummaries = experienceGroup.map {
val childTag = tagReader.readById(it.key)
val childTags = getAllChildTagsByParentTagId(parentTagId).tags.map { tagReader.readById(it.id) }
var totalExperienceCount = 0

val childTagDetails = childTags.map {
val experiences = experienceReader.readByChildTagIdAndYear(year, it.id)
totalExperienceCount += experiences.size
GetChildTag.ChildTagSummary(
childTag.id,
childTag.name,
it.value.size
it.id,
it.name,
experiences.size
)
}

return GetChildTag.TotalTagInfo(
experiences.size,
tagSummaries
totalExperienceCount,
childTagDetails
)
}

@Transactional(readOnly = true)
fun getAllYearsByParentTagId(parentTagId: UUID): GetParentTag.Years {
val experiences = getAuthenticationPrincipal().let {
experienceReader.readByUserIdAndParentTagId(it, parentTagId)
}

val years = experiences
.distinctBy { it.createdAt.year }
.map { it.createdAt.year }
.sorted().reversed()

return GetParentTag.Years(years)
}

@Transactional(readOnly = true)
fun getAllTags(): GetTag.Response {
val parentTags = getAuthenticationPrincipal().let {
tagReader.readAllParentTagsByUserId(it)
}

val parentTagDetails = parentTags.map {
val childTagDetails = tagReader.readChildTagsByParentTagId(it.id).map {
GetTag.ChildTagDetail(
it.id,
it.name
)
}

GetTag.ParentTagDetail(
it.id,
it.name,
childTagDetails
)
}

return GetTag.Response(parentTagDetails)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.bamyanggang.apimodule.domain.tag.presentation

object TagApi {
const val BASE_URL = "/api/tags"
const val ALL_TAGS = "${BASE_URL}/all-tags"
const val MY_PARENT_TAG_URL = "$BASE_URL/my"
const val TOP_RANK_TAG_URL = "$BASE_URL/top-rank"
const val TAG_PATH_VARIABLE_URL = "$BASE_URL/{tagId}"
const val MY_CHILD_TAG_URL = "$BASE_URL/{tagId}/my"
const val ALL_YEARS = "$BASE_URL/{parentTagId}/all-years"
}
Loading

0 comments on commit 036e217

Please sign in to comment.