Dockerfile
This commit is contained in:
73
dao/stock/inventory_count_adjust_history_dao.go
Normal file
73
dao/stock/inventory_count_adjust_history_dao.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"assets/consts/public"
|
||||
dto "assets/model/dto/stock"
|
||||
entity "assets/model/entity/stock"
|
||||
"context"
|
||||
|
||||
"gitea.com/red-future/common/db/mongo"
|
||||
"gitea.com/red-future/common/utils"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
var InventoryCountAdjustHistory = &inventoryCountAdjustHistory{}
|
||||
|
||||
type inventoryCountAdjustHistory struct{}
|
||||
|
||||
// Insert 插入盘点调整历史记录
|
||||
func (d *inventoryCountAdjustHistory) Insert(ctx context.Context, req *dto.CreateInventoryCountAdjustHistoryReq) (ids []interface{}, err error) {
|
||||
var result *entity.InventoryCountAdjustHistory
|
||||
if err = utils.Struct(req, &result); err != nil {
|
||||
return
|
||||
}
|
||||
ids, err = mongo.DB().Insert(ctx, []interface{}{&result}, public.InventoryCountAdjustHistoryCollection)
|
||||
return
|
||||
}
|
||||
|
||||
// GetOne 根据ID查询单条盘点调整历史记录
|
||||
func (d *inventoryCountAdjustHistory) GetOne(ctx context.Context, req *dto.GetInventoryCountAdjustHistoryReq) (res *entity.InventoryCountAdjustHistory, err error) {
|
||||
filter := bson.M{"_id": req.Id}
|
||||
err = mongo.DB().FindOne(ctx, filter, &res, public.InventoryCountAdjustHistoryCollection)
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteFake 软删除盘点调整历史记录
|
||||
func (d *inventoryCountAdjustHistory) DeleteFake(ctx context.Context, req *dto.DeleteInventoryCountAdjustHistoryReq) (err error) {
|
||||
filter := bson.M{"_id": req.Id}
|
||||
_, err = mongo.DB().DeleteSoft(ctx, filter, public.InventoryCountAdjustHistoryCollection)
|
||||
return
|
||||
}
|
||||
|
||||
// List 分页查询盘点调整历史列表
|
||||
func (d *inventoryCountAdjustHistory) List(ctx context.Context, req *dto.ListInventoryCountAdjustHistoryReq) (res []entity.InventoryCountAdjustHistory, total int64, err error) {
|
||||
filter, err := d.buildListFilter(ctx, req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
total, err = mongo.DB().Find(ctx, filter, &res, public.InventoryCountAdjustHistoryCollection, req.Page, req.OrderBy)
|
||||
return
|
||||
}
|
||||
|
||||
// buildListFilter 构建列表查询过滤条件
|
||||
func (d *inventoryCountAdjustHistory) buildListFilter(ctx context.Context, req *dto.ListInventoryCountAdjustHistoryReq) (filter bson.M, err error) {
|
||||
_ = ctx
|
||||
filter = bson.M{}
|
||||
if !g.IsEmpty(req.CountID) {
|
||||
filter["countId"] = req.CountID
|
||||
}
|
||||
if !g.IsEmpty(req.DetailID) {
|
||||
filter["detailId"] = req.DetailID
|
||||
}
|
||||
if !g.IsEmpty(req.AssetSkuID) {
|
||||
filter["assetSkuId"] = req.AssetSkuID
|
||||
}
|
||||
if !g.IsEmpty(req.WarehouseID) {
|
||||
filter["warehouseId"] = req.WarehouseID
|
||||
}
|
||||
if !g.IsEmpty(req.BatchNo) {
|
||||
filter["batchNo"] = req.BatchNo
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user