Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
shahriar
instagram-service
Commits
22966c47
Commit
22966c47
authored
Nov 27, 2021
by
shahriar
☹
Browse files
Update lottery.controller.ts
parent
4c19977a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lottery/lottery.controller.ts
View file @
22966c47
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
)
}
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment