Commit 0084da9c authored by shaw's avatar shaw
Browse files

fix: 修复 NewSettingHandler 参数不足导致的编译错误

- 测试文件添加第三个参数 userService(nil)
- Handler 添加 userService 空指针检查,防止测试环境 panic
parent 31d4c1d2
......@@ -150,7 +150,7 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
}
// 如果切换到简单模式,自动将管理员并发数设为 99999
if req.SimpleMode {
if req.SimpleMode && h.userService != nil {
admin, err := h.userService.GetFirstAdmin(c.Request.Context())
if err == nil && admin != nil {
_ = h.userService.UpdateConcurrency(c.Request.Context(), admin.ID, 99999)
......
......@@ -383,7 +383,7 @@ func newContractDeps(t *testing.T) *contractDeps {
authHandler := handler.NewAuthHandler(nil, userService)
apiKeyHandler := handler.NewAPIKeyHandler(apiKeyService)
usageHandler := handler.NewUsageHandler(usageService, apiKeyService)
adminSettingHandler := adminhandler.NewSettingHandler(settingService, nil)
adminSettingHandler := adminhandler.NewSettingHandler(settingService, nil, nil)
jwtAuth := func(c *gin.Context) {
c.Set(string(middleware.ContextKeyUser), middleware.AuthSubject{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment