Last active
August 29, 2015 13:56
-
-
Save kiris/9131119 to your computer and use it in GitHub Desktop.
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
trait FindTaskContext { | |
def order:String | |
def page:Int | |
def limit:Int | |
} | |
class TaskController { | |
def findTask(code:String, name:String, order:String, limit:Int, page:Int): List[Task] = { | |
// 実際はDBの接続先情報とかも必要なのでもっと複雑になると思う | |
object Context extends FindTaskContext { | |
val order = order | |
val page = page | |
val limit = limit | |
} | |
TaskService.findTask(code, name, Context) | |
} | |
} | |
object TaskService { | |
val taskRepository = new TaskRepository() // 実際はDIされる | |
def findTask(code:String, name:String, ctx:FindTaskContext):List[Task] = { | |
taskRepository.findCodeAndName(code, name, ctx) | |
} | |
} | |
class TaskRepository { | |
def findCodeAndName(code:String, name:String, ctx:FindTaskContext):List[Task] = { | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment