完善配送订单列表可读信息
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// 功能描述:实现配送点范围内的合同、合同气瓶和配送订单接口。
|
||||
// 版本:v1.2.0。
|
||||
// 版本:v1.3.0。
|
||||
package delivery
|
||||
|
||||
import (
|
||||
@@ -364,10 +364,30 @@ func scopedOrder(ctx *gin.Context, identity string, pointID uint64) (models.Gaso
|
||||
|
||||
func ListOrder(ctx *gin.Context) {
|
||||
point, _, ok := currentScope(ctx)
|
||||
if ok {
|
||||
listScoped(ctx, &models.GasorderBasic{}, common.ActiveRecords(db().Model(&models.GasorderBasic{})).
|
||||
Where("delivery_basic_id = ?", point.ID), "gasorder_basic.created_at desc")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
page, size := common.PageSize(ctx)
|
||||
query := common.ApplyKeywordFilter(ctx,
|
||||
common.ActiveRecords(db().Model(&models.GasorderBasic{})).Where("delivery_basic_id = ?", point.ID),
|
||||
&models.GasorderBasic{},
|
||||
)
|
||||
var total int64
|
||||
if err := query.Count(&total).Error; err != nil {
|
||||
infra.Response.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
var orders []models.GasorderBasic
|
||||
if err := query.Order("gasorder_basic.created_at desc").Offset((page - 1) * size).Limit(size).Find(&orders).Error; err != nil {
|
||||
infra.Response.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
response, err := platformgasorder.BuildGasorderListResponse(ctx, orders)
|
||||
if err != nil {
|
||||
infra.Response.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
infra.Response.Success(ctx, gin.H{"total": total, "list": response})
|
||||
}
|
||||
|
||||
func GetOrder(ctx *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user