daShangDao_psiServer/controllers/shipping.go
2026-06-15 13:47:39 +08:00

80 lines
2.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package controllers
import (
"github.com/gin-gonic/gin"
"net/http"
"psi/constant"
"psi/database"
systemReq "psi/models/request"
systemRes "psi/models/response"
"psi/service"
"psi/utils"
)
type ShippingApi struct{}
var shippingService = service.ShippingService{}
// GetShippingOrderList 获取发货单列表
func (r *ShippingApi) GetShippingOrderList(c *gin.Context) {
var req systemReq.GetShippingOrderListRequest
if err := c.ShouldBindQuery(&req); err != nil {
ValidAndFail(constant.LoggerChannelRequest, "发货单列表请求参数异常", "参数错误: "+err.Error(), c, err)
return
}
userInfo := utils.GetUserInfo(c)
result, err := shippingService.GetShippingOrderList(req, userInfo.ID, userInfo.Role, database.GetDB(c))
if err != nil {
utils.FailWithRequestLog(constant.LoggerChannelWork, "发货单列表异常", err, c, req)
return
}
c.JSON(http.StatusOK, gin.H{
"code": 200,
"data": result,
})
}
// GetShippingOrderDetail 获取发货单详情
func (r *ShippingApi) GetShippingOrderDetail(c *gin.Context) {
var req systemReq.GetShippingOrderDetailRequest
if err := c.ShouldBindQuery(&req); err != nil {
ValidAndFail(constant.LoggerChannelRequest, "发货单详情请求参数异常", "参数错误: "+err.Error(), c, err)
return
}
userInfo := utils.GetUserInfo(c)
result, err := shippingService.GetShippingOrderDetail(req.ID, userInfo.ID, userInfo.Role, database.GetDB(c))
if err != nil {
utils.FailWithRequestLog(constant.LoggerChannelWork, "发货单详情异常", err, c, req)
return
}
systemRes.OkWithDetailed(result, "查询成功", c)
}
// GetShippingOrderDetailList 获取发货单详情列表按状态筛选返回list+detail所有字段
func (r *ShippingApi) GetShippingOrderDetailList(c *gin.Context) {
var req systemReq.GetShippingOrderDetailListRequest
if err := c.ShouldBindQuery(&req); err != nil {
ValidAndFail(constant.LoggerChannelRequest, "发货单详情列表请求参数异常", "参数错误: "+err.Error(), c, err)
return
}
userInfo := utils.GetUserInfo(c)
result, err := shippingService.GetShippingOrderDetailList(req, userInfo.ID, userInfo.Role, database.GetDB(c))
if err != nil {
utils.FailWithRequestLog(constant.LoggerChannelWork, "发货单详情列表异常", err, c, req)
return
}
c.JSON(http.StatusOK, gin.H{
"code": 200,
"data": result,
})
}