liuxiaolong
2020-08-12 8849dda9c4fd92467e2c05c15ea483abae6af8e5
add testPush
3个文件已修改
26 ■■■■■ 已修改文件
controllers/car.go 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/userClient.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
routers/router.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/car.go
@@ -160,6 +160,27 @@
    c.ServeJSON()
}
// @router /testPush [get]
func (c *CarController) TestPush() {
    left := getSpaceLeft()
    message := fmt.Sprintf("%s 剩余车位:%d个", time.Now().Format("2006-01-02 15:04:05"), left)
    b, e := service.PushByAlias("育英中学停车", message)
    fmt.Println("b:", b,"e:",e, "message:", message)
    resp := code.Code{}
    if b {
        resp.Success = true
        resp.Status = http.StatusOK
        resp.Data = "推送成功"
    } else {
        resp.Success = false
        resp.Status = http.StatusInternalServerError
        resp.Data = e.Error()
    }
    c.Data["json"] = resp
    c.ServeJSON()
}
// @router /crossRecord [get]
func (c *CarController) CrossRecord() {
    sv := service.NewCarService()
models/userClient.go
@@ -25,7 +25,7 @@
func (uc *UserClient) Exist(phoneNum string) bool {
    var list []UserClient
    o := orm.NewOrm()
    o.Raw("select * from ? where phoneNum=?", uc.TableName(), phoneNum).QueryRows(&list)
    o.QueryTable(uc.TableName()).Filter("phoneNum", phoneNum).All(&list)
    if len(list) >0 {
        return true
    }
@@ -35,7 +35,7 @@
func (uc *UserClient) ExistByCid(phoneNum string, cid string) bool {
    var list []UserClient
    o := orm.NewOrm()
    o.Raw("select * from ? where phoneNum=? and clientId=?", uc.TableName(), phoneNum, cid).QueryRows(&list)
    o.QueryTable(uc.TableName()).Filter("phoneNum", phoneNum).Filter("clientId", cid).All(&list)
    if len(list) >0 {
        return true
    }
routers/router.go
@@ -59,4 +59,5 @@
    beego.Router(preApi+"/user/sync", &controllers.UserController{}, "*:Sync")
    beego.Router(preApi+"/car/crossRecord", &controllers.CarController{}, "*:CrossRecord")
    beego.Router(preApi+"/car/testPush", &controllers.CarController{}, "*:TestPush")
}