Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moved persistence related stuff to the 'dao' package

  • Loading branch information...
commit ab438f7135965f80f84cdc791f8b6d44bca43c24 1 parent f8d026f
@jcranky authored
View
1  app/controllers/Admin.scala
@@ -6,6 +6,7 @@ import play.api.data.Forms._
import play.api.mvc._
import models._
+import models.dao._
import views._
object Admin extends Controller with Secured {
View
1  app/controllers/Application.scala
@@ -6,6 +6,7 @@ import play.api.data.Forms._
import play.api.mvc._
import models._
+import models.dao._
import views._
object Application extends Controller {
View
3  app/controllers/Items.scala
@@ -4,7 +4,8 @@ import play.api._
import play.api.data._
import play.api.data.Forms._
import play.api.mvc._
-import models.{BidHelper, Bid, Item, DAOFactory}
+import models.BidHelper
+import models.dao.{Item, DAOFactory}
object Items extends Controller {
val itemDAO = DAOFactory.itemDAO
View
2  app/models/ItemBids.scala
@@ -1,5 +1,7 @@
package models
+import models.dao._
+
case class ItemBids(higherBid: Option[Bid], bidsList: List[Bid] = Nil)(implicit val item: Item) {
def this(bidsList: List[Bid], item: Item) =
this(if(bidsList.size > 0) Some(bidsList.max) else None, bidsList)(item)
View
2  app/models/bid-actors.scala
@@ -4,6 +4,8 @@ import akka.actor._
import play.api.Play.current
import play.api.libs.concurrent.Akka
+import models.dao._
+
object BidHelper {
val masterBidActor = Akka.system.actorOf(Props[MasterBidActor], "master-bid-actor")
View
2  app/models/AnormItem.scala → app/models/dao/AnormItem.scala
@@ -1,4 +1,4 @@
-package models
+package models.dao
import anorm._
import anorm.SqlParser._
View
17 app/models/dao/DAOFactory.scala
@@ -0,0 +1,17 @@
+package models.dao
+
+object DAOFactory {
+ val dbConfig = play.api.Play.current.configuration.getString("lojinha.db.type", Some(Set("sql", "mongo")))
+
+ def itemDAO: ItemDAO = dbConfig match {
+ case Some("mongo") => MongoItemDAO
+ case Some("sql") => AnormItemDAO
+ case None => AnormItemDAO
+ }
+
+ def bidDAO: BidDAO = dbConfig match {
+ case Some("mongo") => MongoBidDAO
+ case Some("sql") => AnormBidDAO
+ case None => AnormBidDAO
+ }
+}
View
18 app/models/Item.scala → app/models/dao/Item.scala
@@ -1,4 +1,4 @@
-package models
+package models.dao
case class Item(id: Int, name: String, description: String, imageKeys: Option[String])
@@ -28,19 +28,3 @@ trait BidDAO {
def create(bid: Bid)
}
-
-object DAOFactory {
- val dbConfig = play.api.Play.current.configuration.getString("lojinha.db.type", Some(Set("sql", "mongo")))
-
- def itemDAO: ItemDAO = dbConfig match {
- case Some("mongo") => MongoItemDAO
- case Some("sql") => AnormItemDAO
- case None => AnormItemDAO
- }
-
- def bidDAO: BidDAO = dbConfig match {
- case Some("mongo") => MongoBidDAO
- case Some("sql") => AnormBidDAO
- case None => AnormBidDAO
- }
-}
View
2  app/models/MongoItem.scala → app/models/dao/MongoItem.scala
@@ -1,4 +1,4 @@
-package models
+package models.dao
import com.mongodb.casbah.Imports._
import com.mongodb.casbah.commons.MongoDBObject
View
2  app/views/body.scala.html
@@ -1,4 +1,4 @@
-@(items: Seq[Item])
+@(items: Seq[models.dao.Item])
@import models.images.MediumThumb
<ul>
View
2  app/views/itemDetails.scala.html
@@ -1,4 +1,4 @@
-@(item: Item, highestBid: Option[Bid], bidForm: Form[(String, Int)])
+@(item: models.dao.Item, highestBid: Option[models.dao.Bid], bidForm: Form[(String, Int)])
@import helper._
@import helper.twitterBootstrap._
View
2  test/models/ItemBidsSpec.scala
@@ -3,6 +3,8 @@ package models
import org.specs2.mock.Mockito
import org.specs2.mutable.Specification
+import models.dao._
+
class ItemBidsSpec extends Specification with Mockito {
implicit val item = mock[Item]
val bid = Bid(1, "someone@jcranky.com", 10, item)
Please sign in to comment.
Something went wrong with that request. Please try again.