u
This commit is contained in:
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 {
|
||||
|
||||
Reference in new issue
Block a user