controllers/car.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
controllers/user.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
models/userCar.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
service/userService.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
vo/car.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
controllers/car.go
@@ -107,11 +107,8 @@ c.ServeJSON() } func (c *CarController) BindCarSpace() { sv := service.NewCarService() if sv.BindCarSpace() { } c.ServeJSON() } controllers/user.go
@@ -4,6 +4,9 @@ "car-service/extend/code" "car-service/models" "car-service/service" "car-service/vo" "encoding/json" "fmt" "github.com/astaxie/beego" "net/http" ) @@ -60,18 +63,27 @@ func (u *UserController) Login() { phoneNum := u.GetString("phoneNum") cod := u.GetString("code") var sv service.UserService b, info, e := sv.Login(phoneNum, cod) resp := code.Code{} if b { resp.Success= true resp.Status= http.StatusOK resp.Data= *info } else { fmt.Println("phoneNum:", phoneNum, "code:", cod) if phoneNum == "" || cod == "" { resp.Success= false resp.Status= http.StatusBadRequest resp.Data= e.Error() resp.Data= "参数有误" } else { var sv service.UserService b, info, e := sv.Login(phoneNum, cod) if b { resp.Success= true resp.Status= http.StatusOK resp.Data= *info } else { resp.Success= false resp.Status= http.StatusBadRequest resp.Data= e.Error() } } u.Data["json"] = resp u.ServeJSON() } @@ -89,3 +101,21 @@ 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() } models/userCar.go
@@ -26,6 +26,16 @@ 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() service/userService.go
@@ -54,6 +54,10 @@ } } func (sv *UserService) AddPlateNo(userId, plateNo string) bool { return false } func NewVerifyCode(phoneNum string) error { regionId := "cn-hangzhou" accessKeyId := "LTAIkHFaStA1JKk5" vo/car.go
New file @@ -0,0 +1,6 @@ package vo type AddPlateNoVo struct { UserId string `json:"userId" binding:"required"` PlateNo string `json:"plateNo" binding:"required"` }