This commit is contained in:
oneao committed 2026-04-17 17:25:15 +08:00
1 parent e893ef2e48
commit b6415c0d65
25 files changed
+1495 -112

No files matched your search

@@ -5,6 +5,7 @@ import (
"allapp-go/internal/httpx"
"allapp-go/internal/types"
"allapp-go/pkg/db"
"allapp-go/pkg/uniqueid"
"github.com/gofiber/fiber/v3"
)
@@ -48,3 +49,22 @@ func LoadDataBySql(c fiber.Ctx) error {
return httpx.OK(c, data)
}
func GetUniqueId(c fiber.Ctx) error {
var req types.GetUniqueIdReq
if err := httpx.BindAndValidate(c, &req); err != nil {
return errors.WithStack(err)
}
count := req.Count
// 预分配,避免扩容
ids := make([]int64, 0, count)
for i := 0; i < count; i++ {
ids = append(ids, uniqueid.NextId())
}
return httpx.OK(c, ids)
}
@@ -21,6 +21,7 @@ func SaveData(c fiber.Ctx) error {
}
ctx := c.Context()
dbClient := db.New()
err := dbClient.WithTx(ctx, func(tx *db.Client) error {