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
57edbac3
authored
Sep 10, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 删除无用功能
parent
e8895c92
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
95 deletions
+0
-95
controller/user.go
+0
-56
model/user.go
+0
-6
router/api-router.go
+0
-1
web/src/components/OperationSetting.js
+0
-32
No files found.
controller/user.go
View file @
57edbac3
...
@@ -3,7 +3,6 @@ package controller
...
@@ -3,7 +3,6 @@ package controller
import
(
import
(
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"log"
"net/http"
"net/http"
"one-api/common"
"one-api/common"
"one-api/model"
"one-api/model"
...
@@ -80,8 +79,6 @@ func setupLogin(user *model.User, c *gin.Context) {
...
@@ -80,8 +79,6 @@ func setupLogin(user *model.User, c *gin.Context) {
DisplayName
:
user
.
DisplayName
,
DisplayName
:
user
.
DisplayName
,
Role
:
user
.
Role
,
Role
:
user
.
Role
,
Status
:
user
.
Status
,
Status
:
user
.
Status
,
StableMode
:
user
.
StableMode
,
MaxPrice
:
user
.
MaxPrice
,
}
}
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"message"
:
""
,
"message"
:
""
,
...
@@ -161,8 +158,6 @@ func Register(c *gin.Context) {
...
@@ -161,8 +158,6 @@ func Register(c *gin.Context) {
Password
:
user
.
Password
,
Password
:
user
.
Password
,
DisplayName
:
user
.
Username
,
DisplayName
:
user
.
Username
,
InviterId
:
inviterId
,
InviterId
:
inviterId
,
StableMode
:
user
.
StableMode
,
MaxPrice
:
user
.
MaxPrice
,
}
}
if
common
.
EmailVerificationEnabled
{
if
common
.
EmailVerificationEnabled
{
cleanUser
.
Email
=
user
.
Email
cleanUser
.
Email
=
user
.
Email
...
@@ -425,8 +420,6 @@ func UpdateSelf(c *gin.Context) {
...
@@ -425,8 +420,6 @@ func UpdateSelf(c *gin.Context) {
Username
:
user
.
Username
,
Username
:
user
.
Username
,
Password
:
user
.
Password
,
Password
:
user
.
Password
,
DisplayName
:
user
.
DisplayName
,
DisplayName
:
user
.
DisplayName
,
StableMode
:
user
.
StableMode
,
MaxPrice
:
user
.
MaxPrice
,
}
}
if
user
.
Password
==
"$I_LOVE_U"
{
if
user
.
Password
==
"$I_LOVE_U"
{
user
.
Password
=
""
// rollback to what it should be
user
.
Password
=
""
// rollback to what it should be
...
@@ -748,52 +741,3 @@ func TopUp(c *gin.Context) {
...
@@ -748,52 +741,3 @@ func TopUp(c *gin.Context) {
})
})
return
return
}
}
type
StableModeRequest
struct
{
StableMode
bool
`json:"stableMode"`
MaxPrice
string
`json:"maxPrice"`
}
func
SetTableMode
(
c
*
gin
.
Context
)
{
req
:=
&
StableModeRequest
{}
err
:=
c
.
ShouldBindJSON
(
&
req
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"message"
:
err
.
Error
(),
})
return
}
log
.
Println
(
req
)
id
:=
c
.
GetInt
(
"id"
)
user
:=
model
.
User
{
Id
:
id
,
}
err
=
user
.
FillUserById
()
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"message"
:
err
.
Error
(),
})
return
}
user
.
StableMode
=
req
.
StableMode
if
!
req
.
StableMode
{
req
.
MaxPrice
=
"0"
}
user
.
MaxPrice
=
req
.
MaxPrice
err
=
user
.
Update
(
false
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"message"
:
err
.
Error
(),
})
return
}
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
true
,
"message"
:
""
,
"data"
:
"设置成功"
,
})
return
}
model/user.go
View file @
57edbac3
...
@@ -28,8 +28,6 @@ type User struct {
...
@@ -28,8 +28,6 @@ type User struct {
Group
string
`json:"group" gorm:"type:varchar(32);default:'default'"`
Group
string
`json:"group" gorm:"type:varchar(32);default:'default'"`
AffCode
string
`json:"aff_code" gorm:"type:varchar(32);column:aff_code;uniqueIndex"`
AffCode
string
`json:"aff_code" gorm:"type:varchar(32);column:aff_code;uniqueIndex"`
InviterId
int
`json:"inviter_id" gorm:"type:int;column:inviter_id;index"`
InviterId
int
`json:"inviter_id" gorm:"type:int;column:inviter_id;index"`
StableMode
bool
`json:"stable_mode" gorm:"type:tinyint;default:0;column:stable_mode"`
MaxPrice
string
`json:"max_price" gorm:"type:varchar(32);default:'7'"`
}
}
func
GetMaxUserId
()
int
{
func
GetMaxUserId
()
int
{
...
@@ -119,10 +117,6 @@ func (user *User) Update(updatePassword bool) error {
...
@@ -119,10 +117,6 @@ func (user *User) Update(updatePassword bool) error {
}
}
}
}
newUser
:=
*
user
newUser
:=
*
user
err
=
DB
.
Model
(
user
)
.
UpdateColumns
(
map
[
string
]
interface
{}{
"stable_mode"
:
user
.
StableMode
,
"max_price"
:
user
.
MaxPrice
,
})
.
Error
DB
.
First
(
&
user
,
user
.
Id
)
DB
.
First
(
&
user
,
user
.
Id
)
err
=
DB
.
Model
(
user
)
.
Updates
(
newUser
)
.
Error
err
=
DB
.
Model
(
user
)
.
Updates
(
newUser
)
.
Error
...
...
router/api-router.go
View file @
57edbac3
...
@@ -45,7 +45,6 @@ func SetApiRouter(router *gin.Engine) {
...
@@ -45,7 +45,6 @@ func SetApiRouter(router *gin.Engine) {
selfRoute
.
POST
(
"/topup"
,
controller
.
TopUp
)
selfRoute
.
POST
(
"/topup"
,
controller
.
TopUp
)
selfRoute
.
POST
(
"/pay"
,
controller
.
RequestEpay
)
selfRoute
.
POST
(
"/pay"
,
controller
.
RequestEpay
)
selfRoute
.
POST
(
"/amount"
,
controller
.
RequestAmount
)
selfRoute
.
POST
(
"/amount"
,
controller
.
RequestAmount
)
selfRoute
.
POST
(
"/set_stable_mode"
,
controller
.
SetTableMode
)
}
}
adminRoute
:=
userRoute
.
Group
(
"/"
)
adminRoute
:=
userRoute
.
Group
(
"/"
)
...
...
web/src/components/OperationSetting.js
View file @
57edbac3
...
@@ -21,9 +21,6 @@ const OperationSetting = () => {
...
@@ -21,9 +21,6 @@ const OperationSetting = () => {
DisplayTokenStatEnabled
:
''
,
DisplayTokenStatEnabled
:
''
,
ApproximateTokenEnabled
:
''
,
ApproximateTokenEnabled
:
''
,
RetryTimes
:
0
,
RetryTimes
:
0
,
StablePrice
:
6
,
NormalPrice
:
1.5
,
BasePrice
:
1.5
,
});
});
const
[
originInputs
,
setOriginInputs
]
=
useState
({});
const
[
originInputs
,
setOriginInputs
]
=
useState
({});
let
[
loading
,
setLoading
]
=
useState
(
false
);
let
[
loading
,
setLoading
]
=
useState
(
false
);
...
@@ -257,35 +254,6 @@ const OperationSetting = () => {
...
@@ -257,35 +254,6 @@ const OperationSetting = () => {
}}
>
保存监控设置
<
/Form.Button
>
}}
>
保存监控设置
<
/Form.Button
>
<
Divider
/>
<
Divider
/>
<
Header
as
=
'h3'
>
<
Header
as
=
'h3'
>
通道设置
<
/Header
>
<
Form
.
Group
widths
=
{
3
}
>
<
Form
.
Input
label
=
'普通渠道价格'
name
=
'NormalPrice'
onChange
=
{
handleInputChange
}
autoComplete
=
'new-password'
value
=
{
inputs
.
NormalPrice
}
type
=
'number'
// min='1.5'
placeholder
=
'n元/刀'
/>
<
Form
.
Input
label
=
'稳定渠道价格'
name
=
'StablePrice'
onChange
=
{
handleInputChange
}
autoComplete
=
'new-password'
value
=
{
inputs
.
StablePrice
}
type
=
'number'
// min='1.5'
placeholder
=
'n元/刀'
/>
<
/Form.Group
>
<
Form
.
Button
onClick
=
{()
=>
{
submitConfig
(
'stable'
).
then
();
}}
>
保存通道设置
<
/Form.Button
>
<
Divider
/>
<
Header
as
=
'h3'
>
额度设置
额度设置
<
/Header
>
<
/Header
>
<
Form
.
Group
widths
=
{
4
}
>
<
Form
.
Group
widths
=
{
4
}
>
...
...
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