修复文件插入参数传递问题并优化租户OSS总量查询接口
This commit is contained in:
@@ -15,6 +15,6 @@ 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)
|
||||
_, err = mongo.DB().Insert(ctx, []interface{}{&entity}, consts.FileCollection)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package dao
|
||||
import (
|
||||
"context"
|
||||
"oss/consts"
|
||||
"oss/model/dto"
|
||||
"oss/model/entity"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/mongo"
|
||||
@@ -15,18 +16,12 @@ var TenantOssTotal = &tenantOssTotal{}
|
||||
type tenantOssTotal struct {
|
||||
}
|
||||
|
||||
// Insert 插入
|
||||
func (d *tenantOssTotal) Insert(ctx context.Context, entity []interface{}) (err error) {
|
||||
_, err = mongo.DB().Insert(ctx, entity, consts.TenantOssTotalCollection)
|
||||
return
|
||||
}
|
||||
|
||||
// SaveOrUpdate 增加或更新
|
||||
func (d *tenantOssTotal) SaveOrUpdate(ctx context.Context, updateData []*entity.TenantOssTotal) (err error) {
|
||||
if !g.IsEmpty(updateData) {
|
||||
var filter, update []bson.M
|
||||
for _, v := range updateData {
|
||||
bsonm, err := mongo.EntityToBSONM(v)
|
||||
bsonm, err := mongo.EntityToBsonWithFilter(v, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -41,9 +36,8 @@ func (d *tenantOssTotal) SaveOrUpdate(ctx context.Context, updateData []*entity.
|
||||
return
|
||||
}
|
||||
|
||||
func (d *tenantOssTotal) GetOneByTenantId(ctx context.Context, tenantId string) (e *entity.TenantOssTotal, err error) {
|
||||
filter := bson.M{"tenantId": tenantId}
|
||||
e = &entity.TenantOssTotal{}
|
||||
err = mongo.DB().FindOne(ctx, filter, e, consts.TenantOssTotalCollection)
|
||||
func (d *tenantOssTotal) GetOneByTenantId(ctx context.Context, req *dto.GetByTenantIdReq) (res *entity.TenantOssTotal, err error) {
|
||||
filter := bson.M{"tenantId": req.TenantId}
|
||||
err = mongo.DB().FindOne(ctx, filter, &res, consts.TenantOssTotalCollection)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ type tenantOssTotal struct{}
|
||||
var TenantOssTotal = new(tenantOssTotal)
|
||||
|
||||
func (s *tenantOssTotal) GetOneByTenantId(ctx context.Context, req *dto.GetByTenantIdReq) (res *dto.GetByTenantIdRes, err error) {
|
||||
e, err := dao.TenantOssTotal.GetOneByTenantId(ctx, req.TenantId)
|
||||
e, err := dao.TenantOssTotal.GetOneByTenantId(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user