refactor: 将分布式锁从 redis 迁移至 utils 包

This commit is contained in:
2026-03-27 09:49:44 +08:00
parent 018d60469a
commit b9ed1b2492
4 changed files with 7 additions and 8 deletions

View File

@@ -17,7 +17,6 @@ import (
"fmt"
"gitea.com/red-future/common/beans"
"gitea.com/red-future/common/redis"
"gitea.com/red-future/common/utils"
gmq "github.com/bjang03/gmq/core/gmq"
"github.com/bjang03/gmq/mq"
@@ -188,7 +187,7 @@ func (s *stockManage) AddStock(ctx context.Context, msg any) error {
ctx = context.WithValue(ctx, "tenantId", req.TenantId)
// 获取redis-租户存储-锁key
fileLockKey := fmt.Sprintf(public.StockDetailLockKey, req.AssetSkuId)
success, err := redis.Lock(ctx, fileLockKey, int64(60), func(ctx context.Context) error {
success, err := utils.Lock(ctx, fileLockKey, int64(60), func(ctx context.Context) error {
if req.OperationType == "add" {
if req.StockMode == stock.StockModeBatch {
if !g.IsEmpty(req.StockId) {