mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-12 12:13:46 +08:00
refactor: add system config key 'user_init_calls' to init the new register user's api calls
This commit is contained in:
@@ -85,6 +85,16 @@ func (h *UserHandler) Register(c *gin.Context) {
|
||||
ApiKey: "",
|
||||
}),
|
||||
}
|
||||
// 初始化调用次数
|
||||
var cfg model.Config
|
||||
h.db.Where("marker = ?", "system").First(&cfg)
|
||||
var config types.SystemConfig
|
||||
err := utils.JsonDecode(cfg.Config, &config)
|
||||
if err != nil || config.UserInitCalls <= 0 {
|
||||
user.Calls = types.UserInitCalls
|
||||
} else {
|
||||
user.Calls = config.UserInitCalls
|
||||
}
|
||||
res := h.db.Create(&user)
|
||||
if res.Error != nil {
|
||||
resp.ERROR(c, "保存数据失败")
|
||||
|
||||
Reference in New Issue
Block a user