refactor: 将数据库从MongoDB迁移至PostgreSQL
This commit is contained in:
@@ -3,18 +3,24 @@ package dao
|
||||
import (
|
||||
"context"
|
||||
"oss/consts"
|
||||
"oss/model/dto"
|
||||
"oss/model/entity"
|
||||
|
||||
"gitea.com/red-future/common/db/mongo"
|
||||
"gitea.com/red-future/common/db/gfdb"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/gogf/gf/v2/util/guid"
|
||||
)
|
||||
|
||||
var File = &file{}
|
||||
|
||||
type file struct {
|
||||
}
|
||||
type file struct{}
|
||||
|
||||
// Insert 插入
|
||||
func (d *file) Insert(ctx context.Context, entity *entity.File) (err error) {
|
||||
_, err = mongo.DB().Insert(ctx, []interface{}{&entity}, consts.FileCollection)
|
||||
func (d *file) Insert(ctx context.Context, req *dto.UploadFile) (res *entity.File, err error) {
|
||||
if err = gconv.Struct(req, &res); err != nil {
|
||||
return
|
||||
}
|
||||
res.Bid = guid.S()
|
||||
_, err = gfdb.DB(ctx).Model(ctx, consts.FileCollection).Insert(&res)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user