Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.06 KB | None | 0 0
  1. package com.di.repository
  2.  
  3.  
  4. import com.di.cake.user.domain.User
  5. import com.di.repository.api.UserRepositoryComponent
  6.  
  7.  
  8. import scala.slick.driver.MySQLDriver.simple._
  9.  
  10. /**
  11.  * Created by uenyioha on 11/22/14.
  12.  */
  13. trait UserRepositorySlickComponent extends UserRepositoryComponent {
  14.   implicit val session: Session
  15.  
  16.   def userLocator = new UserLocatorSlickImpl
  17.   def userUpdater = new UserUpdaterSlickImpl
  18.  
  19.   val users = TableQuery[Users]
  20.  
  21.   class UserLocatorSlickImpl(implicit val session: Session) extends UserLocator {
  22.     def findAll = users.list
  23.   }
  24.  
  25.   class UserUpdaterSlickImpl(implicit val session: Session) extends UserUpdater {
  26.     def save(user: User) { users += user }
  27.   }
  28.  
  29. }
  30.  
  31. class Users(tag: Tag) extends Table[User](tag, "USERS") {
  32.   def id = column[Int]("ID")
  33.   def firstname = column[String]("FIRSTNAME")
  34.   def lastname = column[String]("LASTNAME")
  35.   def username = column[String]("USERNAME")
  36.   def password = column[String]("PASSWORD")
  37.  
  38.   def * = (id ~ firstname ~ lastname ~ username ~ password) <> (User.tupled, User.unapply _)
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement