Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. def createCrawlEntry(resultCrawlerFK: ResultCrawlerFKModel): Future[ResultCrawlerFKModel] = db.run {
  2. (resultCrawlerFKs
  3. returning resultCrawlerFKs.map(_.resultCrawlerFKId)
  4. into ((params, id) => params.copy(resultCrawlerFKId = Some(id)))
  5. ) += resultCrawlerFK
  6. }
  7.  
  8. case class ResultCrawlerFKModel(
  9. resultCrawlerFKId: Option[Int] = None,
  10. var resultId: Int,
  11. var tagId: Option[Int],
  12. classId: Option[Int],
  13. idId: Option[Int],
  14. var changeDetected: Boolean,
  15. var content: Option[String]
  16. )
  17.  
  18. object ResultCrawlerFKModel {
  19. implicit val ResultCrawlerFKFormat: OFormat[ResultCrawlerFKModel] = Json.format[ResultCrawlerFKModel]
  20. }
  21.  
  22. trait ResultCrawlerFKComponent {
  23. self: HasDatabaseConfigProvider[JdbcProfile] =>
  24.  
  25. import profile.api._
  26.  
  27. class ResultCrawlerFK(tag: Tag) extends Table[ResultCrawlerFKModel](tag, "ResultCrawlerFK") {
  28. def resultCrawlerFKId: Rep[Int] = column[Int]("resultCrawlerFKId", O.PrimaryKey, O.AutoInc)
  29.  
  30. def resultId: Rep[Int] = column[Int]("resultId")
  31.  
  32. def tagId: Rep[Option[Int]] = column[Option[Int]]("tagId")
  33.  
  34. def classId: Rep[Option[Int]] = column[Option[Int]]("classId")
  35.  
  36. def idId: Rep[Option[Int]] = column[Option[Int]]("idId")
  37.  
  38. def changeDetected: Rep[Boolean] = column[Boolean]("changeDetected")
  39.  
  40. def content: Rep[Option[String]] = column[Option[String]]("content")
  41.  
  42. def * : ProvenShape[ResultCrawlerFKModel] = (
  43. resultCrawlerFKId.?,
  44. resultId,
  45. tagId,
  46. classId,
  47. idId,
  48. changeDetected,
  49. content
  50. ) <> ( { tuple: (
  51. Option[Int], // resultCrawlerFKId
  52. Int, // resultId
  53. Option[Int], // tagId
  54. Option[Int], // classId
  55. Option[Int], // idId
  56. Boolean, // changeDetected
  57. Option[String] // content
  58. ) =>
  59. ResultCrawlerFKModel(
  60. resultCrawlerFKId = tuple._1,
  61. resultId = tuple._2,
  62. tagId = tuple._3,
  63. classId = tuple._4,
  64. idId = tuple._5,
  65. changeDetected = tuple._6,
  66. content = tuple._7
  67. )
  68. }, {
  69. ps: ResultCrawlerFKModel =>
  70. Some((
  71. ps.resultCrawlerFKId,
  72. ps.resultId,
  73. ps.tagId,
  74. ps.classId,
  75. ps.idId,
  76. ps.changeDetected,
  77. ps.content
  78. ))
  79. })
  80. }
  81.  
  82. val resultCrawlerFKs: TableQuery[ResultCrawlerFK] = TableQuery[ResultCrawlerFK] // Query object
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement