liuxiaolong
2020-06-19 5df344667773da880d521ef45a4ca497af355d05
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package controllers
 
import (
    "car-service/extend/code"
    "car-service/models"
    "car-service/service"
    "github.com/astaxie/beego"
    "net/http"
    "sort"
    "time"
)
 
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()
    m := time.Now().Minute()
    i := m % 10
    left := 80
    if i == 0 {
        left = 10
    }
    if m == 40 {
        left = 5
    }
    sta := models.CarStatistic{
        Left: left,
    }
    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()
}