Commit 22966c47 authored by shahriar's avatar shahriar
Browse files

Update lottery.controller.ts

parent 4c19977a
import { Body, Controller, Get, Post } from '@nestjs/common';
import { ApiBody, ApiTags } from '@nestjs/swagger'
import { ChangeStatusDto } from './dto/change-status-dto'
import { WeeklySearchDto } from './dto/weekly-search-dto'
import { LotteryService } from './lottery.service';
@Controller('lottery')
export class LotteryController {
constructor(private lotteryService: LotteryService) { }
//weekly lottery apies:
@ApiBody({ type: WeeklySearchDto })
@ApiTags('Lottery/weekly')
@Post('weekly/search')
async getUserResults(@Body() searchDto: WeeklySearchDto) {
return await this.lotteryService.getUserScore(searchDto.username)
}
@ApiTags('Lottery/weekly')
@Get('weekly/calculate-score')
async addResultsToDb() {
return await this.lotteryService.addResultsToDB()
}
@ApiTags('Lottery/weekly')
@Get('weekly/get-lottory-result')
async getResultDb() {
return await this.lotteryService.getResultDb()
}
@ApiBody({ type: ChangeStatusDto })
@ApiTags('Lottery/weekly')
@Post('weekly/change-status')
async changeStatus(@Body() changeStatusDto: ChangeStatusDto) {
return await this.lotteryService.changeStatus(changeStatusDto)
}
}
import { Body, Controller, Get, Post } from '@nestjs/common';
import { ApiBody, ApiTags } from '@nestjs/swagger'
import { ChangeStatusDto } from './dto/change-status-dto'
import { WeeklySearchDto } from './dto/weekly-search-dto'
import { LotteryService } from './lottery.service';
@Controller('lottery')
export class LotteryController {
constructor(private lotteryService: LotteryService) { }
//weekly lottery apies:
@ApiBody({ type: WeeklySearchDto })
@ApiTags('Lottery/weekly')
@Post('weekly/search')
async getUserResults(@Body() searchDto: WeeklySearchDto) {
return await this.lotteryService.getUserScore(searchDto.username)
}
@ApiTags('Lottery/weekly')
@Get('weekly/calculate-score')
async addResultsToDb() {
return await this.lotteryService.addResultsToDB()
}
@ApiTags('Lottery/weekly')
@Get('weekly/get-lottory-result')
async getResultDb() {
return await this.lotteryService.getResultDb().sort(() => Math.random() - 0.5);
}
@ApiBody({ type: ChangeStatusDto })
@ApiTags('Lottery/weekly')
@Post('weekly/change-status')
async changeStatus(@Body() changeStatusDto: ChangeStatusDto) {
return await this.lotteryService.changeStatus(changeStatusDto)
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment