-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…urrency
- Loading branch information
sedovalx
committed
Jun 14, 2015
1 parent
03dce75
commit 9dad548
Showing
7 changed files
with
74 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package config | ||
|
||
import javax.inject.Singleton | ||
|
||
import com.google.inject.AbstractModule | ||
import net.codingwell.scalaguice.ScalaModule | ||
import service.entity.{DriverServiceImpl, DriverService, CarServiceImpl, CarService} | ||
|
||
class ServiceModule extends AbstractModule with ScalaModule { | ||
override def configure(): Unit = { | ||
bind[CarService].to[CarServiceImpl].in[Singleton] | ||
bind[DriverService].to[DriverServiceImpl].in[Singleton] | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
sources/server/app/service/AuthService.scala → ...server/app/service/auth/AuthService.scala
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,4 +1,4 @@ | ||
package service | ||
package service.auth | ||
|
||
import javax.inject.Inject | ||
|
||
|
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,24 @@ | ||
package service.entity | ||
|
||
import javax.inject.Inject | ||
|
||
import models.generated.Tables.{CarFilter, Car, CarTable} | ||
import repository.CarRepo | ||
|
||
import scala.concurrent.Future | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
trait CarService extends EntityService[Car, CarTable, CarRepo, CarFilter] { | ||
def getDisplayName(carId: Int): Future[String] | ||
} | ||
|
||
class CarServiceImpl @Inject() (val repo: CarRepo) extends CarService { | ||
override def getDisplayName(carId: Int): Future[String] = { | ||
repo.findById(carId) map { | ||
case Some(car) => s"${car.model} ${car.regNumber} (${car.rate}})" | ||
case None => "None" | ||
} | ||
} | ||
} | ||
|
||
|
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,26 @@ | ||
package service.entity | ||
|
||
import models.generated.Tables.{DriverFilter, Driver, DriverTable} | ||
import repository.DriverRepo | ||
|
||
import scala.concurrent.Future | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
trait DriverService extends EntityService[Driver, DriverTable, DriverRepo, DriverFilter] { | ||
def getDisplayName(driverId: Int): Future[String] | ||
} | ||
|
||
class DriverServiceImpl(val repo: DriverRepo) extends DriverService { | ||
override def getDisplayName(driverId: Int): Future[String] = { | ||
repo.findById(driverId) map { | ||
case Some(driver) => | ||
s"${driver.lastName} ${driver.firstName}" + | ||
(driver.middleName match { | ||
case Some(s) => " " + s | ||
case None => "" | ||
}) | ||
case None => "None" | ||
} | ||
} | ||
} | ||
|
3 changes: 2 additions & 1 deletion
3
...es/server/app/service/EntityService.scala → ...er/app/service/entity/EntityService.scala
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