forked from wine-area/DMS-Backend
-
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.
- Loading branch information
1 parent
5b5fa46
commit 2a8c06e
Showing
8 changed files
with
134 additions
and
15 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
dms-core/src/main/kotlin/team/aliens/dms/domain/studyroom/dto/UpdateStudyRoomRequest.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 team.aliens.dms.domain.studyroom.dto | ||
|
||
import team.aliens.dms.domain.student.model.Sex | ||
import team.aliens.dms.domain.studyroom.model.StudyRoom | ||
|
||
data class UpdateStudyRoomRequest( | ||
val floor: Int, | ||
val name: String, | ||
val totalWidthSize: Int, | ||
val totalHeightSize: Int, | ||
val eastDescription: String, | ||
val westDescription: String, | ||
val southDescription: String, | ||
val northDescription: String, | ||
val availableSex: String, | ||
val availableGrade: Int | ||
) { | ||
|
||
fun toStudyRoom(studyRoom: StudyRoom) = | ||
studyRoom.copy( | ||
name = name, | ||
floor = floor, | ||
widthSize = totalWidthSize, | ||
heightSize = totalHeightSize, | ||
availableSex = Sex.valueOf(availableSex), | ||
availableGrade = availableGrade, | ||
eastDescription = eastDescription, | ||
westDescription = westDescription, | ||
southDescription = southDescription, | ||
northDescription = northDescription | ||
) | ||
} |
33 changes: 33 additions & 0 deletions
33
dms-core/src/main/kotlin/team/aliens/dms/domain/studyroom/dto/UpdateStudyRoomSeatsRequest.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 team.aliens.dms.domain.studyroom.dto | ||
|
||
import team.aliens.dms.domain.studyroom.model.Seat | ||
import team.aliens.dms.domain.studyroom.model.SeatStatus | ||
import java.util.UUID | ||
|
||
data class UpdateStudyRoomSeatsRequest( | ||
val seats: List<SeatRequest> | ||
) { | ||
val availableHeadCount: Int = seats.count { | ||
SeatStatus.AVAILABLE == SeatStatus.valueOf(it.status) | ||
} | ||
|
||
data class SeatRequest( | ||
val widthLocation: Int, | ||
val heightLocation: Int, | ||
val number: Int?, | ||
val typeId: UUID?, | ||
val status: String | ||
) | ||
|
||
fun toSeats(studyRoomId: UUID) = | ||
seats.map { | ||
Seat( | ||
studyRoomId = studyRoomId, | ||
typeId = it.typeId, | ||
widthLocation = it.widthLocation, | ||
heightLocation = it.heightLocation, | ||
number = it.number, | ||
status = SeatStatus.valueOf(it.status) | ||
) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...re/src/main/kotlin/team/aliens/dms/domain/studyroom/dto/UpdateStudyRoomTimeSlotRequest.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 team.aliens.dms.domain.studyroom.dto | ||
|
||
import team.aliens.dms.domain.studyroom.model.StudyRoomTimeSlot | ||
import java.util.UUID | ||
|
||
data class UpdateStudyRoomTimeSlotRequest( | ||
val timeSlotIds: List<UUID> | ||
) { | ||
fun toStudyRoomTimeSlots(studyRoomId: UUID) = | ||
timeSlotIds.map { | ||
StudyRoomTimeSlot( | ||
studyRoomId = studyRoomId, | ||
timeSlotId = it | ||
) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
dms-core/src/main/kotlin/team/aliens/dms/domain/studyroom/usecase/CreateStudyRoomUseCase.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
27 changes: 27 additions & 0 deletions
27
...e/src/main/kotlin/team/aliens/dms/domain/studyroom/usecase/UpdateStudyRoomSeatsUseCase.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,27 @@ | ||
package team.aliens.dms.domain.studyroom.usecase | ||
|
||
import team.aliens.dms.common.annotation.UseCase | ||
import team.aliens.dms.domain.studyroom.dto.UpdateStudyRoomSeatsRequest | ||
import team.aliens.dms.domain.studyroom.service.StudyRoomService | ||
import java.util.UUID | ||
|
||
@UseCase | ||
class UpdateStudyRoomSeatsUseCase( | ||
private val studyRoomService: StudyRoomService | ||
) { | ||
|
||
fun execute(request: UpdateStudyRoomSeatsRequest, studyRoomId: UUID) { | ||
val studyRoom = studyRoomService.getStudyRoom(studyRoomId) | ||
|
||
studyRoomService.saveStudyRoom( | ||
studyRoom.copy( | ||
availableHeadcount = request.availableHeadCount | ||
) | ||
) | ||
|
||
studyRoomService.updateSeatsByStudyRoom( | ||
studyRoomId = studyRoom.id, | ||
seats = request.toSeats(studyRoom.id) | ||
) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...rc/main/kotlin/team/aliens/dms/domain/studyroom/usecase/UpdateStudyRoomTimeSlotUseCase.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 team.aliens.dms.domain.studyroom.usecase | ||
|
||
import team.aliens.dms.common.annotation.UseCase | ||
import team.aliens.dms.domain.studyroom.dto.UpdateStudyRoomTimeSlotRequest | ||
import team.aliens.dms.domain.studyroom.service.StudyRoomService | ||
import java.util.UUID | ||
|
||
@UseCase | ||
class UpdateStudyRoomTimeSlotUseCase( | ||
private val studyRoomService: StudyRoomService | ||
) { | ||
|
||
fun execute(request: UpdateStudyRoomTimeSlotRequest, studyRoomId: UUID) { | ||
val studyRoom = studyRoomService.getStudyRoom(studyRoomId) | ||
|
||
studyRoomService.updateTimeSlotsByStudyRoom( | ||
studyRoomId = studyRoomId, | ||
studyRoomTimeSlots = request.toStudyRoomTimeSlots(studyRoom.id) | ||
) | ||
} | ||
} |
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