• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala Inject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add

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

import com.google.inject.{ImplementedBy, Inject}
import model.{Artist, ArtistDAO, Temp}
import play.api.libs.json.{JsValue, Json, Writes}
import play.api.Logger

import scala.concurrent.ExecutionContext

@ImplementedBy(classOf[ArtistServicesImpl])
trait ArtistServices {
  def add (discActor : Artist) : Boolean
  def findAllByType(value: String)  : ArtistResponse
}

case class ArtistResponse(artists : List[Artist])

object ArtistResponse {

  //implicit val formatter1 = Json.format[Artist]
  implicit val formatter2 = Json.format[ArtistResponse]
  Logger.debug("Attempting risky calculation.")
  implicit val implicitFooWrites = new Writes[ArtistResponse] {
    def writes(discActors : ArtistResponse): JsValue = {
      Json.obj(
        "artists" -> discActors.artists
      )
    }
  }
}

class ArtistServicesImpl @Inject()(dao: ArtistDAO )(implicit ec: ExecutionContext) extends ArtistServices  {

  override def add(artist : Artist ): Boolean = {
    if(dao.addNew(artist)!=null)
       true
    else
      false
  }

  override def findAllByType(value: String): ArtistResponse = {
    println("Find Artist by Name: " + value)
    ArtistResponse(dao.getAllByName(value).filter(a => a.isDefined).map(a => a.get))
  }

} 
开发者ID:ralekar,项目名称:play-scala-casbah,代码行数:47,代码来源:ArtistServices.scala


示例2: Application

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

import com.google.inject.Inject
import lunatech.lunchplanner.common.DBConnection
import lunatech.lunchplanner.models.User
import lunatech.lunchplanner.services.{ MenuPerDayPerPersonService, UserService }
import lunatech.lunchplanner.viewModels.MenuPerDayPerPersonForm
import play.api.i18n.{ I18nSupport, MessagesApi }
import play.api.mvc.{ Controller, Flash }
import play.api.{ Configuration, Environment }

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

class Application @Inject() (
  userService: UserService,
  menuPerDayPerPersonService: MenuPerDayPerPersonService,
  val connection: DBConnection,
  val environment: Environment,
  val messagesApi: MessagesApi,
  val configuration: Configuration)
  extends Controller with Secured with I18nSupport {

  def index = IsAuthenticatedAsync { username =>
    implicit request =>
      userService.getByEmailAddress(username).flatMap(currentUser =>
        getIndex(currentUser))
  }

  private def getIndex(normalUser: Option[User])(implicit flash: Flash) =
    normalUser match {
      case Some(user) => getMenuPerDayPerPerson(user)
      case None => Future.successful(Unauthorized)
    }

  private def getMenuPerDayPerPerson(user: User)(implicit flash: Flash) = {
    val userIsAdmin = userService.isAdminUser(user.emailAddress)
    menuPerDayPerPersonService.getAllMenuWithNamePerDayWithDishesPerPerson(user.uuid).map(_.toArray)
      .map(menusPerDayPerPerson =>
        Ok(views.html.menuPerDayPerPerson(
          user.copy(isAdmin = userIsAdmin),
          menusPerDayPerPerson,
          MenuPerDayPerPersonForm.menuPerDayPerPersonForm)))
  }
} 
开发者ID:lunatech-labs,项目名称:lunatech-lunch-planner,代码行数:46,代码来源:Application.scala


示例3: CustomerProfileServiceImpl

//设置package包名称以及导入依赖的类
package services.profile.impl

import java.util.UUID

import com.google.inject.Inject
import daos.customer.CustomerProfileDAO
import models.CustomerInfo
import services.profile.CustomerProfileService
import play.api.libs.concurrent.Execution.Implicits._

import scala.concurrent.Future

class CustomerProfileServiceImpl @Inject() (profileDAO: CustomerProfileDAO) extends CustomerProfileService {

  def edit(userID: UUID, profile: CustomerInfo): Future[CustomerInfo] = {
    profileDAO.find(userID).flatMap {
      case Some(customerInfo) =>
        profileDAO.save(userID, profile)
      case None => profileDAO.save(userID, profile)

    }
  }
  def view(userID: UUID): Future[Option[CustomerInfo]] = profileDAO.find(userID)

} 
开发者ID:Bakuchi,项目名称:certification,代码行数:26,代码来源:CustomerProfileServiceImpl.scala


示例4: MerchantCertificatesServiceImpl

//设置package包名称以及导入依赖的类
package services.merchant.impl

import java.util.UUID

import com.google.inject.Inject
import daos.merchant.{ MerchantAreasDAO, MerchantCertificatesDAO }
import daos.util.CertificateDAO
import models._
import services.merchant.{ MerchantAreasService, MerchantCertificatesService }

import scala.concurrent.ExecutionContext.Implicits._
import scala.concurrent.Future

class MerchantCertificatesServiceImpl @Inject() (merchantCertificatesDAO: MerchantCertificatesDAO, certDAO: CertificateDAO) extends MerchantCertificatesService {

  def add(userID: UUID, cert: MerchantCertificate): Future[MerchantCertificate] = merchantCertificatesDAO.save(userID, cert)
  def edit(cert: MerchantCertificate): Future[MerchantCertificate] = certDAO.save(cert)
  def view(userID: UUID): Future[MerchantCertificates] = merchantCertificatesDAO.find(userID)
  def clear(userID: UUID): Future[MerchantCertificates] = merchantCertificatesDAO.clear(userID)
  def deleteOne(userID: UUID, cert: MerchantCertificate): Future[MerchantCertificate] = {
    certDAO.delete(cert)
    merchantCertificatesDAO.deleteOne(userID, cert)
  }
} 
开发者ID:Bakuchi,项目名称:certification,代码行数:25,代码来源:MerchantCertificatesServiceImpl.scala


示例5: StoryServiceFactory

//设置package包名称以及导入依赖的类
package io.soheila.cms.services.stories

import com.google.inject.Inject
import com.google.inject.name.Named
import io.soheila.cms.daos.StoryDAO
import io.soheila.cms.services.stories.fsm.{ Edited, Published, StoryState }


class StoryServiceFactory @Inject() (@Named("storyDAO") val storyDAO: StoryDAO, @Named("publishedStoryDAO") val publishedStory: StoryDAO) {

  private val StoryServiceMap: Map[String, StoryService] = Map(
    Published.getClass.getSimpleName -> new StoryServiceImpl(publishedStory)
  ).withDefaultValue(new StoryServiceImpl(storyDAO))

  def getStoryService(storyState: StoryState): StoryService = {
    StoryServiceMap(storyState.getClass.getSimpleName)
  }

  def getStoryService(published: Boolean): StoryService = {
    if (published) getStoryService(Published)
    else getStoryService(Edited)
  }

  def getDefaultStoryService: StoryService = {
    getStoryService(Edited)
  }

  def getPublishedStoryService: StoryService = {
    getStoryService(Published)
  }
} 
开发者ID:esfand-r,项目名称:soheila-cm,代码行数:32,代码来源:StoryServiceFactory.scala


示例6: CloudinaryStorageServiceImpl

//设置package包名称以及导入依赖的类
package io.soheila.cms.services.media.cloudinary

import cloudinary.model.CloudinaryResourceBuilder
import com.cloudinary.Cloudinary
import com.google.inject.Inject
import io.soheila.cms.services.media.ImageStorageService
import net.ceedubs.ficus.Ficus._
import play.api.Configuration

class CloudinaryStorageServiceImpl @Inject() (val cloudinaryResourceBuilder: CloudinaryResourceBuilder, configuration: Configuration) extends ImageStorageService {

  implicit val cloudinaryClient: Cloudinary = cloudinaryResourceBuilder.cld

  private val config = configuration.underlying

  override def generateSignature(paramsToSign: Map[String, _]): String = {
    val secret = config.as[String]("cloudinary.api_secret")

    val params = paramsToSign.toList.sortBy(_._1) collect {
      case (k, v: Iterable[_]) => s"$k=${v.mkString(",")}"
      case (k, v) if v != null && v.toString != "" =>
        val value = v.toString.replace("\"", "")
        s"$k=$value"
    }

    Cloudinary.sign(params.mkString("&"), secret).map("%02X" format _).mkString
  }
} 
开发者ID:esfand-r,项目名称:soheila-cm,代码行数:29,代码来源:CloudinaryStorageServiceImpl.scala


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


示例8: User

//设置package包名称以及导入依赖的类
package com.bob.reservefund.scala.Controller

import com.bob.reservefund.scala.Service.UserService
import com.bob.reservefund.scala.Util.EnvironmentContext
import com.google.inject.{Inject, Singleton}
import com.twitter.finagle.http.Request
import com.twitter.finatra.annotations.Flag
import com.twitter.finatra.http.request.RequestUtils

import com.bob.reservefund.scala.Filter.WhichUserLoginContext._

case class User(name: String, id: Int, age: Int)

@Singleton
class UserController @Inject()(userService: UserService, @Flag("active.environment") env: String) extends FinatraController {

  get("/users", swagger(o => {
    o.summary("get all users")
      .description("return all users item")
      .tag("user")
      .produces("application/json")
      .responseWith[List[User]](200, "the response json", example = Some(List(User("bb", 1, 2))))
      .responseWith[Unit](404, "the address is not found")
  })) { request: Request =>
    println(request.user.id)
    info("users")
    List(User(env, -1, -1), User(RequestUtils.pathUrl(request), 1, 1), Hello(userService.dbusername, 2, 2), Hello(EnvironmentContext.get("mqconfig.maxTryTimes", "fuck"), 3, 1))
  }

  get("/properties", swagger(o => {
    o.summary("get all properties")
      .description("return all properties item")
      .tag("user")
      .produces("application/json")
      .responseWith[List[User]](200, "the response json", example = Some(List(User("bb", 1, 2))))
      .responseWith[Unit](404, "the address is not found")
  })) { request: Request =>
    EnvironmentContext.toMap
  }
} 
开发者ID:bobxwang,项目名称:ReserveFundService,代码行数:41,代码来源:UserController.scala


示例9: show

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

import com.google.inject.Inject
import models._
import play.api.mvc.{Controller, Action}
import play.api.Play.current
import play.api.i18n.Messages.Implicits._
import scala.concurrent.duration._
import scala.concurrent.Await


class [email protected]()(userRepo: UserRepo) extends Controller {

  def show = Action {
          val userList = Await.result(userRepo.getAll,2 second)
    //      val awardList =  Await.result(awardsRepo.getAll,2 second)
    //      val assignmentList = Await.result(assignmentRepo.getAll,2 second)
    //      val languageList = Await.result(languageRepo.getAll,2 second)
    //      val programminList = Await.result(programmingRepo.getAll,2 second)

    Ok(views.html.intern(userList))
  }
} 
开发者ID:aarwee,项目名称:PLAY-SLICK-DEEPTI-KUNAL-RISHABH,代码行数:24,代码来源:InternController.scala


示例10: AdminController

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

import com.google.inject.Inject
import play.api.mvc.{Action, Controller}
import services.{AssignmentServiceApi, AdminServiceApi}
import scala.concurrent.ExecutionContext.Implicits.global
import play.api.i18n.Messages.Implicits._
import play.api.Play.current


class AdminController @Inject()(admin:AdminServiceApi,service:AssignmentServiceApi) extends Controller{

  val list=admin.getAllRecords


  def listAll=Action.async { implicit request =>
    val id=request.session.get("id").get.toInt
    service.getAssignmentById(id).map{ list =>
      Ok(views.html.assignmentdis(list.toList))
    }
  }

  def details=Action.async { implicit request =>
    val id = request.session.get("id").get.toInt
    admin.getAllRecords.map(res=> Ok(views.html.admindetails(res.toList)))
    }
  } 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:28,代码来源:AdminController.scala


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


示例12: insertAssignment

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

import com.google.inject.{ImplementedBy, Inject}
import models.Assignment
import repository.AssignmentRepo

import scala.concurrent.Future

@ImplementedBy(classOf[AssignmentService])
trait AssignmentServiceApi{
  def insertAssignment(id:Int,name:String,marks:Int,remarks:String):Future[Int]
  def updateAssignment(id:Int,name:String,marks:Int,remarks:String):Future[Int]
  def deleteAssignment(id:Int):Future[Int]
  def getAssignment:Future[List[Assignment]]
  def getAssignmentById(id:Int):Future[Seq[Assignment]]
}

class AssignmentService @Inject()(assignment:AssignmentRepo) extends AssignmentServiceApi{

  def insertAssignment(id:Int,name:String,marks:Int,remarks:String):Future[Int]={
    assignment.insert(id,name,marks,remarks)
  }

  def updateAssignment(id:Int,name:String,marks:Int,remarks:String):Future[Int]={
    assignment.update(id,name,marks,remarks)
  }

  def deleteAssignment(id:Int):Future[Int]={
    assignment.delete(id)
  }

  def getAssignment:Future[List[Assignment]]={
    assignment.getAll()
  }

  def getAssignmentById(id:Int):Future[Seq[Assignment]]= {
    assignment.getAssignment(id)
  }
} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:40,代码来源:AssignmentService.scala


示例13: getAllRecords

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

import com.google.inject.{ImplementedBy, Inject}
import models.User
import slick.lifted.Query

import scala.concurrent.Future

@ImplementedBy(classOf[AdminService])
trait AdminServiceApi{
  def getAllRecords:Future[List[User]]
  //def getAllRecords():Future[Seq[(Int,String,String,String,String,String,String)]]
}
class AdminService @Inject()(admin:AdminRepo) extends AdminServiceApi{
//  def getAllRecords():Future[Seq[(Int,String,String,String,String,String,String)]]={
//    admin.getAll().map(res=>res)
//  }
  def getAllRecords:Future[List[User]]={
   admin.getAll()
  }
} 
开发者ID:PallaviSingh1992,项目名称:Play-Slick-Assig2-v2,代码行数:22,代码来源:AdminService.scala


示例14: Session

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


import javax.inject.Singleton

import com.google.inject.Inject
import play.api.mvc._
import play.api.libs.json._
import com.gilt.akk.cluster.api.test.v0.models.json._
import service.SessionService
import scala.concurrent.ExecutionContext.Implicits.global
@Singleton
class Session @Inject()(sessionService: SessionService) {

  def get() = Action.async {
    implicit request => {
      sessionService.get().map(
        session => Results.Ok(Json.toJson(session))
      )
    }
  }
} 
开发者ID:tmccartan,项目名称:rest-akka-cluster,代码行数:23,代码来源:Session.scala


示例15: Login

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

import application.user.login.AuthenticationServices
import com.google.inject.Inject
import dal.repositories.authentication.{AuthenticationRepository}
import datastructures.LoginUser
import play.api.data.Forms._
import play.api.data._
import play.api.mvc.{Action, Controller}


class Login @Inject() (authentication: AuthenticationServices) extends Controller {

  val loginUser : Form[LoginUser] = Form( mapping(
    "username" -> nonEmptyText,
    "password" -> nonEmptyText) (LoginUser.apply)(LoginUser.unapply) )

  def getLogin = Action {
    request =>
      loginUser.bindFromRequest()(request).fold(
        formWithErrors => BadRequest,
        userData => {
          val response = authentication.authenticated(userData.username, userData.password)
          response match {
            case Some(x) => Status(401)(authentication.makeToken(x))
            case None => Ok(authentication.unauthenticatedResponse)
          }
        })
  }

} 
开发者ID:mubeenahmed,项目名称:MeGuideApi,代码行数:32,代码来源:Login.scala


示例16: Actors

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

import actors.StatisticsProvider
import akka.actor.ActorSystem
import com.google.inject.{AbstractModule, Inject}
import play.api.Configuration
import play.api.libs.ws.WSClient

class Actors @Inject() (system: ActorSystem, ws: WSClient, config: Configuration) extends ApplicationActors {
  system.actorOf(
    props = StatisticsProvider.props.(ws, config).withDispatcher("control-aware-dispatcher"),
    name = "statisticProvider"
  )
}

trait ApplicationActors

class ActorsModule extends AbstractModule {
  override def configure(): Unit = {
    bind(classOf[ApplicationActors]).to(classOf[Actors]).asEagerSingleton
  }
} 
开发者ID:jborkowski,项目名称:twitter-analytics-service,代码行数:23,代码来源:Actors.scala


示例17: ApartmentController

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

import com.google.inject.Inject
import models.{Apartment, ApartmentForm}
import play.api.i18n.{Messages, I18nSupport, MessagesApi}
import play.api.mvc.{Action, Controller}
import services.ApartmentService

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits._


class ApartmentController @Inject()(apartmentService: ApartmentService, val messagesApi: MessagesApi) extends Controller with I18nSupport with Secured {

  def dashboard = IsAuthenticated {
  username =>
     implicit request =>
      apartmentService.listAllApartments map {
        apartments => Ok(views.html.apartment(ApartmentForm.form, apartments))
      }
  }

  def addApartment() = Action.async { implicit request =>
    ApartmentForm.form.bindFromRequest.fold(
      errorForm => Future.successful(Ok(views.html.apartment(errorForm, Seq.empty[Apartment]))),
      data => {
        val newApartment = Apartment(0, data.name, data.rooms, data.area)
        apartmentService.addApartment(newApartment).map(res =>
          Redirect(routes.ApartmentController.dashboard()).flashing(Messages("flash.success") -> res)
        )
      })

  }

  def deleteApartment(id: Long) = Action.async { implicit request =>
    apartmentService.deleteApartment(id) map { res =>
      Redirect(routes.ApartmentController.dashboard())

    }

  }
} 
开发者ID:kunalherkal,项目名称:rental-manager,代码行数:43,代码来源:ApartmentController.scala


示例18: TenantController

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

import com.google.inject.Inject
import models.{Tenant, TenantForm}
import play.api.i18n.{Messages, I18nSupport, MessagesApi}
import play.api.mvc.{Action, Controller}
import services.TenantService
import play.api.libs.concurrent.Execution.Implicits._

import scala.concurrent.Future


class TenantController @Inject()(tenantService: TenantService, val messagesApi: MessagesApi) extends Controller with I18nSupport with Secured {

  def dashboard = IsAuthenticated {
    username =>
     implicit request =>
      tenantService.listAllTenants map {
      tenants => Ok(views.html.tenant(TenantForm.form, tenants))
    }
  }

  def addTenant() = Action.async { implicit request =>
    TenantForm.form.bindFromRequest.fold(
      errorForm => Future.successful(Ok(views.html.tenant(errorForm, Seq.empty[Tenant]))),
      data => {
        val newTenant = Tenant(0, data.firstName, data.lastName, data.mobile, data.email)
        tenantService.addTenant(newTenant).map(res =>
          Redirect(routes.TenantController.dashboard()).flashing(Messages("flash.success") -> res)
        )
    })
  }

  def deleteTenant(id: Long) = Action.async { implicit request =>
    tenantService.deleteTenant(id) map { res =>
      Redirect(routes.TenantController.dashboard())

    }

  }

} 
开发者ID:kunalherkal,项目名称:rental-manager,代码行数:43,代码来源:TenantController.scala


示例19: validate

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


import com.google.inject.Inject
import models.{SimpleValidatorStats, Task, Verification}

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global


trait Validator {
  def validate(verification: Verification): Future[Boolean]
}

class SimpleValidator @Inject()(
                                 val simpleValidatorStatsRepo: SimpleValidatorStatsRepo
                               ) extends Validator {

  def validate(verification: Verification): Future[Boolean] = {
    updateStats(verification).map(validation(_))
  }

  def updateStats(verification: Verification): Future[SimpleValidatorStats] = {
    val stats = simpleValidatorStatsRepo.search("task_id", verification.task_id.toString) flatMap {
      case s: Traversable[SimpleValidatorStats] if s.size == 1 => Future.successful(s.head)
      case s: Traversable[SimpleValidatorStats] if s.isEmpty =>
        Future.successful(new SimpleValidatorStats(task_id = verification.task_id))
      case _ => Future.failed(new Throwable("Database corrupt"))
    }
    val updatedStats = verification.value match {
      case None => stats.map(x => x.copy(numNoValue = x.numNoValue + 1))
      case Some(true) => stats.map(x => x.copy(numTrue = x.numTrue + 1))
      case Some(false) => stats.map(x => x.copy(numFalse = x.numFalse + 1))
    }
    for {
      updatedStats <- updatedStats
      savedStats <- simpleValidatorStatsRepo.save(updatedStats)
    } yield updatedStats
  }

  def validation(stats: SimpleValidatorStats) = stats.numTrue >= stats.numFalse
} 
开发者ID:BonarBeavis,项目名称:Veritask,代码行数:43,代码来源:Validator.scala


示例20: Browser

//设置package包名称以及导入依赖的类
package io.github.mijicd.prezi.domain

import com.google.inject.Inject

class Browser @Inject()(items: Seq[Presentation]) {
  def search(term: SearchTerm): ResultSet = {
    val results = lookup(term)
    val begin = (term.page - 1) * term.size
    val end = begin + term.size

    ResultSet(MetaInfo(results.size), results.slice(begin, end))
  }

  private def lookup(term: SearchTerm) =
    if (!term.title.isEmpty) {
      items filter { item => item.title.equals(term.title) }
    } else {
      items
    }
} 
开发者ID:mijicd,项目名称:finatra-demo,代码行数:21,代码来源:Browser.scala



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Writes类代码示例发布时间:2022-05-23
下一篇:
Scala FileWriter类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap