-
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 #68 from DSM-PICK/32-add-application-ok-or-no
🔀 :: (PICK-32) add application ok or no
- Loading branch information
Showing
22 changed files
with
224 additions
and
57 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
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/dsm/pick2024/domain/admin/facade/AdminFacade.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,22 @@ | ||
package dsm.pick2024.domain.admin.facade | ||
|
||
import dsm.pick2024.domain.admin.domain.Admin | ||
import dsm.pick2024.domain.admin.exception.AdminNotFoundException | ||
import dsm.pick2024.domain.admin.port.`in`.AdminFacadeUseCase | ||
import dsm.pick2024.domain.admin.port.out.FindByAdminIdPort | ||
import org.springframework.security.core.context.SecurityContextHolder | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class AdminFacade( | ||
private val findByAdminIdPort: FindByAdminIdPort | ||
) : AdminFacadeUseCase { | ||
|
||
override fun currentUser(): Admin { | ||
val adminId = SecurityContextHolder.getContext().authentication.name | ||
return getAdminByAdminId(adminId) | ||
} | ||
|
||
override fun getAdminByAdminId(adminId: String) = | ||
findByAdminIdPort.findByAdminId(adminId) ?: throw AdminNotFoundException | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/dsm/pick2024/domain/admin/port/in/AdminFacadeUseCase.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 dsm.pick2024.domain.admin.port.`in` | ||
|
||
import dsm.pick2024.domain.admin.domain.Admin | ||
|
||
interface AdminFacadeUseCase { | ||
fun currentUser(): Admin | ||
|
||
fun getAdminByAdminId(adminId: String): Admin? | ||
} |
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
...tlin/dsm/pick2024/domain/application/exception/EarlyReturnApplicationNotFoundException.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 dsm.pick2024.domain.application.exception | ||
|
||
import dsm.pick2024.global.error.exception.ErrorCode | ||
import dsm.pick2024.global.error.exception.PickException | ||
|
||
object EarlyReturnApplicationNotFoundException : PickException( | ||
ErrorCode.EARLY_RETURN_NOT_FOUND | ||
) |
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
12 changes: 9 additions & 3 deletions
12
...in/kotlin/dsm/pick2024/domain/application/persistence/repository/EarlyReturnRepository.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 dsm.pick2024.domain.application.persistence.repository | ||
|
||
import dsm.pick2024.domain.application.entity.EarlyReturnJpaEntity | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import java.util.UUID | ||
import org.springframework.data.repository.Repository | ||
import java.util.* | ||
|
||
interface EarlyReturnRepository : JpaRepository<EarlyReturnJpaEntity, UUID> { | ||
interface EarlyReturnRepository : Repository<EarlyReturnJpaEntity, UUID> { | ||
fun existsByUsername(username: String): Boolean | ||
|
||
fun findById(id: UUID): EarlyReturnJpaEntity | ||
|
||
fun deleteById(id: UUID) | ||
|
||
fun save(entity: EarlyReturnJpaEntity) | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/dsm/pick2024/domain/application/port/in/StatusEarlyReturnUseCase.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 dsm.pick2024.domain.application.port.`in` | ||
|
||
import dsm.pick2024.domain.application.enums.Status | ||
import java.util.UUID | ||
|
||
interface StatusEarlyReturnUseCase { | ||
fun statusEarlyReturn(status: Status, id: UUID) | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/dsm/pick2024/domain/application/port/out/DeleteEarlyReturnApplicationPort.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,7 @@ | ||
package dsm.pick2024.domain.application.port.out | ||
|
||
import java.util.UUID | ||
|
||
interface DeleteEarlyReturnApplicationPort { | ||
fun deleteById(id: UUID) | ||
} |
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
src/main/kotlin/dsm/pick2024/domain/application/port/out/FindEarlyReturnByIdPort.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 dsm.pick2024.domain.application.port.out | ||
|
||
import dsm.pick2024.domain.application.domain.EarlyReturn | ||
import java.util.UUID | ||
|
||
interface FindEarlyReturnByIdPort { | ||
fun findById(id: UUID): EarlyReturn | ||
} |
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
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/dsm/pick2024/domain/application/service/StatusEarlyReturnService.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,37 @@ | ||
package dsm.pick2024.domain.application.service | ||
|
||
import dsm.pick2024.domain.admin.port.`in`.AdminFacadeUseCase | ||
import dsm.pick2024.domain.application.enums.Status | ||
import dsm.pick2024.domain.application.port.`in`.StatusEarlyReturnUseCase | ||
import dsm.pick2024.domain.application.port.out.DeleteEarlyReturnApplicationPort | ||
import dsm.pick2024.domain.application.port.out.FindEarlyReturnByIdPort | ||
import dsm.pick2024.domain.application.port.out.SaveEarlyReturnPort | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
import java.util.UUID | ||
|
||
@Service | ||
class StatusEarlyReturnService( | ||
private val adminFacadeUseCase: AdminFacadeUseCase, | ||
private val saveEarlyReturnPort: SaveEarlyReturnPort, | ||
private val findEarlyReturnByIdPort: FindEarlyReturnByIdPort, | ||
private val deleteEarlyReturnApplicationPort: DeleteEarlyReturnApplicationPort | ||
) : StatusEarlyReturnUseCase { | ||
|
||
@Transactional | ||
override fun statusEarlyReturn(status: Status, id: UUID) { | ||
val admin = adminFacadeUseCase.currentUser() | ||
|
||
if (Status.NO == status) { | ||
deleteEarlyReturnApplicationPort.deleteById(id) | ||
} | ||
|
||
val earlyReturn = findEarlyReturnByIdPort.findById(id) | ||
val update = earlyReturn.copy( | ||
teacherName = admin.name, | ||
status = status | ||
) | ||
|
||
saveEarlyReturnPort.save(update) | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/dsm/pick2024/global/security/auth/AdminDetailsService.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,16 @@ | ||
package dsm.pick2024.global.security.auth | ||
|
||
import dsm.pick2024.domain.admin.port.`in`.AdminFacadeUseCase | ||
import org.springframework.security.core.userdetails.UserDetails | ||
import org.springframework.security.core.userdetails.UserDetailsService | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class AdminDetailsService( | ||
private val adminFacadeUseCase: AdminFacadeUseCase | ||
) : UserDetailsService { | ||
override fun loadUserByUsername(username: String): UserDetails { | ||
val admin = adminFacadeUseCase.getAdminByAdminId(username) | ||
return AuthDetails(admin!!.name) | ||
} | ||
} |
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
Oops, something went wrong.