Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
Ygopro Arena Revive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Ygopro Arena Revive
Commits
980c4376
Commit
980c4376
authored
Oct 31, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change payment interface to pay-exp
parent
0593163d
Pipeline
#17562
passed with stages
in 2 minutes and 28 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
14 deletions
+43
-14
src/app.controller.ts
src/app.controller.ts
+15
-4
src/app.service.ts
src/app.service.ts
+6
-5
src/config.ts
src/config.ts
+0
-4
src/dto/CodeResponse.dto.ts
src/dto/CodeResponse.dto.ts
+4
-1
src/dto/PayExp.dto.ts
src/dto/PayExp.dto.ts
+18
-0
No files found.
src/app.controller.ts
View file @
980c4376
...
@@ -14,6 +14,7 @@ import {
...
@@ -14,6 +14,7 @@ import {
Query
,
Query
,
UploadedFile
,
UploadedFile
,
UseInterceptors
,
UseInterceptors
,
ValidationPipe
,
}
from
'
@nestjs/common
'
;
}
from
'
@nestjs/common
'
;
import
{
AppService
}
from
'
./app.service
'
;
import
{
AppService
}
from
'
./app.service
'
;
import
{
config
}
from
'
./config
'
;
import
{
config
}
from
'
./config
'
;
...
@@ -33,6 +34,7 @@ import {
...
@@ -33,6 +34,7 @@ import {
}
from
'
@nestjs/swagger
'
;
}
from
'
@nestjs/swagger
'
;
import
{
FileUploadDto
}
from
'
./dto/FileUploadDto
'
;
import
{
FileUploadDto
}
from
'
./dto/FileUploadDto
'
;
import
{
HomePageMatchCountDto
}
from
'
./dto/HomePageMatchCount.dto
'
;
import
{
HomePageMatchCountDto
}
from
'
./dto/HomePageMatchCount.dto
'
;
import
{
PayExpDto
}
from
'
./dto/PayExp.dto
'
;
@
Controller
(
'
api
'
)
@
Controller
(
'
api
'
)
@
ApiTags
(
'
arena
'
)
@
ApiTags
(
'
arena
'
)
...
@@ -274,11 +276,20 @@ export class AppController {
...
@@ -274,11 +276,20 @@ export class AppController {
return
this
.
appService
.
getLastMonthBattleCount
();
return
this
.
appService
.
getLastMonthBattleCount
();
}
}
@
Get
(
'
novelai-auth
'
)
@
Get
(
'
pay-exp
'
)
@
ApiOperation
({
summary
:
'
novelai 用认证
'
})
@
ApiOperation
({
summary
:
'
支付 exp
'
})
@
ApiHeader
({
name
:
'
Authorization
'
})
@
ApiHeader
({
name
:
'
Authorization
'
})
@
ApiOkResponse
({
type
:
CodeResponseDto
})
@
ApiOkResponse
({
type
:
CodeResponseDto
})
async
novelaiAuth
(@
Headers
(
'
Authorization
'
)
token
:
string
)
{
async
payExp
(
return
this
.
appService
.
novelaiAuth
(
token
);
@
Headers
(
'
Authorization
'
)
token
:
string
,
@
Query
(
new
ValidationPipe
({
transform
:
true
,
transformOptions
:
{
enableImplicitConversion
:
true
},
}),
)
query
:
PayExpDto
,
)
{
return
this
.
appService
.
payExp
(
token
,
query
);
}
}
}
}
src/app.service.ts
View file @
980c4376
...
@@ -40,6 +40,7 @@ import { AthleticCheckerService } from './athletic-checker/athletic-checker.serv
...
@@ -40,6 +40,7 @@ import { AthleticCheckerService } from './athletic-checker/athletic-checker.serv
import
{
HomePageMatchCountDto
}
from
'
./dto/HomePageMatchCount.dto
'
;
import
{
HomePageMatchCountDto
}
from
'
./dto/HomePageMatchCount.dto
'
;
import
{
AccountService
}
from
'
./account/account.service
'
;
import
{
AccountService
}
from
'
./account/account.service
'
;
import
{
CodeResponseDto
}
from
'
./dto/CodeResponse.dto
'
;
import
{
CodeResponseDto
}
from
'
./dto/CodeResponse.dto
'
;
import
{
PayExpDto
}
from
'
./dto/PayExp.dto
'
;
const
attrOffset
=
1010
;
const
attrOffset
=
1010
;
const
raceOffset
=
1020
;
const
raceOffset
=
1020
;
...
@@ -1781,7 +1782,7 @@ export class AppService {
...
@@ -1781,7 +1782,7 @@ export class AppService {
return
new
HomePageMatchCountDto
(
count
);
return
new
HomePageMatchCountDto
(
count
);
}
}
async
novelaiAuth
(
token
:
string
)
{
async
payExp
(
token
:
string
,
dto
:
PayExpDto
)
{
const
user
=
await
this
.
accountService
.
checkToken
(
token
);
const
user
=
await
this
.
accountService
.
checkToken
(
token
);
if
(
user
.
admin
)
{
if
(
user
.
admin
)
{
return
new
CodeResponseDto
(
200
);
return
new
CodeResponseDto
(
200
);
...
@@ -1793,22 +1794,22 @@ export class AppService {
...
@@ -1793,22 +1794,22 @@ export class AppService {
});
});
if
(
!
userInfo
)
{
if
(
!
userInfo
)
{
this
.
log
.
log
(
this
.
log
.
log
(
`
${
user
.
username
}
has no duel records, cannot use
novelai
.`
,
`
${
user
.
username
}
has no duel records, cannot use
${
dto
.
getName
()}
.`
,
);
);
throw
new
HttpException
(
new
CodeResponseDto
(
402
),
402
);
throw
new
HttpException
(
new
CodeResponseDto
(
402
),
402
);
}
}
if
(
userInfo
.
exp
<
config
.
novelaiC
ost
)
{
if
(
userInfo
.
exp
<
dto
.
c
ost
)
{
this
.
log
.
log
(
this
.
log
.
log
(
`
${
user
.
username
}
has no enough exp to use novelai:
${
userInfo
.
exp
}
`
,
`
${
user
.
username
}
has no enough exp to use novelai:
${
userInfo
.
exp
}
`
,
);
);
throw
new
HttpException
(
new
CodeResponseDto
(
402
),
402
);
throw
new
HttpException
(
new
CodeResponseDto
(
402
),
402
);
}
}
this
.
log
.
log
(
this
.
log
.
log
(
`
${
user
.
username
}
paid
${
config
.
novelaiCost
}
exp to use novelai
.`
,
`
${
user
.
username
}
paid
${
dto
.
cost
}
exp to use
${
dto
.
getName
()}
.`
,
);
);
await
edb
await
edb
.
getRepository
(
UserInfo
)
.
getRepository
(
UserInfo
)
.
decrement
({
username
:
user
.
username
},
'
exp
'
,
config
.
novelaiC
ost
);
.
decrement
({
username
:
user
.
username
},
'
exp
'
,
dto
.
c
ost
);
return
new
CodeResponseDto
(
200
);
return
new
CodeResponseDto
(
200
);
});
});
}
}
...
...
src/config.ts
View file @
980c4376
...
@@ -9,7 +9,6 @@ export interface Config {
...
@@ -9,7 +9,6 @@ export interface Config {
analyzerHost
:
string
;
analyzerHost
:
string
;
enableSchedule
:
boolean
;
enableSchedule
:
boolean
;
accountsUrl
:
string
;
accountsUrl
:
string
;
novelaiCost
:
number
;
}
}
export
const
athleticCheckConfig
=
{
export
const
athleticCheckConfig
=
{
...
@@ -35,7 +34,4 @@ export const config: Config = {
...
@@ -35,7 +34,4 @@ export const config: Config = {
enableSchedule
:
!
process
.
env
.
NO_SCHEDULE
,
enableSchedule
:
!
process
.
env
.
NO_SCHEDULE
,
accountsUrl
:
accountsUrl
:
process
.
env
.
ACCOUNTS_URL
||
'
https://sapi.moecube.com:444/accounts
'
,
process
.
env
.
ACCOUNTS_URL
||
'
https://sapi.moecube.com:444/accounts
'
,
novelaiCost
:
process
.
env
.
NOVELAI_COST
?
parseInt
(
process
.
env
.
NOVELAI_COST
)
:
3
,
};
};
src/dto/CodeResponse.dto.ts
View file @
980c4376
...
@@ -5,8 +5,11 @@ export class CodeResponseDto {
...
@@ -5,8 +5,11 @@ export class CodeResponseDto {
code
:
number
;
code
:
number
;
@
ApiProperty
({
description
:
'
是否成功
'
})
@
ApiProperty
({
description
:
'
是否成功
'
})
success
:
boolean
;
success
:
boolean
;
constructor
(
code
:
number
)
{
@
ApiProperty
({
description
:
'
错误信息
'
})
message
?:
string
;
constructor
(
code
:
number
,
message
?:
string
)
{
this
.
success
=
code
<
400
;
this
.
success
=
code
<
400
;
this
.
code
=
code
;
this
.
code
=
code
;
this
.
message
=
message
;
}
}
}
}
src/dto/PayExp.dto.ts
0 → 100644
View file @
980c4376
import
{
ApiProperty
}
from
"
@nestjs/swagger
"
;
import
{
IsInt
,
IsOptional
,
IsPositive
,
IsString
}
from
"
class-validator
"
;
export
class
PayExpDto
{
@
IsInt
()
@
IsPositive
()
@
ApiProperty
({
description
:
'
支付数量
'
})
cost
:
number
;
@
IsString
()
@
IsOptional
()
@
ApiProperty
({
description
:
'
支付名称
'
})
name
?:
string
;
getName
()
{
return
this
.
name
||
'
service
'
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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