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