本文整理汇总了Scala中slick.driver.JdbcProfile类的典型用法代码示例。如果您正苦于以下问题:Scala JdbcProfile类的具体用法?Scala JdbcProfile怎么用?Scala JdbcProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JdbcProfile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: ClientRecord
//设置package包名称以及导入依赖的类
package services.database
import com.google.inject.Inject
import play.api.db.slick.DatabaseConfigProvider
import play.api.libs.json.Json
import slick.driver.JdbcProfile
case class ClientRecord(id: Int, firstName: String, lastName: String, petId: Int)
object ClientRecord {
implicit val clientRecordFormat = Json.format[ClientRecord]
}
class ClientsRepo @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) {
val dbConfig = dbConfigProvider.get[JdbcProfile]
val db = dbConfig.db
import dbConfig.driver.api._
val clients = TableQuery[ClientsTable]
class ClientsTable(tag: Tag) extends Table[ClientRecord](tag, "CLIENTS") {
def id = column[Int]("ID", O.AutoInc, O.PrimaryKey)
def firstName = column[String]("FIRST_NAME")
def lastName = column[String]("LAST_NAME")
def petId = column[Int]("PET_ID")
def * = (id, firstName, lastName, petId) <> ((ClientRecord.apply _).tupled, ClientRecord.unapply)
}
}
开发者ID:microservicesinaction,项目名称:playProject,代码行数:31,代码来源:Clients.scala
示例2: PetRecord
//设置package包名称以及导入依赖的类
package services.database
import com.google.inject.Inject
import play.api.db.slick.DatabaseConfigProvider
import play.api.libs.json.Json
import slick.driver.JdbcProfile
case class PetRecord(id: Int, name: String, notes: String)
object PetRecord {
implicit val petRecordFormat = Json.format[PetRecord]
}
class PetsRepo @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) {
val dbConfig = dbConfigProvider.get[JdbcProfile]
val db = dbConfig.db
import dbConfig.driver.api._
val pets = TableQuery[PetsTable]
class PetsTable(tag: Tag) extends Table[PetRecord](tag, "PETS") {
def id = column[Int]("ID", O.AutoInc, O.PrimaryKey)
def name = column[String]("NAME")
def notes = column[String]("NOTES")
def * = (id, name, notes) <> ((PetRecord.apply _).tupled, PetRecord.unapply)
}
}
开发者ID:microservicesinaction,项目名称:playProject,代码行数:28,代码来源:Pets.scala
示例3: ItemRecord
//设置package包名称以及导入依赖的类
package services.database
import com.google.inject.Inject
import play.api.db.slick.DatabaseConfigProvider
import play.api.libs.json.Json
import slick.driver.JdbcProfile
case class ItemRecord(id: Int, firstName: String, lastName: String, petId: Int)
object ItemRecord {
implicit val itemRecordFormat = Json.format[ItemRecord]
}
class ItemsRepo @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) {
val dbConfig = dbConfigProvider.get[JdbcProfile]
val db = dbConfig.db
import dbConfig.driver.api._
val items = TableQuery[ItemsTable]
class ItemsTable(tag: Tag) extends Table[ItemRecord](tag, "ITEMS") {
def id = column[Int]("ID", O.AutoInc, O.PrimaryKey)
def firstName = column[String]("FIRST_NAME")
def lastName = column[String]("LAST_NAME")
def petId = column[Int]("PET_ID")
def * = (id, firstName, lastName, petId) <> ((ItemRecord.apply _).tupled, ItemRecord.unapply)
}
}
开发者ID:microservicesinaction,项目名称:playProject,代码行数:31,代码来源:ItemsRepo.scala
示例4: AccountDAO
//设置package包名称以及导入依赖的类
package dao
import javax.inject.Inject
import java.sql.Date
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import slick.driver.MySQLDriver.api._
import models.Account
import scala.concurrent.Future
class AccountDAO @Inject() (protected val databaseConfigProvider: DatabaseConfigProvider){
private class AccountTable(tag: Tag) extends Table[Account] (tag, "Account"){
def account_id = column[Long]("account_id", O.PrimaryKey, O.AutoInc)
def user_id = column[Option[Long]]("user_id")
def name = column[String]("name")
def amount = column[Long]("amount")
def category_id = column[Long]("category_id")
def register_at = column[Date]("register_at")
def payment_source_id = column[Option[Long]]("payment_source_id")
def payment_destination_id = column[Option[Long]]("payment_destination_id")
override def * = (
account_id,
user_id,
name,
amount,
category_id,
register_at,
payment_source_id,
payment_destination_id) <> (Account.tupled, Account.unapply)
}
val dbConfig = databaseConfigProvider.get[JdbcProfile]
private val accounts = TableQuery[AccountTable]
def list: Future[Seq[Account]] = {
dbConfig.db.run(accounts.result)
}
}
开发者ID:kogai,项目名称:kakei-log,代码行数:42,代码来源:AccountDAO.scala
示例5: PaymentDestinationDAO
//设置package包名称以及导入依赖的类
package dao
import javax.inject.Inject
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import slick.driver.MySQLDriver.api._
import models.PaymentDestination
import scala.concurrent.Future
class PaymentDestinationDAO @Inject() (protected val databaseConfigProvider: DatabaseConfigProvider){
private class PaymentDestinationTable(tag: Tag) extends Table[PaymentDestination] (tag, "PaymentDestination"){
def payment_destination_id = column[Long]("payment_destination_id", O.PrimaryKey, O.AutoInc)
def name = column[String]("name")
def user_id = column[Option[Long]]("user_id")
override def * = (
payment_destination_id,
name,
user_id) <> (PaymentDestination.tupled, PaymentDestination.unapply)
}
val dbConfig = databaseConfigProvider.get[JdbcProfile]
private val paymentDestination = TableQuery[PaymentDestinationTable]
def list: Future[Seq[PaymentDestination]] = {
dbConfig.db.run(paymentDestination.result)
}
}
开发者ID:kogai,项目名称:kakei-log,代码行数:31,代码来源:PaymentDestinationDAO.scala
示例6: CategoryDAO
//设置package包名称以及导入依赖的类
package dao
import javax.inject.Inject
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import slick.driver.MySQLDriver.api._
import models.Category
import scala.concurrent.Future
class CategoryDAO @Inject() (protected val databaseConfigProvider: DatabaseConfigProvider){
private class CategoryTable(tag: Tag) extends Table[Category] (tag, "Category"){
def category_id = column[Long]("category_id", O.PrimaryKey, O.AutoInc)
def name = column[String]("name")
def hierarchy = column[Long]("hierarchy")
def user_id = column[Option[Long]]("user_id")
def parent_id = column[Option[Long]]("parent_id")
override def * = (
category_id,
name,
hierarchy,
user_id,
parent_id) <> (Category.tupled, Category.unapply)
}
val dbConfig = databaseConfigProvider.get[JdbcProfile]
private val category = TableQuery[CategoryTable]
def list: Future[Seq[Category]] = {
dbConfig.db.run(category.result)
}
}
开发者ID:kogai,项目名称:kakei-log,代码行数:35,代码来源:CategoryDAO.scala
示例7: PaymentSourceDAO
//设置package包名称以及导入依赖的类
package dao
import javax.inject.Inject
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import slick.driver.MySQLDriver.api._
import models.PaymentSource
import scala.concurrent.Future
class PaymentSourceDAO @Inject() (protected val databaseConfigProvider: DatabaseConfigProvider){
private class PaymentSourceTable(tag: Tag) extends Table[PaymentSource] (tag, "PaymentSource"){
def payment_source_id = column[Long]("payment_source_id", O.PrimaryKey, O.AutoInc)
def name = column[String]("name")
def user_id = column[Option[Long]]("user_id")
def amount = column[Long]("amount")
override def * = (
payment_source_id,
name,
user_id,
amount) <> (PaymentSource.tupled, PaymentSource.unapply)
}
val dbConfig = databaseConfigProvider.get[JdbcProfile]
private val paymentSource = TableQuery[PaymentSourceTable]
def list: Future[Seq[PaymentSource]] = {
dbConfig.db.run(paymentSource.result)
}
}
开发者ID:kogai,项目名称:kakei-log,代码行数:33,代码来源:PaymentSourceDAO.scala
示例8: SolarInfoStorage
//设置package包名称以及导入依赖的类
package storages
import java.time.LocalDateTime
import java.util.UUID
import javax.inject.Inject
import models.SolarInfo
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import support.database.PvPostgresDriver.api._
import scala.concurrent.{ExecutionContext, Future}
class SolarInfoStorage(tag: Tag) extends Table[SolarInfo](tag, "solar_info") {
def id = column[UUID]("id", O.PrimaryKey)
def monitoring_time = column[LocalDateTime]("monitoring_time")
def irradiance = column[Double]("irradiance")
def panel_temp = column[Double]("panel_temp")
def ambient_temp = column[Double]("ambient_temp")
def wind_speed = column[Double]("wind_speed")
def wind_dir = column[Double]("wind_dir")
def sum_energy = column[Double]("sum_energy")
override def * = (id, monitoring_time, irradiance, panel_temp, ambient_temp, wind_speed, wind_dir, sum_energy) <> (SolarInfo.tupled, SolarInfo.unapply)
}
object SolarInfoStorage {
val tableQuery = TableQuery[SolarInfoStorage]
}
class SolarInfoRepository @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)(implicit ec: ExecutionContext) {
val dbconfig = dbConfigProvider.get[JdbcProfile]
val db = dbconfig.db
private val SolarInfos = SolarInfoStorage.tableQuery
def findById(id: UUID): Future[SolarInfo] = db.run(SolarInfos.filter(_.id === id).result.head)
def all(): Future[List[SolarInfo]] = db.run(SolarInfos.to[List].result)
def create(solarInfo: SolarInfo): Future[UUID] = db.run(SolarInfos returning SolarInfos.map(_.id) += solarInfo)
def delete(id: UUID): Future[Boolean] = db.run(SolarInfos.filter(_.id === id).delete).map(_ > 0)
}
开发者ID:astahiam,项目名称:pv_,代码行数:45,代码来源:SolarInfoStorage.scala
示例9: LanguageTable
//设置package包名称以及导入依赖的类
package repository
import com.google.inject.Inject
import com.google.inject.ImplementedBy
import models.Language
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.slick.HasDatabaseConfigProvider
import slick.driver.JdbcProfile
import scala.concurrent.Future
trait LanguageTable extends UserTable{ self: HasDatabaseConfigProvider[JdbcProfile] =>
import driver.api._
class LanguageTable(tag:Tag) extends Table[Language](tag,"language") {
val id=column[Int]("id")
val name= column[String]("name", O.SqlType("VARCHAR(200)"))
val fluency=column[String]("fluency", O.SqlType("VARCHAR(200)"))
def * = (id, name,fluency) <>(Language.tupled, Language.unapply)
}
val languageTableQuery = TableQuery[LanguageTable]
}
//@ImplementedBy(classOf[LanguageImpl])
class LanguageRepo @Inject() (protected val dbConfigProvider: DatabaseConfigProvider) extends LanguageTable with HasDatabaseConfigProvider[JdbcProfile] {
import driver.api._
def insert(id: Int, name: String, fluency: String): Future[Int] = {
val insertQuery=languageTableQuery += Language(id, name, fluency)
db.run {insertQuery}
}
def update(id: Int, name: String, fluency: String): Future[Int] = db.run {languageTableQuery.filter(_.id === id).update(Language(id, name, fluency))}
def delete(name:String): Future[Int] = db.run { languageTableQuery.filter(_.name === name).delete}
def getAll(): Future[List[Language]] = db.run {
val test=languageTableQuery.to[List]
test.result
}
def getLanguage(id:Int): Future[Seq[Language]] = {
db.run(languageTableQuery.filter(_.id === id).result)
}
}
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:48,代码来源:LanguageRepo.scala
示例10: Restaurants
//设置package包名称以及导入依赖的类
package dao;
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import play.api.Play
import slick.driver.PostgresDriver.api._
import scala.concurrent.Future
import model.CompleteRestaurant
import scala.concurrent.ExecutionContext.Implicits.global
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import play.api.Play
import slick.driver.PostgresDriver.api._
import scala.concurrent.Future
import model.CompleteRestaurant
import scala.concurrent.ExecutionContext.Implicits.global
import model.RestaurantTableDef
object Restaurants {
val dbConfig=DatabaseConfigProvider.get[JdbcProfile](Play.current)
val restaurants=TableQuery[RestaurantTableDef]
def list:Future[Seq[CompleteRestaurant]]={
dbConfig.db.run(restaurants.result)
}
def getById(id:Long): Future[Option[CompleteRestaurant]]={
dbConfig.db.run(restaurants.filter(_.id===id).result.headOption)
}
def save(restaurant:CompleteRestaurant):Future[String]={
dbConfig.db.run(restaurants+=restaurant).map(res => "Restaurant saved").recover{
case ex: Exception => ex.getCause.getMessage
}
}
def update(restaurant:CompleteRestaurant):Future[Int]={
dbConfig.db.run(restaurants.filter(_.id===restaurant.id).update(restaurant))
}
def delete(id:Long):Future[Int]={
dbConfig.db.run(restaurants.filter(_.id===id).delete)
}
}
开发者ID:MartinEliasQ,项目名称:AppEmpre-Dojo3-Scala,代码行数:41,代码来源:Restaurants.scala
示例11: Campaign
//设置package包名称以及导入依赖的类
package models
import play.api.Play
import slick.driver.H2Driver.api._
import scala.concurrent.Future
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.slick.HasDatabaseConfig
import slick.driver.JdbcProfile
case class Campaign(id: Option[Int], title: String, content: String)
trait CampaignsTable {
class Campaigns(tag: Tag) extends Table[Campaign](tag, "CAMPAIGNS") {
def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
def title = column[String]("TITLE")
def content = column[String]("CONTENT")
def * = (id.?, title, content) <> (Campaign.tupled, Campaign.unapply)
}
val campaigns = TableQuery[Campaigns]
}
object CampaignsDAO extends HasDatabaseConfig[JdbcProfile] with CampaignsTable {
val dbConfig = DatabaseConfigProvider.get[JdbcProfile](Play.current)
def findById(id: Int): Future[Option[Campaign]] =
db.run(campaigns.filter(_.id === id).result.headOption)
def findAll: Future[Seq[Campaign]] =
db.run(campaigns.result)
def insert(newRecord: Campaign): Future[Int] = {
db.run((campaigns returning campaigns.map(_.id)) += newRecord)
}
def update(record: Campaign): Future[Int] = {
db.run(campaigns.filter(_.id === record.id)
.map(a => (a.title, a.content))
.update((record.title, record.content)))
}
def getCampaignIds: Future[Seq[Int]] = {
db.run(campaigns.map(row => (row.id)).result)
}
}
开发者ID:kaznishi,项目名称:zz-sandbox-petit-ad,代码行数:48,代码来源:Campaign.scala
示例12: PhraseDao
//设置package包名称以及导入依赖的类
package daos
import java.sql.Timestamp
import java.util.Date
import javax.inject.Inject
import models.Phrase
import org.joda.time.DateTime
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.slick.HasDatabaseConfigProvider
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import slick.driver.JdbcProfile
import scala.concurrent.Future
class PhraseDao @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) extends HasDatabaseConfigProvider[JdbcProfile] {
import driver.api._
private val Phrases = TableQuery[PhrasesTable]
def all(): Future[Seq[Phrase]] = db.run(Phrases.result)
def insert(phrase: Phrase): Future[Unit] = db.run(Phrases += phrase).map { _ => () }
def insert(phrases: Seq[Phrase]): Future[Unit] = db.run(this.Phrases ++= phrases).map(_ => ())
def findById(id: Long): Future[Option[Phrase]] = db.run(Phrases.filter(_.id === id).result.headOption)
def update(id: Long, phrase: Phrase): Future[Unit] = {
val phraseToUpdate: Phrase = phrase.copy(Some(id))
db.run(Phrases.filter(_.id === id).update(phraseToUpdate)).map(_ => ())
}
def delete(id: Long): Future[Unit] =
db.run(Phrases.filter(_.id === id).delete).map(_ => ())
def count(): Future[Int] = {
// this should be changed to db.run(Phrases.length.result) when https://github.com/slick/slick/issues/1237 is fixed
db.run(Phrases.map(_.id).length.result)
}
private class PhrasesTable(tag: Tag) extends Table[Phrase](tag, "PHRASE") {
//implicit val dateColumnType = MappedColumnType.base[Date, Long](d => d.getTime, d => new Date(d))
implicit def dateTime = MappedColumnType.base[DateTime, Timestamp] (
dt => new Timestamp(dt.getMillis), ts => new DateTime(ts.getTime)
)
def id = column[Long]("ID", O.PrimaryKey, O.AutoInc)
def spanish = column[String]("SPANISH")
def english = column[String]("ENGLISH")
def createdAt = column[DateTime]("CREATED_AT")
def * = (id.?, spanish, english, createdAt) <> (Phrase.tupled, Phrase.unapply _)
}
}
开发者ID:rossma,项目名称:pizarra-beta,代码行数:57,代码来源:PhraseDao.scala
示例13: PersonDAOImpl
//设置package包名称以及导入依赖的类
package dao
import javax.inject.Inject
import javax.inject.Singleton
import scala.concurrent.Future
import play.api.Configuration
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.slick.HasDatabaseConfigProvider
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.db.NamedDatabase
import models.Person
import slick.driver.JdbcProfile
@Singleton
class PersonDAOImpl @Inject() (@NamedDatabase("mydb") protected val dbConfigProvider: DatabaseConfigProvider, conf: Configuration) extends PersonDAO with HasDatabaseConfigProvider[JdbcProfile] with Tables {
import driver.api._
val loadedDb = conf.getString("slick.dbs.mydb.db.url")//just for demo, should be "blah" in PersonDAOImplSpec
println("LOADED CONFIG FOR DB: " + loadedDb)
def findAll(): Future[Seq[Person]] =
db.run(persons.result).map { res => println("Hello from real DAO!"); res }
def insert(p: Person): Future[Int] =
db.run(persons += p)
def createTables(): Future[Unit] =
db.run(persons.schema.create)
}
trait Tables { self: HasDatabaseConfigProvider[JdbcProfile] =>
import driver.api._
class PersonsTable(tag: Tag) extends Table[Person](tag, "PERSON") {
def id = column[Int]("ID", O.PrimaryKey)
def name = column[String]("NAME")
def age = column[Int]("AGE")
def * = (id, name, age) <> (Person.tupled, Person.unapply _)
}
lazy val persons = TableQuery[PersonsTable]
}
开发者ID:sake92,项目名称:PlayGuiceExample,代码行数:43,代码来源:PersonDAOImpl.scala
示例14: Restaurante
//设置package包名称以及导入依赖的类
package models
import javax.inject._
import play.api.Application
import slick.driver.JdbcProfile
import slick.driver.MySQLDriver.api._
import play.api.db.slick.DatabaseConfigProvider
import slick.backend.DatabaseConfig
import scala.concurrent.Future
case class Restaurante (var id:Int,var nombre:String,var direccion:String)
class RestauranteTableDef(tag: Tag) extends Table[Restaurante](tag, "Restaurantes") {
def id = column[Int]("id", O.PrimaryKey,O.AutoInc)
def nombre = column[String]("Nombre")
def direccion = column[String]("Direccion")
override def * =
(id, nombre, direccion) <>(Restaurante.tupled, Restaurante.unapply)
}
class Restaurantes @Inject() (appProvider: Provider[Application]) {
def dbConfig(): DatabaseConfig[JdbcProfile] =
DatabaseConfigProvider.get[JdbcProfile](appProvider.get())
val restaurantes = TableQuery[RestauranteTableDef]
var lista :List[Restaurante]={
List(
Restaurante(
3
,"La casa blanca"
,"Argentina"
),
Restaurante(
4
,"La casa rosta"
,"Manizales"
)
)
}
def adicionar(restaurante: Restaurante)={
lista = lista ::: List(restaurante)
}
def traerTodo:Future[Seq[Restaurante]]={
dbConfig().db.run(restaurantes.result)
}
}
开发者ID:arbeyvillegas,项目名称:Restaurante,代码行数:55,代码来源:Restaurante.scala
示例15: TenantDaoImpl
//设置package包名称以及导入依赖的类
package dao
import com.google.inject.{Inject, Singleton}
import models.Tenant
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import play.api.libs.concurrent.Execution.Implicits._
import scala.concurrent.Future
@Singleton
class TenantDaoImpl @Inject()(databaseConfigProvider: DatabaseConfigProvider) extends TenantDao {
val dbConfig = databaseConfigProvider.get[JdbcProfile]
import dbConfig._
import driver.api._
class TenantTable(tag : Tag) extends Table[Tenant](tag, "tenants") {
def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
def firstName = column[String]("first_name")
def lastName = column[String]("last_name")
def mobile = column[Long]("mobile")
def email = column[String]("email")
override def * =
(id, firstName, lastName, mobile, email) <> (Tenant.tupled, Tenant.unapply)
}
implicit val tenants = TableQuery[TenantTable]
override def add(tenant: Tenant): Future[String] = {
db.run(tenants += tenant).map(res => "Tenant Successfully Added").recover {
case ex : Exception => ex.getCause.getMessage
}
}
override def get(id: Long): Future[Option[Tenant]] = {
db.run(tenants.filter(_.id === id).result.headOption)
}
override def delete(id: Long): Future[Int] = {
db.run(tenants.filter(_.id === id).delete)
}
override def listAll: Future[Seq[Tenant]] = {
db.run(tenants.result)
}
}
开发者ID:kunalherkal,项目名称:rental-manager,代码行数:52,代码来源:TenantDaoImpl.scala
示例16: BootstrapLoader
//设置package包名称以及导入依赖的类
import controllers.UserController
import dao.UserDao
import play.api.ApplicationLoader.Context
import play.api.db.evolutions.{DynamicEvolutions, EvolutionsComponents}
import play.api.db.slick.{DbName, DatabaseConfigProvider, SlickComponents}
import play.api.db.slick.evolutions.SlickEvolutionsComponents
import play.api.i18n.{DefaultLangs, DefaultMessagesApi, MessagesApi}
import play.api.routing.Router
import play.api._
import router._
import slick.driver.JdbcProfile
class BootstrapLoader extends ApplicationLoader {
override def load(context: Context): Application = {
Logger.configure(context.environment)
new ApplicationComponents(context).application
}
}
class ApplicationComponents(context: Context) extends BuiltInComponentsFromContext(context)
with SlickComponents with SlickEvolutionsComponents with EvolutionsComponents {
lazy val messagesApi: MessagesApi = new DefaultMessagesApi(environment, configuration, new DefaultLangs(configuration))
lazy val dbConfig = api.dbConfig[JdbcProfile](DbName("default"))
lazy val userDao = new UserDao(dbConfig)
lazy val applicationController = new controllers.Application()
lazy val assets = new controllers.Assets(httpErrorHandler)
lazy val webAssets = new controllers.WebJarAssets(httpErrorHandler, configuration, environment)
lazy val userController = new UserController(messagesApi, userDao = userDao)
override def router: Router = new Routes(
httpErrorHandler,
applicationController,
userController,
assets,
webAssets
)
// This is required by EvolutionsComponents
lazy val dynamicEvolutions = new DynamicEvolutions
def onStart() = {
// applicationEvolutions is a val and requires evolution
applicationEvolutions
}
onStart()
}
开发者ID:cloudwicklabs,项目名称:play-cloudwickone-slick-template,代码行数:51,代码来源:BootstrapLoader.scala
示例17: UnemployController
//设置package包名称以及导入依赖的类
package controllers
import javax.inject._
import play.api._
import play.api.mvc._
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import slick.dbio.DBIOAction
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import models._
import models.Tables._
import slick.driver.MySQLDriver.api._
@Singleton
class UnemployController @Inject()(dbConfigProvider: DatabaseConfigProvider) extends Controller {
val dbConfig = dbConfigProvider.get[JdbcProfile]
def index = Action.async { implicit request =>
val seriesf = dbConfig.db.run(Series.filter(s => Data.filter(d => d.seriesId === s.seriesId).exists).result)
seriesf.map(series => Ok(views.html.unemploySeries(series)))
}
def dataTable(series: String) = Action.async { implicit request =>
val dataf = dbConfig.db.run(Data.filter(d => d.seriesId === series).result)
dataf.map(data => Ok(views.html.unemployTable(series, data)))
}
}
开发者ID:MarkCLewis,项目名称:WebAppsS17-play-slick,代码行数:29,代码来源:UnemployController.scala
示例18: Users
//设置package包名称以及导入依赖的类
package controllers.datastore
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.slick.HasDatabaseConfigProvider
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import slick.driver.JdbcProfile
import scala.concurrent.Future
import scala.util.{Try, Success, Failure}
import javax.inject._
import controllers.model._
class Users @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)
extends HasDatabaseConfigProvider[JdbcProfile] {
import driver.api._
private class UserTable (tag: Tag) extends Table[User](tag, "USER") {
def username = column[String]("USERNAME", O.PrimaryKey)
def passwordHash = column[String]("PASSWORD")
def email = column[Option[String]]("EMAIL")
def phoneNumber = column[Option[String]]("PHONE_NUMBER")
def * = (username, passwordHash, email, phoneNumber).shaped <> [User](User.fromTuple, User.toTuple _)
}
private val users = TableQuery[UserTable]
def schema = users.schema
def all: Future[Seq[User]] = db.run(users.result)
def insert(user: User): Try[User] = Try {
db.run(users += user)
user
}
def get(username: String): Future[Option[User]] =
db.run(users.filter(user => user.username === username).result.headOption)
def += (user: User): Try[User] = insert(user)
}
开发者ID:omefire,项目名称:Scodex,代码行数:41,代码来源:Users.scala
示例19: ExchangeRates
//设置package包名称以及导入依赖的类
package controllers.datastore
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.slick.HasDatabaseConfigProvider
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import slick.driver.JdbcProfile
import scala.concurrent.Future
import scala.util.{Try, Success, Failure}
import javax.inject._
import java.sql.Date
import controllers.model._
class ExchangeRates @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)
extends HasDatabaseConfigProvider[JdbcProfile] {
import driver.api._
private class ExchangeRateTable (tag: Tag) extends Table[ExchangeRate](tag, "EXCHANGE_RATE") {
def date = column[Date]("DATE")
def fromCurrency = column[String]("FROM_CURRENCY")
def toCurrency = column[String]("TO_CURRENCY")
def rate = column[BigDecimal]("RATE")
def pk = primaryKey("pk_exchange_rate", (date, fromCurrency, toCurrency))
def * = (date, fromCurrency, toCurrency, rate).shaped <> [ExchangeRate](ExchangeRate.fromTuple, ExchangeRate.toTuple _)
}
private val exchangeRates = TableQuery[ExchangeRateTable]
def schema = exchangeRates.schema
def all: Future[Seq[ExchangeRate]] = db.run(exchangeRates.result)
}
开发者ID:omefire,项目名称:Scodex,代码行数:34,代码来源:ExchangeRates.scala
示例20: StockPrices
//设置package包名称以及导入依赖的类
package controllers.datastore
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.slick.HasDatabaseConfigProvider
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import slick.driver.JdbcProfile
import scala.concurrent.Future
import scala.util.{Try, Success, Failure}
import javax.inject._
import java.sql.Date
import controllers.model._
class StockPrices @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)
extends HasDatabaseConfigProvider[JdbcProfile] {
import driver.api._
private class StockPriceTable (tag: Tag) extends Table[StockPrice](tag, "STOCK_PRICE") {
def date = column[Date]("DATE")
def symbol = column[String]("SYMBOL")
def price = column[BigDecimal]("PRICE")
def currency = column[String]("CURRENCY")
def pk = primaryKey("pk_stock_price", (date, symbol))
def * = (date, symbol, price, currency).shaped <> [StockPrice](StockPrice.fromTuple, StockPrice.toTuple _)
}
private val stockPrices = TableQuery[StockPriceTable]
def schema = stockPrices.schema
def all: Future[Seq[StockPrice]] = db.run(stockPrices.result)
}
开发者ID:omefire,项目名称:Scodex,代码行数:34,代码来源:StockPrices.scala
注:本文中的slick.driver.JdbcProfile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论