Skip to content

Commit e334afc

Browse files
feat: add create room service
1 parent e8e5d0d commit e334afc

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2023. Smart Operating Block
3+
*
4+
* Use of this source code is governed by an MIT-style
5+
* license that can be found in the LICENSE file or at
6+
* https://opensource.org/licenses/MIT.
7+
*/
8+
9+
package application.service
10+
11+
import entity.zone.Room
12+
import usecase.repository.RoomRepository
13+
14+
/**
15+
* Module that wraps all the services that orchestrate the application logic (not domain one).
16+
*/
17+
object Service {
18+
/**
19+
* Interface that models an Application Service.
20+
* An Application Service handle application logic without business elements.
21+
* @param[T] the type returned by the service.
22+
*/
23+
interface ApplicationService<out T> {
24+
/**
25+
* Method to execute the application service.
26+
* @return the result of type [T]
27+
*/
28+
fun execute(): T
29+
}
30+
31+
/**
32+
* Application Service that has the objective of creating a [room] using the [roomRepository] passed.
33+
*/
34+
class CreateRoom(private val room: Room, private val roomRepository: RoomRepository) : ApplicationService<Room?> {
35+
override fun execute(): Room? = this.roomRepository.createRoom(room)
36+
}
37+
}

0 commit comments

Comments
 (0)