refactor: 移除业务ID字段并优化DAO层实现

This commit is contained in:
2026-03-19 17:35:38 +08:00
parent 8e2ea0bde1
commit 39fd187502
9 changed files with 27 additions and 58 deletions

View File

@@ -8,7 +8,6 @@ import (
"gitea.com/red-future/common/db/gfdb"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/guid"
)
var File = &file{}
@@ -16,11 +15,14 @@ var File = &file{}
type file struct{}
// Insert 插入
func (d *file) Insert(ctx context.Context, req *dto.UploadFile) (res *entity.File, err error) {
func (d *file) Insert(ctx context.Context, req *dto.UploadFile) (id int64, err error) {
var res *entity.File
if err = gconv.Struct(req, &res); err != nil {
return
}
res.Bid = guid.S()
_, err = gfdb.DB(ctx).Model(ctx, consts.FileCollection).Insert(&res)
return
r, err := gfdb.DB(ctx).Model(ctx, consts.FileCollection).Insert(&res)
if err != nil {
return
}
return r.LastInsertId()
}