package controllers import ( "car-service/extend/code" "car-service/models" "car-service/service" "github.com/astaxie/beego" "net/http" "sort" ) type CarController struct { beego.Controller } // @Title 统计剩余车位 // @Description 统计剩余车位 // @Success 200 {object} models.CarStatistic // @Failure 403 {string} json "" // @router /statistic [get] func (c *CarController) Statistic() { //sv := service.NewCarService() //sta := sv.Statistic() sta := models.CarStatistic{ Left: 80, } resp := code.Code{ Success: true, Status: http.StatusOK, Data: sta, } c.Data["json"] = resp c.ServeJSON() } // @Title 根据车牌号查找车位信息 // @Description 根据车牌号查找车位信息 // @Success 200 {object} models.CarPos // @Failure 403 {string} json "" // @router /carPos [get] func (c *CarController) findCar() { } // @Title 车位占用情况 // @Description 车位占用情况 // @Success 200 {object} models.PosResult // @Failure 403 {string} json "" // @router /spaceNo [get] func (c *CarController) SpaceNo() { sv := service.NewCarService() spaceNos := sv.FindSpaceNo() sort.Sort(spaceNos) resp := code.Code{ Success: true, Status: http.StatusOK, Data: spaceNos, } c.Data["json"] = resp c.ServeJSON() } func (c *CarController) BindCarSpace() { sv := service.NewCarService() if sv.BindCarSpace() { } c.ServeJSON() }