You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
593 B
34 lines
593 B
package addr
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"recook/internal/back"
|
|
"recook/internal/dbc"
|
|
"recook/internal/model/user"
|
|
"recook/tools"
|
|
)
|
|
|
|
type removeParam struct {
|
|
AddrID uint `json:"addrID" validate:"required"`
|
|
}
|
|
|
|
func RemoveAddr(c *gin.Context) {
|
|
var p removeParam
|
|
err := tools.ParseParams(&p, c)
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
if p.AddrID == 0 {
|
|
back.Fail(c, "请选择收货地址")
|
|
return
|
|
}
|
|
|
|
err = dbc.DB.Delete(user.Addr{}, "id = ?", p.AddrID).Error
|
|
if err != nil {
|
|
back.Err(c, err.Error())
|
|
return
|
|
}
|
|
back.Suc(c, "操作成功", nil)
|
|
}
|