This commit is contained in:
ryan
2026-07-13 15:17:45 +08:00
parent 08e61ce833
commit e0eb4e5975
334 changed files with 17212 additions and 12321 deletions
@@ -4,7 +4,8 @@
package auth_source
import ("bytes"
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
@@ -15,7 +16,8 @@ import ("bytes"
"github.com/Rain-kl/Wavelet/internal/testhelper"
"github.com/gin-gonic/gin"
"github.com/Rain-kl/Wavelet/internal/common/response")
"github.com/Rain-kl/Wavelet/internal/common/response"
)
func setupTestRouter(authUser *model.User) *gin.Engine {
r := testhelper.NewTestGinEngine()
+1 -1
View File
@@ -11,4 +11,4 @@ import (
func saveOrUpdateConfig(ctx context.Context, key, value string) error {
return repository.SaveOrUpdateSystemConfig(ctx, key, value)
}
}
+1 -1
View File
@@ -97,4 +97,4 @@ func ClearCache(c *gin.Context) {
return
}
c.JSON(http.StatusOK, response.OKNil())
}
}
+4 -2
View File
@@ -6,7 +6,8 @@
// overview information, and executing custom SQL queries.
package db_manage
import ("database/sql"
import (
"database/sql"
"fmt"
"math"
"net/http"
@@ -19,7 +20,8 @@ import ("database/sql"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"github.com/Rain-kl/Wavelet/internal/common/response")
"github.com/Rain-kl/Wavelet/internal/common/response"
)
const (
binaryKB = 0
+1 -1
View File
@@ -427,4 +427,4 @@ func GetLogsAnalytics(c *gin.Context) {
Browsers: browserList,
TopUsers: topUsers,
}))
}
}
+4 -4
View File
@@ -49,10 +49,10 @@ func TestWebSocketCheckOrigin(t *testing.T) {
}
tests := []struct {
name string
origin string
host string
wantOK bool
name string
origin string
host string
wantOK bool
}{
{
name: "empty origin (non-browser clients)",
+1 -1
View File
@@ -275,4 +275,4 @@ func renderCustomPayload(template string, req CustomPushRequest) string {
result = strings.ReplaceAll(result, "$url", escapeJSONString(req.URL))
result = strings.ReplaceAll(result, "$to", escapeJSONString(req.To))
return result
}
}
@@ -35,4 +35,4 @@ func handleAdminLogin(ctx context.Context, event listener.AdminLoggedIn) {
"time": time.Now().Format("2006-01-02 15:04:05"),
}
push.DefaultTrigger.Trigger(ctx, AdminLogin, body)
}
}
@@ -14,4 +14,4 @@ import (
func Register() {
push.RegisterBuiltInEvent(AdminLogin)
listener.OnAdminLoggedIn(handleAdminLogin)
}
}
+2 -1
View File
@@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"strings"
"github.com/Rain-kl/Wavelet/internal/model"
"github.com/Rain-kl/Wavelet/internal/repository"
"github.com/Rain-kl/Wavelet/internal/task"
@@ -339,4 +340,4 @@ func resolveDynamicKeyword(target string, flatBody map[string]any) string {
}
}
return target
}
}
+1 -1
View File
@@ -410,4 +410,4 @@ func getEventInfo(req CreateEventRequest) (string, string, []byte, error) {
return "", "", nil, err
}
return req.EventKey, meta.Name, defaultTemplateBytes, nil
}
}
+1 -1
View File
@@ -289,4 +289,4 @@ func TestPush(c *gin.Context) {
return
}
c.JSON(http.StatusOK, response.OKNil())
}
}
+1 -1
View File
@@ -121,4 +121,4 @@ func extractUsername(data map[string]any) string {
}
}
return ""
}
}
+4 -2
View File
@@ -5,7 +5,8 @@
// Package status 提供系统状态查询接口
package status
import ("context"
import (
"context"
"fmt"
"log"
"math"
@@ -19,7 +20,8 @@ import ("context"
"github.com/Rain-kl/Wavelet/internal/db"
"github.com/gin-gonic/gin"
"github.com/Rain-kl/Wavelet/internal/common/response")
"github.com/Rain-kl/Wavelet/internal/common/response"
)
// startTime 记录服务启动时间
var startTime = time.Now()
+4 -4
View File
@@ -7,9 +7,9 @@ package system_config
// 系统配置错误消息常量
const (
SystemConfigNotFound = "系统配置不存在"
ConfigKeyRequired = "配置键不能为空"
ConfigValueRequired = "配置值不能为空"
ConfigKeyExists = "配置键已存在"
SystemConfigNotFound = "系统配置不存在"
ConfigKeyRequired = "配置键不能为空"
ConfigValueRequired = "配置值不能为空"
ConfigKeyExists = "配置键已存在"
StorageDriverSwitchRequiresMigration = "存在存量文件,请通过存储迁移任务切换存储引擎"
)
+1 -1
View File
@@ -125,4 +125,4 @@ func resolveStorageMigrationTasksOnDirectDriverUpdate(
}).Error; err != nil {
logger.ErrorF(ctx, "自动更新迁移任务状态失败: %v", err)
}
}
}
+4 -2
View File
@@ -4,7 +4,8 @@
package task
import ("fmt"
import (
"fmt"
"net/http"
"strconv"
"strings"
@@ -18,7 +19,8 @@ import ("fmt"
"github.com/gin-gonic/gin"
"github.com/robfig/cron/v3"
"github.com/Rain-kl/Wavelet/internal/common/response")
"github.com/Rain-kl/Wavelet/internal/common/response"
)
// ListTaskTypes 获取支持的任务类型列表
// @Summary 获取支持的任务类型
+4 -2
View File
@@ -4,7 +4,8 @@
package task
import ("bytes"
import (
"bytes"
"context"
"encoding/json"
"fmt"
@@ -25,7 +26,8 @@ import ("bytes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/Rain-kl/Wavelet/internal/common/response")
"github.com/Rain-kl/Wavelet/internal/common/response"
)
func setupTaskTestEnvironment(t *testing.T) func() {
_, mr, cleanup := testhelper.SetupTestEnvironment(t)
+1 -1
View File
@@ -75,4 +75,4 @@ func deleteTemplate(ctx context.Context, key string) error {
return errors.New(SystemTemplateCannotDelete)
}
return repository.DeleteTemplate(ctx, &tmpl)
}
}
+1 -1
View File
@@ -173,4 +173,4 @@ func DeleteTemplate(c *gin.Context) {
}
c.JSON(http.StatusOK, response.OKNil())
}
}
+4 -2
View File
@@ -3,7 +3,8 @@
package template
import ("bytes"
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
@@ -14,7 +15,8 @@ import ("bytes"
"github.com/Rain-kl/Wavelet/internal/testhelper"
"github.com/gin-gonic/gin"
"github.com/Rain-kl/Wavelet/internal/common/response")
"github.com/Rain-kl/Wavelet/internal/common/response"
)
func setupTestRouter(authUser *model.User) *gin.Engine {
r := testhelper.NewTestGinEngine()
+4 -2
View File
@@ -3,14 +3,16 @@
package updater
import ("context"
import (
"context"
"net/http"
"time"
"github.com/Rain-kl/Wavelet/pkg/logger"
"github.com/gin-gonic/gin"
"github.com/Rain-kl/Wavelet/internal/common/response")
"github.com/Rain-kl/Wavelet/internal/common/response"
)
// GetUpdateStatus 获取应用更新状态
// @Summary 获取应用更新状态
+9 -9
View File
@@ -6,15 +6,15 @@
package user
const (
userNotFound = "用户不存在"
cannotDisable = "不能禁用管理员用户"
cannotDelete = "不能删除管理员用户"
cannotDeleteSelf = "不能删除当前登录用户"
updateUserFailed = "更新用户状态失败"
deleteUserFailed = "删除用户失败"
usernameExists = "用户名已存在"
usernameRequired = "用户名不能为空"
passwordTooShort = "密码长度不能少于 8 位" //nolint:gosec // false positive: this is an error message, not hardcoded credentials
userNotFound = "用户不存在"
cannotDisable = "不能禁用管理员用户"
cannotDelete = "不能删除管理员用户"
cannotDeleteSelf = "不能删除当前登录用户"
updateUserFailed = "更新用户状态失败"
deleteUserFailed = "删除用户失败"
usernameExists = "用户名已存在"
usernameRequired = "用户名不能为空"
passwordTooShort = "密码长度不能少于 8 位" //nolint:gosec // false positive: this is an error message, not hardcoded credentials
createUserFailed = "创建用户失败"
emailRequired = "邮箱不能为空"
emailExists = "邮箱已被注册"