29 lines
517 B
Go
29 lines
517 B
Go
package dao
|
|
|
|
import (
|
|
"context"
|
|
"oss/consts"
|
|
"oss/model/dto"
|
|
"oss/model/entity"
|
|
|
|
"gitea.com/red-future/common/db/gfdb"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
)
|
|
|
|
var File = &file{}
|
|
|
|
type file struct{}
|
|
|
|
// Insert 插入
|
|
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
|
|
}
|
|
r, err := gfdb.DB(ctx).Model(ctx, consts.FileCollection).Insert(&res)
|
|
if err != nil {
|
|
return
|
|
}
|
|
return r.LastInsertId()
|
|
}
|