package service

import (
	"cold-delivery/app/admin/model"
	"cold-delivery/app/admin/service/dto"
	cDto "cold-delivery/common/dto"
	"cold-delivery/common/global"
	"gogs.baozhida.cn/zoie/OAuth-core/service"
)

type WaybillLogistics struct {
	service.Service
}

// GetPage 获取WaybillLogistics列表
func (e *WaybillLogistics) GetPage(c *dto.WaybillLogisticsGetPageReq, list *[]model.WaybillLogistics, count *int64) error {
	var err error
	var data model.WaybillLogistics

	err = e.Orm.Model(&data).
		Scopes(
			cDto.MakeCondition(c.GetNeedSearch()),
		).
		Preload("CoolerBox").
		Find(list).
		Count(count).Error
	if err != nil {
		e.Log.Errorf("db error: %s", err)
		return global.GetFailedErr
	}
	return nil
}
