Advertisement
alfin123

kodingan post template

Feb 6th, 2020
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.62 KB | None | 0 0
  1.    override suspend fun createRowTemplateById(
  2.             company: Company,
  3.             rowId: String,
  4.             name: String,
  5.             thumbnail: String,
  6.             categories: List<String>
  7.     ): RowSectionData {
  8.         val pageRow = datastore.get(PageRow::class.java, ObjectId(rowId)) orNotFound "page row"
  9.         val pageComponents = datastore.find(PageComponent::class.java).field("row").equal(pageRow).asList()
  10.         val rowTemplate = PageRowSection()
  11.         rowTemplate.team = company
  12.         rowTemplate.name = name
  13.         rowTemplate.thumbnail = thumbnail
  14.         if (categories.isNotEmpty())rowTemplate.categories= ArrayList(categories.map { it.toLowerCase() })
  15.         rowTemplate.setting = pageRow.setting
  16.         datastore.save(rowTemplate)
  17.         val res = pageComponents.map { pageComp ->
  18.             val comp = PageComponentSection()
  19.             comp.row = rowTemplate
  20.             comp.type = pageComp.type
  21.             comp.setting = pageComp.setting
  22.             comp.colomorder = pageComp.colomorder
  23.             comp.formId = pageComp.formId
  24.             comp.html = pageComp.html
  25.             comp.htmlCode = pageComp.htmlCode
  26.             comp.order = pageComp.order
  27.             comp.selected = pageComp.selected
  28.             comp.source = pageComp.source
  29.             comp.textHtml = pageComp.textHtml
  30.             comp.title = pageComp.title
  31.             comp.titleHtml = pageComp.titleHtml
  32.             comp.rating = pageComp.rating
  33.             comp.priceHtml = pageComp.priceHtml
  34.             datastore.save(comp)
  35.             comp
  36.         }
  37.         return RowSectionData(rowTemplate, res)
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement