mongo.go重构
This commit is contained in:
@@ -21,6 +21,6 @@ func (d *file) SetNoCache() {
|
||||
|
||||
// Insert 插入
|
||||
func (d *file) Insert(ctx context.Context, entity *entity.File) (err error) {
|
||||
_, err = mongo.Insert(ctx, []interface{}{entity}, consts.FileCollection)
|
||||
_, err = mongo.DB().Insert(ctx, []interface{}{entity}, consts.FileCollection)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"oss/consts"
|
||||
"oss/model/entity"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/mongo"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"oss/consts"
|
||||
"oss/model/entity"
|
||||
)
|
||||
|
||||
var TenantOssTotal = &tenantOssTotal{
|
||||
@@ -23,7 +24,7 @@ func (d *tenantOssTotal) SetNoCache() {
|
||||
|
||||
// Insert 插入
|
||||
func (d *tenantOssTotal) Insert(ctx context.Context, entity []interface{}) (err error) {
|
||||
_, err = mongo.Insert(ctx, entity, consts.TenantOssTotalCollection)
|
||||
_, err = mongo.DB().Insert(ctx, entity, consts.TenantOssTotalCollection)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ func (d *tenantOssTotal) SaveOrUpdate(ctx context.Context, updateData []*entity.
|
||||
filter = append(filter, bson.M{"tenantId": v.TenantId})
|
||||
update = append(update, bson.M{"$set": bson.M{"usedOssSize": v.UsedOssSize, "totalOssSize": v.TotalOssSize}})
|
||||
}
|
||||
_, err = mongo.SaveOrUpdate(ctx, filter, update, consts.TenantOssTotalCollection)
|
||||
_, err = mongo.DB().SaveOrUpdate(ctx, filter, update, consts.TenantOssTotalCollection)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -43,6 +44,6 @@ func (d *tenantOssTotal) SaveOrUpdate(ctx context.Context, updateData []*entity.
|
||||
func (d *tenantOssTotal) GetOneByTenantId(ctx context.Context, tenantId string) (e *entity.TenantOssTotal, err error) {
|
||||
filter := bson.M{"tenantId": tenantId}
|
||||
e = &entity.TenantOssTotal{}
|
||||
err = mongo.FindOne(ctx, d.NoCache, filter, e, consts.TenantOssTotalCollection)
|
||||
err = mongo.DB().FindOne(ctx, filter, e, consts.TenantOssTotalCollection)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user