daShangDao_psiServer/controllers/cancel_logistics.go

41 lines
926 B
Go

package controllers
import (
"net/http"
"github.com/gin-gonic/gin"
"psi/models/request"
"psi/service"
"psi/utils"
)
// CancelLogisticsApi 删除物流单号 定义一个结构体
type CancelLogisticsApi struct{}
// cancelLogisticsService 删除物流单号服务 声明一个变量
var cancelLogisticsService = service.CancelLogisticsService{}
// CancelLogistics 取消物流单号
func (r *CancelLogisticsApi) CancelLogistics(c *gin.Context) {
var req request.CancelLogisticsRequest
if err := c.ShouldBind(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": "500",
"msg": "参数错误: " + err.Error(),
})
return
}
resp, err := cancelLogisticsService.CancelLogistics(req.UserID, req.LogisticsNo)
if err != nil {
utils.ErrorLog("cancel_logistics", nil) // simple log
c.JSON(http.StatusOK, gin.H{
"code": "500",
"msg": err.Error(),
})
return
}
c.JSON(http.StatusOK, resp)
}