-
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 #77 from KUSITMS-29th-TEAM-B/feat/flight-63
feat: JD 조회 API 구현
- Loading branch information
Showing
20 changed files
with
327 additions
and
9 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
21 changes: 21 additions & 0 deletions
21
Api-Module/src/main/kotlin/com/bamyanggang/apimodule/common/dto/SliceResponse.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.common.dto | ||
|
||
import com.bamyanggang.domainmodule.common.pagination.SliceDomain | ||
|
||
data class SliceResponse<T>( | ||
val content: List<T>, | ||
val page: Int, | ||
val size: Int, | ||
val hasNext: Boolean | ||
) { | ||
companion object { | ||
fun <T> from(slice: SliceDomain<T>): SliceResponse<T> { | ||
return SliceResponse( | ||
content = slice.content, | ||
page = slice.pageNumber, | ||
size = slice.pageSize, | ||
hasNext = slice.hasNext | ||
) | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../com/bamyanggang/apimodule/domain/jobDescription/application/dto/GetJobDescriptionInfo.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,20 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.application.dto | ||
|
||
import com.bamyanggang.domainmodule.domain.jobDescription.enums.WriteStatus | ||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
class GetJobDescriptionInfo { | ||
|
||
data class Response( | ||
val jobDescriptionId: UUID, | ||
val remainingDate: Int, | ||
val enterpriseName: String, | ||
val title: String, | ||
val writeStatus: WriteStatus, | ||
val createdAt: LocalDateTime, | ||
val startedAt: LocalDateTime, | ||
val endedAt: LocalDateTime, | ||
) | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...ggang/apimodule/domain/jobDescription/application/service/JobDescriptionInfoGetService.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,48 @@ | ||
package com.bamyanggang.apimodule.domain.jobDescription.application.service | ||
|
||
import com.bamyanggang.apimodule.common.dto.SliceResponse | ||
import com.bamyanggang.apimodule.common.getAuthenticationPrincipal | ||
import com.bamyanggang.apimodule.domain.jobDescription.application.dto.GetJobDescriptionInfo | ||
import com.bamyanggang.domainmodule.common.pagination.SliceDomain | ||
import com.bamyanggang.domainmodule.domain.jobDescription.enums.SortType | ||
import com.bamyanggang.domainmodule.domain.jobDescription.enums.WriteStatus | ||
import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyReader | ||
import com.bamyanggang.domainmodule.domain.jobDescription.service.JobDescriptionReader | ||
import org.springframework.data.domain.Pageable | ||
import org.springframework.data.domain.SliceImpl | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
|
||
@Service | ||
class JobDescriptionInfoGetService( | ||
private val jobDescriptionReader: JobDescriptionReader, | ||
private val applyReader: ApplyReader | ||
) { | ||
|
||
@Transactional(readOnly = true) | ||
fun getJobDescriptionInfo(pageable: Pageable, writeStatus: WriteStatus?, sortType: SortType?): SliceResponse<GetJobDescriptionInfo.Response> { | ||
return getAuthenticationPrincipal().let{ userId -> | ||
val jobDescriptions = jobDescriptionReader.readJobDescriptionByUserIdAndSortType(userId, pageable.pageNumber, pageable.pageSize, sortType) | ||
|
||
val jobDescriptionInfoResponses = jobDescriptions.content.map{ jobDescription -> | ||
val apply = applyReader.readApplyByJobDescriptionId(jobDescription.id) | ||
GetJobDescriptionInfo.Response( | ||
jobDescription.id, | ||
jobDescription.getRemainingDate(), | ||
jobDescription.enterpriseName, | ||
jobDescription.title, | ||
apply?.writeStatus?: WriteStatus.NOT_APPLIED, | ||
jobDescription.createdAt, | ||
jobDescription.startedAt, | ||
jobDescription.endedAt | ||
) | ||
} | ||
|
||
val jobDescriptionsSlice = SliceDomain(jobDescriptionInfoResponses, jobDescriptions.pageNumber, jobDescriptions.pageSize, jobDescriptions.hasNext) | ||
SliceResponse.from(jobDescriptionsSlice) | ||
} | ||
} | ||
|
||
|
||
} |
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
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
8 changes: 8 additions & 0 deletions
8
Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/common/pagination/SliceDomain.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,8 @@ | ||
package com.bamyanggang.domainmodule.common.pagination | ||
|
||
data class SliceDomain<T>( | ||
val content: List<T>, | ||
val pageNumber: Int, | ||
val pageSize: Int, | ||
val hasNext: Boolean | ||
) |
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
6 changes: 6 additions & 0 deletions
6
...dule/src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/enums/SortType.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.domainmodule.domain.jobDescription.enums | ||
|
||
enum class SortType { | ||
CREATED, // 등록순 | ||
ENDED // 마감순 | ||
} |
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
3 changes: 3 additions & 0 deletions
3
...n/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/repository/ApplyRepository.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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package com.bamyanggang.domainmodule.domain.jobDescription.repository | ||
|
||
import com.bamyanggang.domainmodule.domain.jobDescription.aggregate.Apply | ||
import java.util.* | ||
|
||
interface ApplyRepository { | ||
fun save(apply: Apply) | ||
|
||
fun findByJobDescriptionId(jobDescriptionId: UUID): Apply? | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...com/bamyanggang/domainmodule/domain/jobDescription/repository/JobDescriptionRepository.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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
package com.bamyanggang.domainmodule.domain.jobDescription.repository | ||
|
||
import com.bamyanggang.domainmodule.common.pagination.SliceDomain | ||
import com.bamyanggang.domainmodule.domain.jobDescription.aggregate.JobDescription | ||
import java.util.* | ||
|
||
interface JobDescriptionRepository { | ||
|
||
fun save(jobDescription: JobDescription) | ||
|
||
fun findAllByUserIdAndSortByCreatedAt(userId: UUID, page: Int, size: Int): SliceDomain<JobDescription> | ||
|
||
fun findAllByUserId(userId: UUID, page: Int, size: Int): SliceDomain<JobDescription> | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/service/ApplyReader.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,17 @@ | ||
package com.bamyanggang.domainmodule.domain.jobDescription.service | ||
|
||
import com.bamyanggang.domainmodule.domain.jobDescription.aggregate.Apply | ||
import com.bamyanggang.domainmodule.domain.jobDescription.repository.ApplyRepository | ||
import org.springframework.stereotype.Service | ||
import java.util.* | ||
|
||
@Service | ||
class ApplyReader( | ||
private val applyRepository: ApplyRepository | ||
) { | ||
|
||
fun readApplyByJobDescriptionId(JobDescriptionId: UUID): Apply?{ | ||
return applyRepository.findByJobDescriptionId(JobDescriptionId) | ||
} | ||
|
||
} |
Oops, something went wrong.