refactor: 移除业务ID字段并优化DAO层实现
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user