liuxiaolong
2020-06-29 9b5710f23d6cbda9f2b0e650cf8916e7707d5588
controllers/user.go
@@ -113,7 +113,36 @@
      resp.Status = http.StatusBadRequest
      resp.Data = "参数有误"
   } else {
      var sv service.UserService
      if sv.AddPlateNo(reqBody.UserId, reqBody.PlateNo) {
         resp.Success = true
         resp.Status = http.StatusOK
         resp.Data = "添加成功"
      } else {
         resp.Success = false
         resp.Status = http.StatusBadRequest
         resp.Data = "添加失败"
      }
   }
   u.Data["json"] = resp
   u.ServeJSON()
}
// @router /myPlateNos [get]
func (u *UserController) MyPlateNos() {
   userId := u.GetString("userId")
   var uc models.UserCar
   all, err := uc.GetByUserId(userId)
   var nos = make([]string, 0)
   if err == nil && all != nil {
      for _,p := range all {
         nos = append(nos, p.PlateNo)
      }
   }
   resp := code.Code{
      Success: true,
      Status: http.StatusOK,
      Data: nos,
   }
   u.Data["json"] = resp
   u.ServeJSON()