liuxiaolong
2020-07-27 aa38814dac11fbd1c7c1c04cd57aaeaff1daa0f4
controllers/user.go
@@ -131,8 +131,10 @@
// @router /myPlateNos [get]
func (u *UserController) MyPlateNos() {
   userId := u.GetString("userId")
   fmt.Println("MyPlateNos userId", userId)
   var uc models.UserCar
   all, err := uc.GetByUserId(userId)
   fmt.Println("all:", all, "err:", err)
   var nos = make([]string, 0)
   if err == nil && all != nil {
      for _,p := range all {
@@ -148,3 +150,24 @@
   u.ServeJSON()
}
// @router /delPlateNo [delete]
func (u *UserController) DelPlateNo() {
   userId := u.GetString("userId")
   plateNo := u.GetString("plateNo")
   resp := code.Code{}
   var uc models.UserCar
   i,e := uc.Delete(userId, plateNo)
   fmt.Println("delPlateNo i:",i, "e:", e)
   if e ==nil && i >0 {
      resp.Success = true
      resp.Status = http.StatusOK
      resp.Data = "删除成功"
   } else {
      resp.Success = false
      resp.Status = http.StatusInternalServerError
      resp.Data = "删除失败"
   }
   u.Data["json"] = resp
   u.ServeJSON()
}