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
0c9235d1
Commit
0c9235d1
authored
Aug 15, 2021
by
soheib
Browse files
merge
parents
bded2cd7
38b34484
Changes
27
Hide whitespace changes
Inline
Side-by-side
src/lottery/dto/calculate-score-dto.ts
View file @
0c9235d1
export
class
CalculateScoreDto
{
profile_username
:
string
post_array
:
string
[]
export
class
CalculateScoreDto
{
profile_username
:
string
post_array
:
string
[]
}
\ No newline at end of file
src/lottery/dto/change-status-dto.ts
View file @
0c9235d1
export
class
ChangeStatusDto
{
mobile
:
string
username
:
string
export
class
ChangeStatusDto
{
mobile
:
string
username
:
string
}
\ No newline at end of file
src/lottery/dto/weekly-search-dto.ts
View file @
0c9235d1
export
class
WeeklySearchDto
{
username
:
string
profile_username
:
string
post_array
:
string
[]
export
class
WeeklySearchDto
{
username
:
string
profile_username
:
string
post_array
:
string
[]
}
\ No newline at end of file
src/lottery/lottery.controller.ts
View file @
0c9235d1
import
{
Body
,
Query
,
Controller
,
Get
,
Post
}
from
'
@nestjs/common
'
;
import
{
CalculateScoreDto
}
from
'
./dto/calculate-score-dto
'
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:
@
Post
(
'
weekly/search
'
)
async
getUserResults
(@
Body
()
searchDto
:
WeeklySearchDto
)
{
return
await
this
.
lotteryService
.
getUserScore
(
searchDto
.
username
,
searchDto
.
profile_username
,
searchDto
.
post_array
)
}
@
Post
(
'
weekly/calculate-score
'
)
async
addResultsToDb
(@
Body
()
calculateScoreDto
:
CalculateScoreDto
)
{
return
await
this
.
lotteryService
.
addResultsToDB
(
calculateScoreDto
.
profile_username
,
calculateScoreDto
.
post_array
)
}
@
Get
(
'
weekly/get-lottory-result
'
)
async
getResultDb
()
{
return
await
this
.
lotteryService
.
getResultDb
()
}
@
Post
(
'
weekly/change-status
'
)
async
changeStatus
(@
Body
()
changeStatusDto
:
ChangeStatusDto
)
{
console
.
log
(
'
here
'
);
return
await
this
.
lotteryService
.
changeStatus
(
changeStatusDto
)
}
}
import
{
Body
,
Query
,
Controller
,
Get
,
Post
}
from
'
@nestjs/common
'
;
import
{
CalculateScoreDto
}
from
'
./dto/calculate-score-dto
'
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:
@
Post
(
'
weekly/search
'
)
async
getUserResults
(@
Body
()
searchDto
:
WeeklySearchDto
)
{
return
await
this
.
lotteryService
.
getUserScore
(
searchDto
.
username
,
searchDto
.
profile_username
,
searchDto
.
post_array
)
}
@
Post
(
'
weekly/calculate-score
'
)
async
addResultsToDb
(@
Body
()
calculateScoreDto
:
CalculateScoreDto
)
{
return
await
this
.
lotteryService
.
addResultsToDB
(
calculateScoreDto
.
profile_username
,
calculateScoreDto
.
post_array
)
}
@
Get
(
'
weekly/get-lottory-result
'
)
async
getResultDb
()
{
return
await
this
.
lotteryService
.
getResultDb
()
}
@
Post
(
'
weekly/change-status
'
)
async
changeStatus
(@
Body
()
changeStatusDto
:
ChangeStatusDto
)
{
console
.
log
(
'
here
'
);
return
await
this
.
lotteryService
.
changeStatus
(
changeStatusDto
)
}
}
src/main.ts
View file @
0c9235d1
import
{
NestFactory
}
from
'
@nestjs/core
'
;
import
{
AppModule
}
from
'
./app.module
'
;
async
function
bootstrap
()
{
const
app
=
await
NestFactory
.
create
(
AppModule
);
app
.
enableCors
({
origin
:
'
*
'
,
methods
:
'
GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS
'
,
credentials
:
true
,
})
await
app
.
listen
(
400
2
).
then
(()
=>
{
console
.
log
(
`server start on port 400
2
`
);
})
}
bootstrap
();
1
import
{
NestFactory
}
from
'
@nestjs/core
'
;
import
{
AppModule
}
from
'
./app.module
'
;
async
function
bootstrap
()
{
const
app
=
await
NestFactory
.
create
(
AppModule
);
app
.
enableCors
({
origin
:
'
*
'
,
methods
:
'
GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS
'
,
credentials
:
true
,
})
await
app
.
listen
(
400
1
).
then
(()
=>
{
console
.
log
(
`server start on port 400
1
`
);
})
}
bootstrap
();
src/request.schema.ts
View file @
0c9235d1
import
{
Prop
,
Schema
,
SchemaFactory
}
from
'
@nestjs/mongoose
'
;
import
{
Document
,
Types
}
from
'
mongoose
'
;
export
type
RequestDocument
=
Request
&
Document
;
@
Schema
({
timestamps
:
true
})
export
class
Request
{
@
Prop
()
_id
:
Types
.
ObjectId
;
@
Prop
()
cursor
:
string
;
@
Prop
()
type
:
string
;
@
Prop
()
post_short_code
:
string
;
@
Prop
()
account_username
:
string
;
}
export
const
RequestSchema
=
SchemaFactory
.
createForClass
(
Request
);
import
{
Prop
,
Schema
,
SchemaFactory
}
from
'
@nestjs/mongoose
'
;
import
{
Document
,
Types
}
from
'
mongoose
'
;
export
type
RequestDocument
=
Request
&
Document
;
@
Schema
({
timestamps
:
true
})
export
class
Request
{
@
Prop
()
_id
:
Types
.
ObjectId
;
@
Prop
()
cursor
:
string
;
@
Prop
()
type
:
string
;
@
Prop
()
post_short_code
:
string
;
@
Prop
()
account_username
:
string
;
}
export
const
RequestSchema
=
SchemaFactory
.
createForClass
(
Request
);
src/result.schema.ts
View file @
0c9235d1
import
{
Prop
,
Schema
,
SchemaFactory
}
from
'
@nestjs/mongoose
'
;
import
{
Document
,
Types
}
from
'
mongoose
'
;
export
type
ResultDocument
=
Result
&
Document
;
@
Schema
({
timestamps
:
true
})
export
class
Result
{
@
Prop
()
username
:
string
;
@
Prop
()
valid_mentions
:
number
;
@
Prop
()
mentions_before
:
number
;
@
Prop
()
followed_before
:
number
;
@
Prop
()
pending_mentions
:
number
;
@
Prop
()
score
:
number
;
@
Prop
()
valid_users
:
Array
<
string
>
;
@
Prop
()
mentions_before_users
:
Array
<
string
>
;
@
Prop
()
followed_before_users
:
Array
<
string
>
;
@
Prop
()
pending_users
:
Array
<
string
>
;
}
export
const
ResultSchema
=
SchemaFactory
.
createForClass
(
Result
);
import
{
Prop
,
Schema
,
SchemaFactory
}
from
'
@nestjs/mongoose
'
;
import
{
Document
,
Types
}
from
'
mongoose
'
;
export
type
ResultDocument
=
Result
&
Document
;
@
Schema
({
timestamps
:
true
})
export
class
Result
{
@
Prop
()
username
:
string
;
@
Prop
()
valid_mentions
:
number
;
@
Prop
()
mentions_before
:
number
;
@
Prop
()
followed_before
:
number
;
@
Prop
()
pending_mentions
:
number
;
@
Prop
()
score
:
number
;
@
Prop
()
valid_users
:
Array
<
string
>
;
@
Prop
()
mentions_before_users
:
Array
<
string
>
;
@
Prop
()
followed_before_users
:
Array
<
string
>
;
@
Prop
()
pending_users
:
Array
<
string
>
;
}
export
const
ResultSchema
=
SchemaFactory
.
createForClass
(
Result
);
Prev
1
2
Next
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