This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.playframework.com/documentation/latest/Configuration | |
play.http.secret.key = "changeme" | |
play.http.secret.key=${?APPLICATION_SECRET} | |
play.modules.enabled += "modules.AppModule" | |
slick.dbs.default { | |
profile = "slick.jdbc.PostgresProfile$" | |
db.url = "jdbc:postgresql://localhost:5432/fulltextexample" | |
db.url = ${?DB_URL} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package modules | |
import com.google.inject.AbstractModule | |
import models.daos.{DocumentDAO, DocumentDAOImpl} | |
import models.services.{DocumentService, DocumentServiceImpl} | |
import net.codingwell.scalaguice.ScalaModule | |
class AppModule extends AbstractModule with ScalaModule { | |
override def configure(): Unit = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Routes | |
# This file defines all application routes (Higher priority routes first) | |
# https://www.playframework.com/documentation/latest/ScalaRouting | |
# ~~~~ | |
# An example controller showing a sample home page | |
GET / controllers.HomeController.index() | |
GET /documents controllers.DocumentsController.documents(page: Int ?= 0, pageSize: Int ?= 10) | |
GET /documents/new controllers.DocumentsController.createDocument | |
GET /documents/search controllers.DocumentsController.searchPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import models.services.DocumentService | |
import forms.{SaveDocumentForm, SearchDocumentForm} | |
import models.Document | |
import play.api.mvc._ | |
import javax.inject.Inject | |
import scala.concurrent.{ExecutionContext, Future} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models.services | |
import models.{Document, Page, SearchResult} | |
import models.daos.DocumentDAO | |
import javax.inject.Inject | |
import scala.concurrent.{ExecutionContext, Future} | |
class DocumentServiceImpl @Inject() (documentDAO: DocumentDAO)(implicit ec: ExecutionContext) extends DocumentService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models.daos | |
import models.{Document, Page, SearchResult} | |
import MyPostgresProfile.api._ | |
import play.api.Logging | |
import play.api.db.slick.DatabaseConfigProvider | |
import javax.inject.Inject | |
import scala.concurrent.{ExecutionContext, Future} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models.daos | |
import MyPostgresProfile.api._ | |
import com.github.tminglei.slickpg.TsVector | |
import models.Document | |
import slick.lifted.ProvenShape | |
trait TableDefinitions { | |
class DocumentTable(tag: Tag) extends Table[Document](tag, Some("app"), "document") { | |
def id = column[Long]("id", O.PrimaryKey, O.AutoInc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models.daos | |
import com.github.tminglei.slickpg._ | |
trait MyPostgresProfile extends ExPostgresProfile | |
with PgArraySupport | |
with PgDate2Support | |
with PgRangeSupport | |
with PgHStoreSupport | |
with PgSearchSupport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
case class SearchResult(highlights: String, rank: Float, documentId: Long) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
case class Page[T](items: Seq[T], page: Int, offset: Int, total: Long, totalPageCount: Long) { | |
lazy val prev: Option[Int] = Option(page - 1).filter(_ >= 0) | |
lazy val next: Option[Int] = Option(page + 1).filter(_ => (offset + items.size) < total) | |
} |
NewerOlder