Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cfd220cf
authored
Jul 15, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: make subscription api compatible with official api
parent
8e601e11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
controller/billing.go
+7
-3
No files found.
controller/billing.go
View file @
cfd220cf
...
@@ -7,16 +7,19 @@ import (
...
@@ -7,16 +7,19 @@ import (
)
)
func
GetSubscription
(
c
*
gin
.
Context
)
{
func
GetSubscription
(
c
*
gin
.
Context
)
{
var
quota
int
var
remainQuota
int
var
usedQuota
int
var
err
error
var
err
error
var
token
*
model
.
Token
var
token
*
model
.
Token
if
common
.
DisplayTokenStatEnabled
{
if
common
.
DisplayTokenStatEnabled
{
tokenId
:=
c
.
GetInt
(
"token_id"
)
tokenId
:=
c
.
GetInt
(
"token_id"
)
token
,
err
=
model
.
GetTokenById
(
tokenId
)
token
,
err
=
model
.
GetTokenById
(
tokenId
)
quota
=
token
.
RemainQuota
remainQuota
=
token
.
RemainQuota
usedQuota
=
token
.
UsedQuota
}
else
{
}
else
{
userId
:=
c
.
GetInt
(
"id"
)
userId
:=
c
.
GetInt
(
"id"
)
quota
,
err
=
model
.
GetUserQuota
(
userId
)
remainQuota
,
err
=
model
.
GetUserQuota
(
userId
)
usedQuota
,
err
=
model
.
GetUserUsedQuota
(
userId
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
openAIError
:=
OpenAIError
{
openAIError
:=
OpenAIError
{
...
@@ -28,6 +31,7 @@ func GetSubscription(c *gin.Context) {
...
@@ -28,6 +31,7 @@ func GetSubscription(c *gin.Context) {
})
})
return
return
}
}
quota
:=
remainQuota
+
usedQuota
amount
:=
float64
(
quota
)
amount
:=
float64
(
quota
)
if
common
.
DisplayInCurrencyEnabled
{
if
common
.
DisplayInCurrencyEnabled
{
amount
/=
common
.
QuotaPerUnit
amount
/=
common
.
QuotaPerUnit
...
...
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