From f64dd9f191dff341b4eb430d7bacc44a3db9a279 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期五, 04 三月 2022 10:12:45 +0800 Subject: [PATCH] fix nil --- controllers/user.go | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/controllers/user.go b/controllers/user.go index 29b3f0c..ec7df28 100644 --- a/controllers/user.go +++ b/controllers/user.go @@ -65,7 +65,7 @@ cod := u.GetString("code") cid := u.GetString("cid") //unipush clientid resp := code.Code{} - fmt.Println("phoneNum:", phoneNum, "code:", cod) + fmt.Println("phoneNum:", phoneNum, "code:", cod, "clientId:", cid) if phoneNum == "" || cod == ""{ resp.Success= false resp.Status= http.StatusBadRequest @@ -94,6 +94,18 @@ // @Success 200 {string} logout success // @router /logout [get] func (u *UserController) Logout() { + cid := u.GetString("cid") //unipush clientid + fmt.Println("clientId:", cid) + + if cid != "" { + go func() { + unbindB, unE := service.UnbindAlias(cid) + fmt.Println("unbind result:", unbindB, "err:", unE) + var uc models.UserClient + i, e := uc.DeleteByCid(cid) + fmt.Println("deleteByCid affected:", i, "err:", e) + }() + } resp := code.Code{} resp.Success = true resp.Status = http.StatusOK @@ -186,4 +198,17 @@ } +// @router /sync [get] +func (u *UserController) Sync() { + resp := code.Code{} + syncCount := service.SyncHikPerson() + resp.Success = true + resp.Status = http.StatusOK + resp.Data = map[string]interface{}{ + "syncCount": syncCount, + } + + u.Data["json"] = resp + u.ServeJSON() +} -- Gitblit v1.8.0