修复文件插入参数传递问题并优化租户OSS总量查询接口

This commit is contained in:
2026-01-12 09:11:32 +08:00
parent 8e82851b65
commit 383cccf55f
3 changed files with 7 additions and 13 deletions

View File

@@ -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
}

View File

@@ -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
}