Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.di.repository
- import com.di.cake.user.domain.User
- import com.di.repository.api.UserRepositoryComponent
- import scala.slick.driver.MySQLDriver.simple._
- /**
- * Created by uenyioha on 11/22/14.
- */
- trait UserRepositorySlickComponent extends UserRepositoryComponent {
- implicit val session: Session
- def userLocator = new UserLocatorSlickImpl
- def userUpdater = new UserUpdaterSlickImpl
- val users = TableQuery[Users]
- class UserLocatorSlickImpl(implicit val session: Session) extends UserLocator {
- def findAll = users.list
- }
- class UserUpdaterSlickImpl(implicit val session: Session) extends UserUpdater {
- def save(user: User) { users += user }
- }
- }
- class Users(tag: Tag) extends Table[User](tag, "USERS") {
- def id = column[Int]("ID")
- def firstname = column[String]("FIRSTNAME")
- def lastname = column[String]("LASTNAME")
- def username = column[String]("USERNAME")
- def password = column[String]("PASSWORD")
- def * = (id ~ firstname ~ lastname ~ username ~ password) <> (User.tupled, User.unapply _)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement