From 4a836a4cb69e7321eb331b59a4218b983e49ffd2 Mon Sep 17 00:00:00 2001
From: CaIon <1808837298@qq.com>
Date: Sun, 10 Sep 2023 01:13:12 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
controller/user.go | 56 --------------------------
model/user.go | 6 ---
router/api-router.go | 1 -
web/src/components/OperationSetting.js | 32 ---------------
4 files changed, 95 deletions(-)
diff --git a/controller/user.go b/controller/user.go
index a072b54e..8fd10b82 100644
--- a/controller/user.go
+++ b/controller/user.go
@@ -3,7 +3,6 @@ package controller
import (
"encoding/json"
"fmt"
- "log"
"net/http"
"one-api/common"
"one-api/model"
@@ -80,8 +79,6 @@ func setupLogin(user *model.User, c *gin.Context) {
DisplayName: user.DisplayName,
Role: user.Role,
Status: user.Status,
- StableMode: user.StableMode,
- MaxPrice: user.MaxPrice,
}
c.JSON(http.StatusOK, gin.H{
"message": "",
@@ -161,8 +158,6 @@ func Register(c *gin.Context) {
Password: user.Password,
DisplayName: user.Username,
InviterId: inviterId,
- StableMode: user.StableMode,
- MaxPrice: user.MaxPrice,
}
if common.EmailVerificationEnabled {
cleanUser.Email = user.Email
@@ -425,8 +420,6 @@ func UpdateSelf(c *gin.Context) {
Username: user.Username,
Password: user.Password,
DisplayName: user.DisplayName,
- StableMode: user.StableMode,
- MaxPrice: user.MaxPrice,
}
if user.Password == "$I_LOVE_U" {
user.Password = "" // rollback to what it should be
@@ -748,52 +741,3 @@ func TopUp(c *gin.Context) {
})
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
-}
diff --git a/model/user.go b/model/user.go
index fa53c287..0e12f077 100644
--- a/model/user.go
+++ b/model/user.go
@@ -28,8 +28,6 @@ type User struct {
Group string `json:"group" gorm:"type:varchar(32);default:'default'"`
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"`
- 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 {
@@ -119,10 +117,6 @@ func (user *User) Update(updatePassword bool) error {
}
}
newUser := *user
- err = DB.Model(user).UpdateColumns(map[string]interface{}{
- "stable_mode": user.StableMode,
- "max_price": user.MaxPrice,
- }).Error
DB.First(&user, user.Id)
err = DB.Model(user).Updates(newUser).Error
diff --git a/router/api-router.go b/router/api-router.go
index dd883358..13fb0684 100644
--- a/router/api-router.go
+++ b/router/api-router.go
@@ -45,7 +45,6 @@ func SetApiRouter(router *gin.Engine) {
selfRoute.POST("/topup", controller.TopUp)
selfRoute.POST("/pay", controller.RequestEpay)
selfRoute.POST("/amount", controller.RequestAmount)
- selfRoute.POST("/set_stable_mode", controller.SetTableMode)
}
adminRoute := userRoute.Group("/")
diff --git a/web/src/components/OperationSetting.js b/web/src/components/OperationSetting.js
index 4822f69e..92a99039 100644
--- a/web/src/components/OperationSetting.js
+++ b/web/src/components/OperationSetting.js
@@ -21,9 +21,6 @@ const OperationSetting = () => {
DisplayTokenStatEnabled: '',
ApproximateTokenEnabled: '',
RetryTimes: 0,
- StablePrice: 6,
- NormalPrice: 1.5,
- BasePrice: 1.5,
});
const [originInputs, setOriginInputs] = useState({});
let [loading, setLoading] = useState(false);
@@ -256,35 +253,6 @@ const OperationSetting = () => {
submitConfig('monitor').then();
}}>保存监控设置