-
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.
feat : JD 조회 application 계층 생성, SliceResponse 생성(#63)
- Loading branch information
1 parent
c6801a2
commit 15c3ef6
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
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) | ||
} | ||
} | ||
|
||
|
||
} |