Created
December 22, 2018 03:39
-
-
Save chrishieu/40735dc8b53dda9d753e26823fc469a3 to your computer and use it in GitHub Desktop.
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
import { Get, Controller, Render, Dependencies } from '@nestjs/common'; | |
import { CategoryServiceImpl } from 'Services/Implementation/category.service.impl'; | |
import { CategoryService } from 'Services/category.service'; | |
import { DictionaryServiceImpl } from 'Services/Implementation/dictionary.service.impl'; | |
import { PromotionServiceImpl } from 'Services/Implementation/promotion.service.impl'; | |
import { PromotionService } from 'Services/promotion.service'; | |
import { DictionaryService } from 'Services/dictionary.service'; | |
@Controller() | |
@Dependencies(CategoryServiceImpl, PromotionServiceImpl, DictionaryServiceImpl) | |
export class PromotionController { | |
private categoryService: CategoryService; | |
private promotionService: PromotionService; | |
private dictionaryService: DictionaryService; | |
constructor(categoryService: CategoryService, promotionService: PromotionService, dictionaryService: DictionaryService) { | |
this.categoryService = categoryService; | |
this.promotionService = promotionService; | |
this.dictionaryService = dictionaryService; | |
} | |
@Get("/uu-dai") | |
@Render('Main/Promotion/Index') | |
async root() { | |
const viewBag = { | |
promotionList: await this.promotionService.findAll(), | |
promotionTitle: await this.dictionaryService.getPromotionTitle() | |
} | |
return viewBag; | |
} | |
@Get("/api-uu-dai") | |
async apiUuDai() { | |
const viewBag = { | |
promotionList: await this.promotionService.findAll(), | |
promotionTitle: await this.dictionaryService.getPromotionTitle() | |
} | |
viewBag.promotionList = viewBag.promotionList.map(x => { | |
const newPosts = x.category.posts.map(y => { | |
return { ...y, slug : y.slug + '?isWebApp=true'} | |
}) | |
x.category.posts = newPosts; | |
return x | |
}) | |
return viewBag; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment