From dbc843d0b37f786fb816131bcc7ebca86dbe72e9 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期四, 06 八月 2020 09:58:46 +0800 Subject: [PATCH] add crossRecord --- controllers/car.go | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/controllers/car.go b/controllers/car.go index 56c179b..2329ce3 100644 --- a/controllers/car.go +++ b/controllers/car.go @@ -28,12 +28,11 @@ hikSta, flag := sv.Statistic() if flag { left := hikSta.Left - fmt.Println("realTime left:", left) if !initCacheM { models.SetSpaceNo(hikSta.TotalPermPlace) initCacheM = true } - if left <=10 && left != prePushLeft { + if left <=5 && left != prePushLeft { go func() { message := fmt.Sprintf("%s 鍓╀綑杞︿綅锛�%d涓�", time.Now().Format("2006-01-02 15:04:05"), left) b, e := service.Push("鑲茶嫳鏅烘収鍋滆溅", message) @@ -102,8 +101,9 @@ // @Failure 403 {string} json "" // @router /spaceNo [get] func (c *CarController) SpaceNo() { + userId := c.GetString("userId") sv := service.NewCarService() - spaceNos := sv.FindSpaceNo() + spaceNos := sv.FindSpaceNo(userId) sort.Sort(spaceNos) resp := code.Code{ Success: true, @@ -118,4 +118,17 @@ func (c *CarController) BindCarSpace() { c.ServeJSON() +} + +// @router /crossRecord [get] +func (c *CarController) CrossRecord() { + sv := service.NewCarService() + records := sv.CrossRecords() + resp := code.Code{ + Success: true, + Status: http.StatusOK, + Data: records, + } + c.Data["json"] = resp + c.ServeJSON() } \ No newline at end of file -- Gitblit v1.8.0