feat: improve gas station management workflow
This commit is contained in:
@@ -1,16 +1,38 @@
|
||||
package delivery
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/infra"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// ListDeliveryBasic 查询配送点分页列表。
|
||||
func ListDeliveryBasic(ctx *gin.Context) { common.ListPage[models.DeliveryBasic](ctx) }
|
||||
func ListDeliveryBasic(ctx *gin.Context) {
|
||||
gasIdentities := strings.Split(strings.TrimSpace(ctx.Query("gas_basic_identities")), ",")
|
||||
if len(gasIdentities) == 1 && gasIdentities[0] == "" {
|
||||
gasIdentities = nil
|
||||
}
|
||||
if len(gasIdentities) > 100 {
|
||||
infra.Response.Error(ctx, errcode.ErrInvalidArgument)
|
||||
return
|
||||
}
|
||||
common.ListPageFiltered[models.DeliveryBasic](ctx, func(query *gorm.DB) *gorm.DB {
|
||||
if len(gasIdentities) == 0 {
|
||||
return query
|
||||
}
|
||||
return query.Where(
|
||||
"gas_basic_id IN (SELECT id FROM gas_basic WHERE identity IN ? AND status <> ?)",
|
||||
gasIdentities,
|
||||
common.StatusArchived,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// GetDeliveryBasic 查询一个配送点。
|
||||
func GetDeliveryBasic(ctx *gin.Context) { common.GetByIdentity[models.DeliveryBasic](ctx) }
|
||||
|
||||
Reference in New Issue
Block a user