fix: 更新数据库表名引用及配置

This commit is contained in:
2026-03-27 11:10:11 +08:00
parent b9ed1b2492
commit 70b8cf0316
12 changed files with 141 additions and 192 deletions

View File

@@ -154,14 +154,14 @@ func (d *location) DeleteByWarehouseId(ctx context.Context, warehouseId string)
// CountStockDetailsByLocationId 统计库位上的库存明细数量(用于删除前检查)
func (d *location) CountStockDetailsByLocationId(ctx context.Context, locationId string) (count int64, err error) {
filter := bson.M{"locationId": locationId}
count, err = mongo.DB().Count(ctx, filter, public.StockDetailsCollection)
count, err = mongo.DB().Count(ctx, filter, public.TableNameStockDetails)
return
}
// CountStockBatchByLocationId 统计库位上的批次库存数量(用于删除前检查)
func (d *location) CountStockBatchByLocationId(ctx context.Context, locationId string) (count int64, err error) {
filter := bson.M{"locationId": locationId}
count, err = mongo.DB().Count(ctx, filter, public.StockBatchCollection)
count, err = mongo.DB().Count(ctx, filter, public.TableNameStockBatch)
return
}

View File

@@ -27,7 +27,7 @@ func (d *stockBatch) Insert(ctx context.Context, req *dto.CreateSockBatchReq) (i
if err = gconv.Struct(req, &res); err != nil {
return
}
r, err := gfdb.DB(ctx).Model(ctx, public.StockBatchCollection).Data(&res).Insert()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameStockBatch).Data(&res).Insert()
if err != nil {
return
}
@@ -35,7 +35,7 @@ func (d *stockBatch) Insert(ctx context.Context, req *dto.CreateSockBatchReq) (i
}
func (d *stockBatch) Update(ctx context.Context, req *dto.UpdateSockBatchReq) (rows int64, err error) {
model := gfdb.DB(ctx).Model(ctx, public.StockBatchCollection).OmitEmpty().Where(entity.StockBatchCol.Id, req.Id)
model := gfdb.DB(ctx).Model(ctx, public.TableNameStockBatch).OmitEmpty().Where(entity.StockBatchCol.Id, req.Id)
model.Data(entity.StockBatchCol.BatchQty, &gdb.Counter{
Field: entity.StockBatchCol.BatchQty,
Value: gconv.Float64(req.BatchQty),
@@ -53,7 +53,7 @@ func (d *stockBatch) Update(ctx context.Context, req *dto.UpdateSockBatchReq) (r
// One 根据批次号查询使用NoCache跳过缓存确保获取最新数据
func (d *stockBatch) One(ctx context.Context, req *dto.GetSockBatchReq, fields ...string) (res *entity.StockBatch, err error) {
model := gfdb.DB(ctx).Model(ctx, public.StockBatchCollection)
model := gfdb.DB(ctx).Model(ctx, public.TableNameStockBatch)
if !g.IsEmpty(req.Id) {
model.Where(entity.StockBatchCol.Id, req.Id)
}

View File

@@ -26,7 +26,7 @@ func (d *stockDetails) BatchInsert(ctx context.Context, req []*dto.CreateSockDet
if err = gconv.Structs(req, &res); err != nil {
return
}
r, err := gfdb.DB(ctx).Model(ctx, public.StockDetailsCollection).Data(res).Save()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameStockDetails).Data(res).Save()
if err != nil {
return
}
@@ -34,7 +34,7 @@ func (d *stockDetails) BatchInsert(ctx context.Context, req []*dto.CreateSockDet
}
func (d *stockDetails) Delete(ctx context.Context, req []dto.DeleteSockDetailsReq) (rows int64, err error) {
r, err := gfdb.DB(ctx).Model(ctx, public.StockDetailsCollection).Where(entity.StockDetailsCol.Id, &req).Delete()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameStockDetails).Where(entity.StockDetailsCol.Id, &req).Delete()
if err != nil {
return
}
@@ -62,7 +62,7 @@ func (d *stockDetails) List(ctx context.Context, req *dto.GetSockDetailsReq, fie
// buildListFilter 构建列表查询的过滤条件
func (d *stockDetails) buildListFilter(ctx context.Context, req *dto.GetSockDetailsReq) *gdb.Model {
model := gfdb.DB(ctx).Model(ctx, public.StockDetailsCollection).Model
model := gfdb.DB(ctx).Model(ctx, public.TableNameStockDetails).Model
model.Where(entity.StockDetailsCol.Id, req.Id)
model.Where(entity.StockDetailsCol.AssetId, req.AssetId)
model.Where(entity.StockDetailsCol.AssetSkuId, req.AssetSkuId)