本文整理汇总了Scala中play.api.db.slick.HasDatabaseConfigProvider类的典型用法代码示例。如果您正苦于以下问题:Scala HasDatabaseConfigProvider类的具体用法?Scala HasDatabaseConfigProvider怎么用?Scala HasDatabaseConfigProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HasDatabaseConfigProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: BusinessTypeRepo
//设置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.BusinessType
@Singleton
class BusinessTypeRepo @Inject()(
dao: models.dao.BusinessTypeDAO,
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[BusinessType]] = db.run(dao.query.result)
def find(id: Int): OptionT[Future, BusinessType] =
OptionT(db.run(dao.query(id).result.headOption))
def add(businesstype: BusinessType): Future[Int] =
db.run((dao.query returning dao.query.map(_.id)) += businesstype)
def update(businesstype: BusinessType): Future[Boolean] =
db.run(dao.query(businesstype.id).map(_.name).update(businesstype.name).map( _ > 0))
def delete(id: Int): Future[Int] =
db.run(dao.query(id).delete)
}
开发者ID:jessica1421,项目名称:HD-Cignal,代码行数:33,代码来源: BusinessTypeRepo.scala
示例17: CountryRepo
//设置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.Country
@Singleton
class CountryRepo @Inject()(
dao: models.dao.CountryDAO,
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[Country]] = db.run(dao.query.result)
def find(id: Int): OptionT[Future, Country] =
OptionT(db.run(dao.query(id).result.headOption))
def add(country: Country): Future[Int] =
db.run((dao.query returning dao.query.map(_.id)) += country)
def update(country: Country): Future[Boolean] =
db.run(dao.query(country.id).map(_.name).update(country.name).map( _ > 0))
def delete(id: Int): Future[Int] =
db.run(dao.query(id).delete)
}
开发者ID:jessica1421,项目名称:HD-Cignal,代码行数:33,代码来源:CountryRepo.scala
示例18: FirmTypeRepo
//设置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.FirmType
@Singleton
class FirmTypeRepo @Inject()(
dao: models.dao.FirmTypeDAO,
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[FirmType]] = db.run(dao.query.result)
def find(id: Int): OptionT[Future, FirmType] =
OptionT(db.run(dao.query(id).result.headOption))
def add(firmType: FirmType): Future[Int] =
db.run((dao.query returning dao.query.map(_.id)) += firmType)
def update(firmType: FirmType): Future[Boolean] =
db.run(dao.query(firmType.id).update(firmType).map( _ > 0))
def delete(id: Int): Future[Int] =
db.run(dao.query(id).delete)
}
开发者ID:jessica1421,项目名称:HD-Cignal,代码行数:33,代码来源:FirmTypeRepo.scala
示例19: AccountClassificationRepo
//设置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.AccountClassification
@Singleton
class AccountClassificationRepo @Inject()(
dao: models.dao.AccountClassificationDAO,
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[AccountClassification]] = db.run(dao.query.result)
def getByType(isMain: Boolean): Future[Seq[AccountClassification]] =
db.run(dao.query.filter(_.isMain === isMain).result)
def find(id: Int): OptionT[Future, AccountClassification] =
OptionT(db.run(dao.query(id).result.headOption))
def add(accountClassification: AccountClassification): Future[Int] =
db.run((dao.query returning dao.query.map(_.id)) += accountClassification)
def update(accountClassification: AccountClassification): Future[Boolean] =
db.run({
dao
.query(accountClassification.id)
.map(_.name)
.update(accountClassification.name)
.map( _ > 0)})
def delete(id: Int): Future[Int] =
db.run(dao.query(id).delete)
}
开发者ID:jessica1421,项目名称:HD-Cignal,代码行数:41,代码来源:AccountClassificationRepo.scala
示例20: FirmRepo
//设置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.Firm
@Singleton
class FirmRepo @Inject()(
dao: models.dao.FirmDAO,
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[Firm]] = db.run(dao.query.result)
def getByType(idFirmType: Int): Future[Seq[Firm]] =
db.run(dao.query.filter(_.idFirmType === idFirmType).result)
def getByParent(idParent: Int): Future[Seq[Firm]] =
db.run(dao.query.filter(_.idParent === idParent).result)
def find(id: Int): OptionT[Future, Firm] =
OptionT(db.run(dao.query(id).result.headOption))
def add(firm: Firm): Future[Int] =
db.run((dao.query returning dao.query.map(_.id)) += firm)
def update(firm: Firm): Future[Boolean] =
db.run(dao.query(firm.id).update(firm).map( _ > 0))
def delete(id: Int): Future[Int] =
db.run(dao.query(id).delete)
}
开发者ID:jessica1421,项目名称:HD-Cignal,代码行数:39,代码来源:FirmRepo.scala
注:本文中的play.api.db.slick.HasDatabaseConfigProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论