| | |
| | | u.ServeJSON() |
| | | } |
| | | |
| | | // @router /delPlateNo [delete] |
| | | func (u *UserController) DelPlateNo() { |
| | | userId := u.GetString("userId") |
| | | plateNo := u.GetString("plateNo") |
| | | resp := code.Code{} |
| | | var uc models.UserCar |
| | | if i,e := uc.Delete(userId, plateNo);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() |
| | | } |
| | | |
| | |
| | | return false |
| | | } |
| | | |
| | | func (uc *UserCar) DeleteByUserId(userId string) (int64, error) { |
| | | func (uc *UserCar) Delete(userId string, plateNo string) (int64, error) { |
| | | o := orm.NewOrm() |
| | | result, err := o.Raw("delete from ? where userId=?", uc.TableName(), userId).Exec() |
| | | result, err := o.Raw("delete from ? where userId=? and plateNo=?", uc.TableName(), userId, plateNo).Exec() |
| | | if err != nil { |
| | | return 0, err |
| | | } |
| | |
| | | beego.Router(preApi+"/user/logout", &controllers.UserController{}, "*:Logout") |
| | | beego.Router(preApi+"/user/addPlateNo", &controllers.UserController{}, "*:AddPlateNo") |
| | | beego.Router(preApi+"/user/myPlateNos", &controllers.UserController{}, "*:MyPlateNos") |
| | | beego.Router(preApi+"/user/delPlateNo", &controllers.UserController{}, "*:DelPlateNo") |
| | | } |