liuxiaolong
2020-08-10 9358e5ec2d2b65fec4ef9a1be7d1a1e1e2cf9d2d
controllers/user.go
@@ -63,15 +63,16 @@
func (u *UserController) Login() {
   phoneNum := u.GetString("phoneNum")
   cod := u.GetString("code")
   cid := u.GetString("cid")  //unipush clientid
   resp := code.Code{}
   fmt.Println("phoneNum:", phoneNum, "code:", cod)
   if phoneNum == "" || cod == "" {
   if phoneNum == "" || cod == ""{
      resp.Success= false
      resp.Status= http.StatusBadRequest
      resp.Data= "参数有误"
   } else {
      var sv service.UserService
      b, info, e := sv.Login(phoneNum, cod)
      b, info, e := sv.Login(phoneNum, cod, cid)
      if b {
         resp.Success= true
@@ -131,11 +132,12 @@
// @router /myPlateNos [get]
func (u *UserController) MyPlateNos() {
   userId := u.GetString("userId")
   var uc models.UserCar
   all, err := uc.GetByUserId(userId)
   fmt.Println("MyPlateNos userId", userId)
   sv :=  service.NewCarService()
   vehicleList := sv.GetVehicleListByPerson(userId)
   var nos = make([]string, 0)
   if err == nil && all != nil {
      for _,p := range all {
   if vehicleList != nil {
      for _,p := range vehicleList {
         nos = append(nos, p.PlateNo)
      }
   }
@@ -154,7 +156,9 @@
   plateNo := u.GetString("plateNo")
   resp := code.Code{}
   var uc models.UserCar
   if i,e := uc.Delete(userId, plateNo);e ==nil && i >0 {
   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 = "删除成功"
@@ -167,3 +171,19 @@
   u.ServeJSON()
}
// @router /all [get]
func (u *UserController) GetUserAll() {
   resp := code.Code{}
   sv := service.NewCarService()
   personAll := sv.GetHikPersonList()
   if personAll != nil {
      resp.Success = true
      resp.Status = http.StatusOK
      resp.Data = personAll
   }
   u.Data["json"] = resp
   u.ServeJSON()
}