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
8a7f5970
authored
May 21, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: able to manage user's quota now
parent
64b4553a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
model/user.go
+0
-1
web/src/pages/User/EditUser.js
+22
-2
No files found.
model/user.go
View file @
8a7f5970
...
@@ -20,7 +20,6 @@ type User struct {
...
@@ -20,7 +20,6 @@ type User struct {
GitHubId
string
`json:"github_id" gorm:"column:github_id;index"`
GitHubId
string
`json:"github_id" gorm:"column:github_id;index"`
WeChatId
string
`json:"wechat_id" gorm:"column:wechat_id;index"`
WeChatId
string
`json:"wechat_id" gorm:"column:wechat_id;index"`
VerificationCode
string
`json:"verification_code" gorm:"-:all"`
// this field is only for Email verification, don't save it to database!
VerificationCode
string
`json:"verification_code" gorm:"-:all"`
// this field is only for Email verification, don't save it to database!
Balance
int
`json:"balance" gorm:"type:int;default:0"`
AccessToken
string
`json:"access_token" gorm:"type:char(32);column:access_token;uniqueIndex"`
// this token is for system management
AccessToken
string
`json:"access_token" gorm:"type:char(32);column:access_token;uniqueIndex"`
// this token is for system management
Quota
int
`json:"quota" gorm:"type:int;default:0"`
Quota
int
`json:"quota" gorm:"type:int;default:0"`
}
}
...
...
web/src/pages/User/EditUser.js
View file @
8a7f5970
...
@@ -14,8 +14,9 @@ const EditUser = () => {
...
@@ -14,8 +14,9 @@ const EditUser = () => {
github_id
:
''
,
github_id
:
''
,
wechat_id
:
''
,
wechat_id
:
''
,
email
:
''
,
email
:
''
,
quota
:
0
,
});
});
const
{
username
,
display_name
,
password
,
github_id
,
wechat_id
,
email
}
=
const
{
username
,
display_name
,
password
,
github_id
,
wechat_id
,
email
,
quota
}
=
inputs
;
inputs
;
const
handleInputChange
=
(
e
,
{
name
,
value
})
=>
{
const
handleInputChange
=
(
e
,
{
name
,
value
})
=>
{
setInputs
((
inputs
)
=>
({
...
inputs
,
[
name
]:
value
}));
setInputs
((
inputs
)
=>
({
...
inputs
,
[
name
]:
value
}));
...
@@ -44,7 +45,11 @@ const EditUser = () => {
...
@@ -44,7 +45,11 @@ const EditUser = () => {
const
submit
=
async
()
=>
{
const
submit
=
async
()
=>
{
let
res
=
undefined
;
let
res
=
undefined
;
if
(
userId
)
{
if
(
userId
)
{
res
=
await
API
.
put
(
`/api/user/`
,
{
...
inputs
,
id
:
parseInt
(
userId
)
});
let
data
=
{
...
inputs
,
id
:
parseInt
(
userId
)
};
if
(
typeof
data
.
quota
===
'string'
)
{
data
.
quota
=
parseInt
(
data
.
quota
);
}
res
=
await
API
.
put
(
`/api/user/`
,
data
);
}
else
{
}
else
{
res
=
await
API
.
put
(
`/api/user/self`
,
inputs
);
res
=
await
API
.
put
(
`/api/user/self`
,
inputs
);
}
}
...
@@ -92,6 +97,21 @@ const EditUser = () => {
...
@@ -92,6 +97,21 @@ const EditUser = () => {
autoComplete
=
'new-password'
autoComplete
=
'new-password'
/>
/>
<
/Form.Field
>
<
/Form.Field
>
{
userId
&&
(
<
Form
.
Field
>
<
Form
.
Input
label
=
'剩余额度'
name
=
'quota'
placeholder
=
{
'请输入新的剩余额度'
}
onChange
=
{
handleInputChange
}
value
=
{
quota
}
type
=
{
'number'
}
autoComplete
=
'new-password'
/>
<
/Form.Field
>
)
}
<
Form
.
Field
>
<
Form
.
Field
>
<
Form
.
Input
<
Form
.
Input
label
=
'已绑定的 GitHub 账户'
label
=
'已绑定的 GitHub 账户'
...
...
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