当前位置: 首页>>代码示例>>Scala>>正文


Scala HasDatabaseConfigProvider类代码示例

本文整理汇总了Scala中play.api.db.slick.HasDatabaseConfigProvider的典型用法代码示例。如果您正苦于以下问题:Scala HasDatabaseConfigProvider类的具体用法?Scala HasDatabaseConfigProvider怎么用?Scala HasDatabaseConfigProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HasDatabaseConfigProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: 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

示例2: SetUpDao

//设置package包名称以及导入依赖的类
package dao

import javax.inject._

import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.driver.JdbcProfile


@Singleton
class SetUpDao @Inject() (protected val dbConfigProvider: DatabaseConfigProvider,
                          private val yearMonthDao: YearMonthDao,
                          private val categoryDao: CategoryDao,
                          private val payMethodDao: PayMethodDao,
                          private val payeeDao: PayeeDao,
                          private val itemDateDao: ItemDateDao,
                          private val costItemDao: CostItemDao
                         )
      extends HasDatabaseConfigProvider[JdbcProfile] {

  import driver.api._

  private val yearMonthQuery = TableQuery[yearMonthDao.YearMonthTable]
  private val categoryQuery = TableQuery[categoryDao.CategoryTable]
  private val payMethodQuery = TableQuery[payMethodDao.PayMethodTable]
  private val payeeQuery = TableQuery[payeeDao.PayeeTable]
  private val itemDateQuery = TableQuery[itemDateDao.ItemDateTable]
  private val costItemQuery = TableQuery[costItemDao.CostItemTable]

  val setup = DBIO.seq(
    (
      yearMonthQuery.schema ++
        categoryQuery.schema ++
        payMethodQuery.schema ++
        payeeQuery.schema ++
        itemDateQuery.schema ++
        costItemQuery.schema
      ).create
  )

  val setupFuture = db.run(setup)
} 
开发者ID:dikky1218,项目名称:kakeiboApi,代码行数:42,代码来源:SetUpDao.scala

示例3: Scores

//设置package包名称以及导入依赖的类
package dao

import javax.inject.{Inject, Singleton}

import models._
import play.api.db.slick.{HasDatabaseConfigProvider, DatabaseConfigProvider}
import slick.driver.JdbcProfile

import scala.concurrent.Future


trait ScoreComponent{ self: HasDatabaseConfigProvider[JdbcProfile] =>
  import driver.api._
  class Scores(tag: Tag) extends Table[Score](tag, "Score"){
    def scoreId = column[Option[Int]]("ScoreId", O.PrimaryKey, O.AutoInc)
    def value = column[Double]("Value")
    def assessmentMethodId = column[Int]("AssessmentMethodId")
    def courseId = column[String]("CourseId")
    def academicSeasonId = column[Int]("AcademicSeasonId")

    def * = (scoreId, value, assessmentMethodId, courseId, academicSeasonId) <>((Score.apply _).tupled, Score.unapply _)
  }
}
@Singleton
class ScoreDAO @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)
  extends HasDatabaseConfigProvider[JdbcProfile] with ScoreComponent {
  import driver.api._
  private lazy val scores = TableQuery[Scores]

  def countScore(courseId: String, academicId: Int): Future[Int] =
    db.run(scores.filter(s => s.courseId === courseId && s.academicSeasonId === academicId).length.result)

  def insert(listScore: Seq[Score]): Future[Option[Int]] = {
    db.run(scores ++= listScore)
  }
} 
开发者ID:chinhnk00494,项目名称:cw-CMR,代码行数:37,代码来源:ScoreDAO.scala

示例4: GradeStatisticDAO

//设置package包名称以及导入依赖的类
package dao

import javax.inject.{Inject, Singleton}

import models.GradeStatistic
import play.api.db.slick.{HasDatabaseConfigProvider, DatabaseConfigProvider}
import slick.driver.JdbcProfile

import scala.concurrent.Future


@Singleton
class GradeStatisticDAO @Inject()(protected val dbConfigProvider:DatabaseConfigProvider)
  extends HasDatabaseConfigProvider[JdbcProfile] {
  import driver.api._

  class GradeStatistics(tag: Tag) extends Table[GradeStatistic](tag,"GradeStatistic"){
    def cmrId = column[Int]("CMRId",O.PrimaryKey,O.AutoInc)
    def statisticType = column[String]("StatisticType",O.PrimaryKey)
    def assessmentMethodId = column[Int]("AssessmentMethodId",O.PrimaryKey)
    def value = column[Option[Float]]("Value")

    def * = (cmrId,statisticType,assessmentMethodId,value) <> ((GradeStatistic.apply _).tupled, GradeStatistic.unapply _)
  }
  private lazy val gradeStatistics = TableQuery[GradeStatistics]

  def findByCMRId(cmrId: Int): Future[Seq[GradeStatistic]] =
    db.run(gradeStatistics.filter(_.cmrId === cmrId).result)
} 
开发者ID:chinhnk00494,项目名称:cw-CMR,代码行数:30,代码来源:GradeStatisticDAO.scala

示例5: GradeDistributionDAO

//设置package包名称以及导入依赖的类
package dao

import javax.inject.{Inject, Singleton}

import models.GradeDistribution
import play.api.db.slick.{HasDatabaseConfigProvider, DatabaseConfigProvider}
import slick.driver.JdbcProfile

import scala.concurrent.Future


@Singleton
class GradeDistributionDAO @Inject()(protected val dbConfigProvider:DatabaseConfigProvider)
  extends HasDatabaseConfigProvider[JdbcProfile] {
  import driver.api._

  class GradeDistributions(tag: Tag) extends Table[GradeDistribution](tag,"GradeDistribution"){
    def cmrId = column[Int]("CMRId",O.PrimaryKey, O.AutoInc)
    def assessmentMethodId = column[Int]("AssessmentMethodId",O.PrimaryKey)
    def distributionType = column[String]("DistributionType",O.PrimaryKey)
    def value = column[Option[Int]]("Value")

    def * = (cmrId,assessmentMethodId,distributionType,value) <> ((GradeDistribution.apply _).tupled, GradeDistribution.unapply _)
  }
  private lazy val gradeDistributions = TableQuery[GradeDistributions]

  def findByCMRId(cmrId: Int) : Future[Seq[GradeDistribution]] = db.run(
    gradeDistributions.filter(_.cmrId === cmrId).result
  )
} 
开发者ID:chinhnk00494,项目名称:cw-CMR,代码行数:31,代码来源:GradeDistributionDAO.scala

示例6: get

//设置package包名称以及导入依赖的类
package model.user.dao

import javax.inject.Inject

import com.google.inject.ImplementedBy
import model.user.RegisteredUser
import model.user.RegisteredUser.RegisteredUserTable
import model.user.User.RegistrationTable
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.driver.H2Driver.api._
import slick.driver.JdbcProfile

import scala.concurrent.Future

@ImplementedBy(classOf[RegisteredUserDAOImpl])
trait RegisteredUserDAO {
  def get(id: Long) : Future[Option[RegisteredUser]]
  def find(email: String) : Future[Option[RegisteredUser]]
  def find(login: String, pass: String) : Future[Option[RegisteredUser]]
  def save(registeredUser: RegisteredUser) : Future[Int]
  def save(user: (Long, String, String, String)): Future[Int]
}

class RegisteredUserDAOImpl @Inject()(val dbConfigProvider: DatabaseConfigProvider)
  extends HasDatabaseConfigProvider[JdbcProfile] with RegisteredUserDAO {

  val users = TableQuery[RegisteredUserTable]

  override def get(id: Long): Future[Option[RegisteredUser]] = db.run(users.filter(_.userId === id).result.headOption)

  override def find(email: String): Future[Option[RegisteredUser]] = db.run(users.filter(_.email === email).result.headOption)

  override def find(login: String, pass: String): Future[Option[RegisteredUser]] = {
    val findUser = users.filter { u =>
      (u.email === login || u.username === login) && u.password === pass
    }

    db.run(findUser.result.headOption)
  }

  override def save(registeredUser: RegisteredUser): Future[Int] = {
    db.run(users += registeredUser)
  }

  val usersToRegistration = TableQuery[RegistrationTable]

  override def save(user: (Long, String, String, String)): Future[Int] = {
    db.run(usersToRegistration += user)
  }
} 
开发者ID:nimmortal,项目名称:todo-list-play-auth-slick,代码行数:51,代码来源:RegisteredUserDAO.scala

示例7: DBController

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.{Inject, Singleton}

import dao.{DatabrickAuditLogDAO, UserDAO}
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import play.api.mvc.{AbstractController, ControllerComponents}
import slick.jdbc.JdbcProfile

import scala.concurrent.ExecutionContext


@Singleton
class DBController @Inject()(
                            userDao:UserDAO,
                            databrickAuditLogDao: DatabrickAuditLogDAO,
                              protected val dbConfigProvider: DatabaseConfigProvider,
                              cc: ControllerComponents
                            )
                            (implicit ec: ExecutionContext)
  extends AbstractController(cc) with HasDatabaseConfigProvider[JdbcProfile] {
  def init = Action { implicit request =>
    Ok("success")
  }

} 
开发者ID:bkstha,项目名称:my-log-api,代码行数:27,代码来源:DBController.scala

示例8: DataDAO

//设置package包名称以及导入依赖的类
package models.dao

import com.google.inject.Inject
import models.tables.SlickTables
import org.slf4j.LoggerFactory
import play.api.db.slick.{HasDatabaseConfigProvider, DatabaseConfigProvider}
import slick.driver.JdbcProfile


class DataDAO  @Inject()(
  protected val dbConfigProvider:DatabaseConfigProvider
  )extends HasDatabaseConfigProvider[JdbcProfile]{
  import slick.driver.MySQLDriver.api._
  private val log=LoggerFactory.getLogger(this.getClass)

  val voice=SlickTables.tVoice
  val image=SlickTables.tImage
  val typing=SlickTables.tTyping
  val game=SlickTables.tGame

  def getVoiceByUser(userId:Long)={
    db.run(voice.filter(_.userid===userId).result)
  }

  def getImageByUser(userId:Long)={
    db.run(image.filter(_.userid===userId).result)
  }

  def getTypingByUser(userId:Long)={
    db.run(typing.filter(_.userid===userId).result)
  }

  def getGameByUser(userId:Long)={
    db.run(game.filter(_.userid===userId).result)
  }

} 
开发者ID:springlustre,项目名称:trainingAdmin,代码行数:38,代码来源:DataDAO.scala

示例9: AliasDao

//设置package包名称以及导入依赖的类
package models

import javax.inject.Inject
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.slick.HasDatabaseConfigProvider
import slick.driver.JdbcProfile
import scala.concurrent.{ExecutionContext, Future}
import javax.inject.Singleton


@Singleton()
class AliasDao @Inject() (protected val dbConfigProvider: DatabaseConfigProvider) extends Tables with HasDatabaseConfigProvider[JdbcProfile] {
  val profile = driver
  import driver.api._

  def getAll(implicit ec: ExecutionContext): Future[List[AliasApi]] = {
    val query = Alias
    val action = query.result
    val futureAliases = db.run(action)

    futureAliases.map(
      _.map {
        a => AliasApi(
          id = a.id,
          domainId = a.domainId,
          address = a.address,
          goto = a.goto,
          active = a.active
        )
      }.toList
    )
  }

  private def getAliasQuery(maybeId: Option[Int] = None) = {
    val aliasQuery = maybeId match {
      case None => Alias
      case Some(id) => Alias.filter(_.id === id)
    }
    aliasQuery

//    val withAliasQuery = for {
//
//    }
  }
} 
开发者ID:tuken,项目名称:playpostfix,代码行数:46,代码来源:AliasDao.scala

示例10: MemberDataAccess

//设置package包名称以及导入依赖的类
package models

import java.sql.Date
import java.util.Calendar
import javax.inject.{Inject, Singleton}

import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.driver.JdbcProfile
import slick.driver.MySQLDriver.api._

@Singleton()
class MemberDataAccess @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) extends HasDatabaseConfigProvider[JdbcProfile] {
	val members = TableQuery[MembersTable]

	def getList = {
		db.run(members.result)
	}

	def create = {
		db.run(members.schema.create)
	}

	def insert = {
		db.run(members += Member(1, "admin", "12345", "Genius", "[email protected]", new java.sql.Date(Calendar.getInstance().getTimeInMillis)))
	}
}

case class Member(mid: Int, userid: String, password: String, nickname: String, email: String, regdate:Date)

class MembersTable(tag: Tag) extends Table[Member](tag, "MEMBERS") {
	def mid = column[Int]("MID", O.PrimaryKey, O.AutoInc)
	def userid = column[String]("USERID")
	def password = column[String]("PASSWORD")
	def nickname = column[String]("NICKNAME")
	def email = column[String]("EMAIL")
	def regdate = column[Date]("REGDATE")
	def * = (mid, userid, password, nickname, email, regdate) <> ((Member.apply _).tupled, Member.unapply)
} 
开发者ID:csj4032,项目名称:primavera,代码行数:39,代码来源:Member.scala

示例11: Interns

//设置package包名称以及导入依赖的类
package repository


import com.google.inject.{Inject}
import play.api.db.slick.DatabaseConfigProvider
import play.api.db.slick.HasDatabaseConfigProvider
import slick.driver.JdbcProfile
import scala.concurrent.Future


case class Interns(id:Int,name:String,email:String,mobile:String,address:String,emergency:String)

trait InternTable{ self: HasDatabaseConfigProvider[JdbcProfile] =>
  import driver.api._

  class InternTable(tag:Tag) extends Table[Interns](tag,"interns") {
    val id=column[Int]("id",O.AutoInc,O.PrimaryKey)
    val name= column[String]("name", O.SqlType("VARCHAR(100)"))
    val email= column[String]("email", O.SqlType("VARCHAR(100)"))
    val mobile= column[String]("mobile", O.SqlType("VARCHAR(10)"))
    val address= column[String]("address", O.SqlType("VARCHAR(100)"))
    val emergency= column[String]("emergency", O.SqlType("VARCHAR(10)"))

    def * = (id, name,email,mobile,address,emergency) <> (Interns.tupled,Interns.unapply)
  }

  val internTableQuery = TableQuery[InternTable]
}

class InternRepo @Inject()(protected val dbConfigProvider:DatabaseConfigProvider) extends InternTable with HasDatabaseConfigProvider[JdbcProfile]{
  import driver.api._

  def insert(intern:Interns):Future[Int] = {
    db.run {
      internTableQuery += intern
    }
  }

  def update(intern:Interns):Future[Int]={
    db.run {internTableQuery.filter(_.id === intern.id).update(intern)}
  }

  def delete(id: Int):Future[Int]={
    db.run {internTableQuery.filter(_.id === id).delete}
  }

  def getAll():Future[List[Interns]]={
    db.run{ internTableQuery.to[List].result}
  }

  def getById(id:Int):Future[Option[Interns]]={
    db.run{
      internTableQuery.filter(_.id===id).result.headOption
    }
  }

} 
开发者ID:rahulforallp,项目名称:playScalaSlick,代码行数:58,代码来源:InternRepo.scala

示例12: FooDb

//设置package包名称以及导入依赖的类
package db

import javax.inject.Inject

import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.driver.JdbcProfile

class FooDb @Inject()(protected val dbConfigProvider: DatabaseConfigProvider)
  extends HasDatabaseConfigProvider[JdbcProfile] {
  import driver.api._

  class FooTable(tag: Tag) extends Table[(Long, String, String)](tag, "person") {
    def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
    def firstName = column[String]("first_name")
    def lastName = column[String]("last_name")

    def * = (id, firstName, lastName)
  }

  val query = TableQuery[FooTable]
  def findAll() = db.run(query.result)
} 
开发者ID:rfuerst87,项目名称:slick-leak-demo,代码行数:23,代码来源:FooDb.scala

示例13: AccountRepo

//设置package包名称以及导入依赖的类
package models.repo

import javax.inject._
import scala.concurrent.{ ExecutionContext, Future }
import play.api.db.slick.{ DatabaseConfigProvider, HasDatabaseConfigProvider }
import cats.data.OptionT
import models.domain.Account

@Singleton
class AccountRepo @Inject()(
    dao: models.dao.AccountDAO,
    implicit val ec: ExecutionContext,
    protected val dbConfigProvider: DatabaseConfigProvider)
  extends HasDatabaseConfigProvider[utils.db.PostgresDriver] {
  import driver.api._

  def exists(id: Int): Future[Boolean] = db.run(dao.query(id).exists.result)

  def get: Future[Seq[Account]] = db.run(dao.query.result)

  def find(id: Int): OptionT[Future, Account] =
    OptionT(db.run(dao.query(id).result.headOption))

  def add(account: Account): Future[Int] =
    db.run((dao.query returning dao.query.map(_.id)) += account)

  def update(account: Account): Future[Boolean] =
    db.run({
      dao
        .query(account.id)
        .map(_.name)
        .update(account.name)
        .map( _ > 0)})

  def delete(id: Int): Future[Int] =
    db.run(dao.query(id).delete)
} 
开发者ID:jessica1421,项目名称:HD-Cignal,代码行数:38,代码来源:AccountRepo.scala

示例14: ProvinceRepo

//设置package包名称以及导入依赖的类
package models.repo

import javax.inject._
import scala.concurrent.{ ExecutionContext, Future }
import play.api.db.slick.{ DatabaseConfigProvider, HasDatabaseConfigProvider }
import cats.data.OptionT
import models.domain.Province

@Singleton
class ProvinceRepo @Inject()(
    dao: models.dao.ProvinceDAO,
    implicit val ec: ExecutionContext,
    protected val dbConfigProvider: DatabaseConfigProvider)
  extends HasDatabaseConfigProvider[utils.db.PostgresDriver] {
  import driver.api._

  def exists(id: Int): Future[Boolean] = db.run(dao.query(id).exists.result)

  def get: Future[Seq[Province]] = db.run(dao.query.result)

  def find(id: Int): OptionT[Future, Province] =
    OptionT(db.run(dao.query(id).result.headOption))

  def add(province: Province): Future[Int] =
    db.run((dao.query returning dao.query.map(_.id)) += province)

  def updateName(id: Int, newName: String): Future[Boolean] =
    db.run(dao.query(id).map(_.name).update(newName).map( _ > 0))

  def updateRegion(id: Int, idRegion: Int): Future[Boolean] =
    db.run(dao.query(id).map(_.idRegion).update(idRegion).map( _ > 0))

  def update(id: Int, newIdRegion: Option[Int], newName: Option[String])
    : Future[Unit] = db.run {
    DBIO.seq(Seq(
      newIdRegion.map(dao.query(id).map(_.idRegion).update(_)),
      newName.map(dao.query(id).map(_.name).update(_)))
    .collect({ case Some(action) => action}):_*)
  }

  def delete(id: Int): Future[Int] =
    db.run(dao.query(id).delete)
} 
开发者ID:jessica1421,项目名称:HD-Cignal,代码行数:44,代码来源:ProvinceRepo.scala

示例15: MunicipalityRepo

//设置package包名称以及导入依赖的类
package models.repo

import javax.inject._
import scala.concurrent.{ ExecutionContext, Future }
import play.api.db.slick.{ DatabaseConfigProvider, HasDatabaseConfigProvider }
import cats.data.OptionT
import models.domain.Municipality

@Singleton
class MunicipalityRepo @Inject()(
    dao: models.dao.MunicipalityDAO,
    implicit val ec: ExecutionContext,
    protected val dbConfigProvider: DatabaseConfigProvider)
  extends HasDatabaseConfigProvider[utils.db.PostgresDriver] {
  import driver.api._

  def exists(id: Int): Future[Boolean] = db.run(dao.query(id).exists.result)

  def get: Future[Seq[Municipality]] = db.run(dao.query.result)

  def find(id: Int): OptionT[Future, Municipality] =
    OptionT(db.run(dao.query(id).result.headOption))

  def add(municipality: Municipality): Future[Int] =
    db.run((dao.query returning dao.query.map(_.id)) += municipality)

  def updateName(id: Int, newName: String): Future[Boolean] =
    db.run(dao.query(id).map(_.name).update(newName).map( _ > 0))

  def updateAreaCode(id: Int, areacode: Int): Future[Boolean] =
    db.run(dao.query(id).map(_.areacode).update(areacode).map( _ > 0))

  def updateProvince(id: Int, idProvince: Int): Future[Boolean] =
    db.run(dao.query(id).map(_.idProvince).update(idProvince).map( _ > 0))

  def update(id: Int, newName: Option[String], newAreaCode: Option[Int], newIdProvince: Option[Int])
    : Future[Unit] = db.run {
    DBIO.seq(Seq(
      newName.map(dao.query(id).map(_.name).update(_)),
      newAreaCode.map(dao.query(id).map(_.areacode).update(_)),
      newIdProvince.map(dao.query(id).map(_.idProvince).update(_)))
    .collect({ case Some(action) => action}):_*)
  }

  def delete(id: Int): Future[Int] =
    db.run(dao.query(id).delete)

} 
开发者ID:jessica1421,项目名称:HD-Cignal,代码行数:49,代码来源:MunicipalityRepo.scala


注:本文中的play.api.db.slick.HasDatabaseConfigProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。