-
Notifications
You must be signed in to change notification settings - Fork 0
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 #144 from TeamMiso/develop
master 로 머지
- Loading branch information
Showing
7 changed files
with
103 additions
and
1 deletion.
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
7 changes: 6 additions & 1 deletion
7
src/main/kotlin/andreas311/miso/domain/inquiry/repository/InquiryRepository.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,12 +1,17 @@ | ||
package andreas311.miso.domain.inquiry.repository | ||
|
||
import andreas311.miso.domain.inquiry.entity.Inquiry | ||
import andreas311.miso.domain.inquiry.enums.InquiryStatus | ||
import andreas311.miso.domain.user.entity.User | ||
import org.springframework.data.repository.CrudRepository | ||
|
||
interface InquiryRepository : CrudRepository<Inquiry, Long> { | ||
|
||
fun findAllByOrderByCreatedDateDesc(): List<Inquiry> | ||
|
||
fun findByUserOrderByCreatedDateDesc(user: User): List<Inquiry>? | ||
fun findByUserOrderByCreatedDateDesc(user: User): List<Inquiry> | ||
|
||
fun findAllByInquiryStatusOrderByCreatedDateDesc(inquiryStatus: InquiryStatus): List<Inquiry> | ||
|
||
fun findByUserAndInquiryStatusOrderByCreatedDateDesc(user: User, inquiryStatus: InquiryStatus): List<Inquiry> | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/andreas311/miso/domain/inquiry/service/ListFilterInquiryService.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,9 @@ | ||
package andreas311.miso.domain.inquiry.service | ||
|
||
import andreas311.miso.domain.inquiry.enums.InquiryStatus | ||
import andreas311.miso.domain.inquiry.presentation.data.response.ListInquiryResponseDto | ||
|
||
interface ListFilterInquiryService { | ||
|
||
fun execute(inquiryStatus: InquiryStatus): ListInquiryResponseDto | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/andreas311/miso/domain/inquiry/service/ListInquiryService.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 andreas311.miso.domain.inquiry.service | ||
|
||
import andreas311.miso.domain.inquiry.presentation.data.response.ListInquiryResponseDto | ||
|
||
interface ListInquiryService { | ||
|
||
fun execute(): ListInquiryResponseDto | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/andreas311/miso/domain/inquiry/service/impl/ListFilterInquiryServiceImpl.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,33 @@ | ||
package andreas311.miso.domain.inquiry.service.impl | ||
|
||
import andreas311.miso.domain.inquiry.enums.InquiryStatus | ||
import andreas311.miso.domain.inquiry.presentation.data.response.InquiryResponseDto | ||
import andreas311.miso.domain.inquiry.presentation.data.response.ListInquiryResponseDto | ||
import andreas311.miso.domain.inquiry.repository.InquiryRepository | ||
import andreas311.miso.domain.inquiry.service.ListFilterInquiryService | ||
import andreas311.miso.domain.user.enums.Role | ||
import andreas311.miso.global.annotation.ReadOnlyService | ||
import andreas311.miso.global.util.UserUtil | ||
|
||
@ReadOnlyService | ||
class ListFilterInquiryServiceImpl( | ||
private val userUtil: UserUtil, | ||
private val inquiryRepository: InquiryRepository | ||
) : ListFilterInquiryService { | ||
|
||
override fun execute(inquiryStatus: InquiryStatus): ListInquiryResponseDto { | ||
|
||
val user = userUtil.currentUser() | ||
|
||
val inquiry = | ||
if (user.role.equals(Role.ROLE_USER)) { | ||
inquiryRepository.findByUserAndInquiryStatusOrderByCreatedDateDesc(user, inquiryStatus) | ||
} else { | ||
inquiryRepository.findAllByInquiryStatusOrderByCreatedDateDesc(inquiryStatus) | ||
} | ||
|
||
return ListInquiryResponseDto( | ||
inquiryList = inquiry.map { InquiryResponseDto(it) } | ||
) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/andreas311/miso/domain/inquiry/service/impl/ListInquiryServiceImpl.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,32 @@ | ||
package andreas311.miso.domain.inquiry.service.impl | ||
|
||
import andreas311.miso.domain.inquiry.presentation.data.response.InquiryResponseDto | ||
import andreas311.miso.domain.inquiry.presentation.data.response.ListInquiryResponseDto | ||
import andreas311.miso.domain.inquiry.repository.InquiryRepository | ||
import andreas311.miso.domain.inquiry.service.ListInquiryService | ||
import andreas311.miso.domain.user.enums.Role | ||
import andreas311.miso.global.annotation.ReadOnlyService | ||
import andreas311.miso.global.util.UserUtil | ||
|
||
@ReadOnlyService | ||
class ListInquiryServiceImpl( | ||
private val userUtil: UserUtil, | ||
private val inquiryRepository: InquiryRepository | ||
) : ListInquiryService { | ||
|
||
override fun execute(): ListInquiryResponseDto { | ||
|
||
val user = userUtil.currentUser() | ||
|
||
val inquiry = | ||
if (user.role.equals(Role.ROLE_USER)) { | ||
inquiryRepository.findByUserOrderByCreatedDateDesc(user) | ||
} else { | ||
inquiryRepository.findAllByOrderByCreatedDateDesc() | ||
} | ||
|
||
return ListInquiryResponseDto( | ||
inquiryList = inquiry.map { InquiryResponseDto(it) } | ||
) | ||
} | ||
} |
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