| | |
| | | c.ServeJSON() |
| | | } |
| | | |
| | | |
| | | func (c *CarController) BindCarSpace() { |
| | | sv := service.NewCarService() |
| | | |
| | | if sv.BindCarSpace() { |
| | | |
| | | } |
| | | c.ServeJSON() |
| | | } |
| | |
| | | "car-service/extend/code" |
| | | "car-service/models" |
| | | "car-service/service" |
| | | "car-service/vo" |
| | | "encoding/json" |
| | | "fmt" |
| | | "github.com/astaxie/beego" |
| | | "net/http" |
| | | ) |
| | |
| | | func (u *UserController) Login() { |
| | | phoneNum := u.GetString("phoneNum") |
| | | cod := u.GetString("code") |
| | | resp := code.Code{} |
| | | fmt.Println("phoneNum:", phoneNum, "code:", 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) |
| | | resp := code.Code{} |
| | | |
| | | if b { |
| | | resp.Success= true |
| | | resp.Status= http.StatusOK |
| | |
| | | resp.Status= http.StatusBadRequest |
| | | resp.Data= e.Error() |
| | | } |
| | | } |
| | | |
| | | u.Data["json"] = resp |
| | | u.ServeJSON() |
| | | } |
| | |
| | | u.ServeJSON() |
| | | } |
| | | |
| | | // @Param reqBody body vo.AddPlateNoVo true "绑定车牌号参数" |
| | | // @router /addPlateNo [post] |
| | | func (u *UserController) AddPlateNo() { |
| | | var reqBody vo.AddPlateNoVo |
| | | body := u.Ctx.Input.RequestBody |
| | | err := json.Unmarshal(body, &reqBody) |
| | | resp := code.Code{} |
| | | if err != nil { |
| | | resp.Success = false |
| | | resp.Status = http.StatusBadRequest |
| | | resp.Data = "参数有误" |
| | | } else { |
| | | |
| | | } |
| | | u.Data["json"] = resp |
| | | u.ServeJSON() |
| | | } |
| | | |
| | |
| | | return all,nil |
| | | } |
| | | |
| | | func (uc *UserCar) Exist(userId string, plateNo string) bool { |
| | | var list []UserCar |
| | | o := orm.NewOrm() |
| | | i,_ := o.Raw("select * from ? where userId=? and plateNo=?", uc.TableName(), userId, plateNo).QueryRows(&list) |
| | | if i > 0 && len(list) >0 { |
| | | return true |
| | | } |
| | | return false |
| | | } |
| | | |
| | | func (uc *UserCar) DeleteByUserId(userId string) (int64, error) { |
| | | o := orm.NewOrm() |
| | | result, err := o.Raw("delete from ? where userId=?", uc.TableName(), userId).Exec() |
| | |
| | | } |
| | | } |
| | | |
| | | func (sv *UserService) AddPlateNo(userId, plateNo string) bool { |
| | | return false |
| | | } |
| | | |
| | | func NewVerifyCode(phoneNum string) error { |
| | | regionId := "cn-hangzhou" |
| | | accessKeyId := "LTAIkHFaStA1JKk5" |
New file |
| | |
| | | package vo |
| | | |
| | | type AddPlateNoVo struct { |
| | | UserId string `json:"userId" binding:"required"` |
| | | PlateNo string `json:"plateNo" binding:"required"` |
| | | } |