优化mongo,封装count逻辑,处理objectId
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"cid/model/dto"
|
||||
"cid/model/entity"
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
@@ -21,15 +20,10 @@ func (s *advertisement) Add(ctx context.Context, req *dto.AddAdvertisementReq) (
|
||||
return
|
||||
}
|
||||
|
||||
// 设置基础字段
|
||||
now := time.Now()
|
||||
advertisement.CreatedAt = now
|
||||
advertisement.UpdatedAt = now
|
||||
advertisement.IsDeleted = false
|
||||
|
||||
// 设置初始状态
|
||||
advertisement.Status = "待审核"
|
||||
|
||||
// 注意:CreatedAt、UpdatedAt、TenantId、IsDeleted等字段由common/mongo的Insert方法自动设置
|
||||
if err = dao.Advertisement.Insert(ctx, advertisement); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user