func DelAddress(c *gin.Context) { var cookie middleware.CookieManager cookie = c.MustGet("CM").(middleware.CookieManager) a_id, _ := strconv.Atoi(c.PostForm("id")) address := model.Address{} address.Get(a_id) fmt.Println(address) address.Delete() cookie.Flash("success_msg", "address delete success") c.JSON(http.StatusOK, address) }
func NewAddress(c *gin.Context) { me := tool.GetMe(c) if me.ID > 0 { var cookie middleware.CookieManager cookie = c.MustGet("CM").(middleware.CookieManager) province := c.PostForm("province") city := c.PostForm("city") detail := c.PostForm("detail") name := c.PostForm("name") phone := c.PostForm("phone") address := model.Address{Province: province, City: city, Detail: detail, Name: name, Phone: phone, UserID: int(me.ID)} address.Create() cookie.Flash("success_msg", "address add success") c.Redirect(http.StatusMovedPermanently, "/") } }