| | |
| | | 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() |