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

@@ -23,7 +23,7 @@ func (d *assetSku) Insert(ctx context.Context, req *dto.CreateAssetSkuReq) (id i
if err = gconv.Struct(req, &res); err != nil {
return
}
r, err := gfdb.DB(ctx).Model(ctx, public.AssetSkuCollection).Data(&res).Insert()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAssetSku).Data(&res).Insert()
if err != nil {
return
}
@@ -32,7 +32,7 @@ func (d *assetSku) Insert(ctx context.Context, req *dto.CreateAssetSkuReq) (id i
// Update 更新SKU
func (d *assetSku) Update(ctx context.Context, req *dto.UpdateAssetSkuReq) (rows int64, err error) {
r, err := gfdb.DB(ctx).Model(ctx, public.AssetSkuCollection).Data(&req).OmitEmpty().Where(entity.AssetCol.Id, req.Id).Update()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAssetSku).Data(&req).OmitEmpty().Where(entity.AssetCol.Id, req.Id).Update()
if err != nil {
return
}
@@ -41,7 +41,7 @@ func (d *assetSku) Update(ctx context.Context, req *dto.UpdateAssetSkuReq) (rows
// Delete 删除SKU-根据id进行假删
func (d *assetSku) Delete(ctx context.Context, req *dto.DeleteAssetSkuReq) (rows int64, err error) {
r, err := gfdb.DB(ctx).Model(ctx, public.AssetSkuCollection).Where(entity.AssetSkuCol.Id, req.Id).Delete()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAssetSku).Where(entity.AssetSkuCol.Id, req.Id).Delete()
if err != nil {
return
}
@@ -50,7 +50,7 @@ func (d *assetSku) Delete(ctx context.Context, req *dto.DeleteAssetSkuReq) (rows
// GetOne 获取单个SKU
func (d *assetSku) GetOne(ctx context.Context, req *dto.GetAssetSkuReq, fields ...string) (res *entity.AssetSku, err error) {
r, err := gfdb.DB(ctx).Model(ctx, public.AssetSkuCollection).Where(entity.AssetCol.Id, req.Id).Fields(fields).One()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAssetSku).Where(entity.AssetCol.Id, req.Id).Fields(fields).One()
if err != nil {
return
}
@@ -60,7 +60,7 @@ func (d *assetSku) GetOne(ctx context.Context, req *dto.GetAssetSkuReq, fields .
// GetListByAssetIdExcludeCurrentSku 根据资产ID获取SKU列表并且排除当前SKU
func (d *assetSku) GetListByAssetIdExcludeCurrentSku(ctx context.Context, assetId int64, req *dto.ListAssetSkuReq, fields ...string) (res []entity.AssetSku, total int, err error) {
model := gfdb.DB(ctx).Model(ctx, public.AssetSkuCollection)
model := gfdb.DB(ctx).Model(ctx, public.TableNameAssetSku)
model.Fields(fields)
model.Where(entity.AssetSkuCol.AssetId, assetId)
model.WhereNot(entity.AssetSkuCol.Id, req.Id)
@@ -94,7 +94,7 @@ func (d *assetSku) List(ctx context.Context, req *dto.ListAssetSkuReq, fields ..
// buildListFilter 构建列表查询的过滤条件
func (d *assetSku) buildListFilter(ctx context.Context, req *dto.ListAssetSkuReq) *gdb.Model {
model := gfdb.DB(ctx).Model(ctx, public.AssetSkuCollection).Model
model := gfdb.DB(ctx).Model(ctx, public.TableNameAssetSku).Cache(ctx)
if !g.IsEmpty(req.Keyword) {
model.WhereLike(entity.AssetCol.Name, "%"+req.Keyword+"%")
model.WhereOrLike(entity.AssetSkuCol.SkuName, "%"+req.Keyword+"%")