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 *assetDao) Insert(ctx context.Context, req *dto.CreateAssetReq) (id int6
if err = gconv.Struct(req, &res); err != nil {
return
}
r, err := gfdb.DB(ctx).Model(ctx, public.AssetCollection).Data(&res).Insert()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAsset).Data(&res).Insert()
if err != nil {
return
}
@@ -32,7 +32,7 @@ func (d *assetDao) Insert(ctx context.Context, req *dto.CreateAssetReq) (id int6
// Update 更新资产
func (d *assetDao) Update(ctx context.Context, req *dto.UpdateAssetReq) (rows int64, err error) {
r, err := gfdb.DB(ctx).Model(ctx, public.AssetCollection).Data(&req).OmitEmpty().Where(entity.AssetCol.Id, req.Id).Update()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAsset).Data(&req).OmitEmpty().Where(entity.AssetCol.Id, req.Id).Update()
if err != nil {
return
}
@@ -41,7 +41,7 @@ func (d *assetDao) Update(ctx context.Context, req *dto.UpdateAssetReq) (rows in
// Delete 删除资产-根据id进行假删
func (d *assetDao) Delete(ctx context.Context, req *dto.DeleteAssetReq) (rows int64, err error) {
r, err := gfdb.DB(ctx).Model(ctx, public.AssetCollection).Where(entity.AssetCol.Id, req.Id).Delete()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAsset).Where(entity.AssetCol.Id, req.Id).Delete()
if err != nil {
return
}
@@ -50,7 +50,7 @@ func (d *assetDao) Delete(ctx context.Context, req *dto.DeleteAssetReq) (rows in
// GetOne 获取单个资产
func (d *assetDao) GetOne(ctx context.Context, req *dto.GetAssetReq, fields ...string) (res *entity.Asset, err error) {
r, err := gfdb.DB(ctx).Model(ctx, public.AssetCollection).Where(entity.AssetCol.Id, req.Id).Fields(fields).One()
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameAsset).Where(entity.AssetCol.Id, req.Id).Fields(fields).One()
if err != nil {
return
}
@@ -81,7 +81,7 @@ func (d *assetDao) List(ctx context.Context, req *dto.ListAssetReq, fields ...st
// buildListFilter 构建列表查询的过滤条件
func (d *assetDao) buildListFilter(ctx context.Context, req *dto.ListAssetReq) *gdb.Model {
model := gfdb.DB(ctx).Model(ctx, public.AssetCollection).Model
model := gfdb.DB(ctx).Model(ctx, public.TableNameAsset).Cache(ctx)
if !g.IsEmpty(req.Keyword) {
model.WhereLike(entity.AssetCol.Name, "%"+req.Keyword+"%")
}