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 { Body, Controller, Get, Post } from '@nestjs/common';
import { ApiBody, ApiTags } from '@nestjs/swagger' import { ApiBody, ApiTags } from '@nestjs/swagger'
import { ChangeStatusDto } from './dto/change-status-dto' import { ChangeStatusDto } from './dto/change-status-dto'
import { WeeklySearchDto } from './dto/weekly-search-dto' import { WeeklySearchDto } from './dto/weekly-search-dto'
import { LotteryService } from './lottery.service'; import { LotteryService } from './lottery.service';
@Controller('lottery') @Controller('lottery')
export class LotteryController { export class LotteryController {
constructor(private lotteryService: LotteryService) { } constructor(private lotteryService: LotteryService) { }
//weekly lottery apies: //weekly lottery apies:
@ApiBody({ type: WeeklySearchDto }) @ApiBody({ type: WeeklySearchDto })
@ApiTags('Lottery/weekly') @ApiTags('Lottery/weekly')
@Post('weekly/search') @Post('weekly/search')
async getUserResults(@Body() searchDto: WeeklySearchDto) { async getUserResults(@Body() searchDto: WeeklySearchDto) {
return await this.lotteryService.getUserScore(searchDto.username) return await this.lotteryService.getUserScore(searchDto.username)
} }
@ApiTags('Lottery/weekly') @ApiTags('Lottery/weekly')
@Get('weekly/calculate-score') @Get('weekly/calculate-score')
async addResultsToDb() { async addResultsToDb() {
return await this.lotteryService.addResultsToDB() return await this.lotteryService.addResultsToDB()
} }
@ApiTags('Lottery/weekly') @ApiTags('Lottery/weekly')
@Get('weekly/get-lottory-result') @Get('weekly/get-lottory-result')
async getResultDb() { async getResultDb() {
return await this.lotteryService.getResultDb() return await this.lotteryService.getResultDb().sort(() => Math.random() - 0.5);
} }
@ApiBody({ type: ChangeStatusDto }) @ApiBody({ type: ChangeStatusDto })
@ApiTags('Lottery/weekly') @ApiTags('Lottery/weekly')
@Post('weekly/change-status') @Post('weekly/change-status')
async changeStatus(@Body() changeStatusDto: ChangeStatusDto) { async changeStatus(@Body() changeStatusDto: ChangeStatusDto) {
return await this.lotteryService.changeStatus(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