From ca10e9d776509f54cb0251b7eae44cee74d94b2c Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期二, 01 九月 2020 20:09:50 +0800
Subject: [PATCH] findHikSpaceUser add state=1

---
 controllers/user.go |   56 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/controllers/user.go b/controllers/user.go
index 1e7f612..a906ae3 100644
--- a/controllers/user.go
+++ b/controllers/user.go
@@ -63,15 +63,16 @@
 func (u *UserController) Login() {
 	phoneNum := u.GetString("phoneNum")
 	cod := u.GetString("code")
+	cid := u.GetString("cid")  //unipush clientid
 	resp := code.Code{}
-	fmt.Println("phoneNum:", phoneNum, "code:", cod)
-	if phoneNum == "" || cod == "" {
+	fmt.Println("phoneNum:", phoneNum, "code:", cod, "clientId:", cid)
+	if phoneNum == "" || cod == ""{
 		resp.Success= false
 		resp.Status= http.StatusBadRequest
 		resp.Data= "鍙傛暟鏈夎"
 	} else {
 		var sv service.UserService
-		b, info, e := sv.Login(phoneNum, cod)
+		b, info, e := sv.Login(phoneNum, cod, cid)
 
 		if b {
 			resp.Success= true
@@ -93,6 +94,17 @@
 // @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
+			uc.DeleteByCid(cid)
+		}()
+	}
 	resp := code.Code{}
 	resp.Success = true
 	resp.Status = http.StatusOK
@@ -132,12 +144,11 @@
 func (u *UserController) MyPlateNos() {
 	userId := u.GetString("userId")
 	fmt.Println("MyPlateNos userId", userId)
-	var uc models.UserCar
-	all, err := uc.GetByUserId(userId)
-	fmt.Println("all:", all, "err:", err)
+	sv :=  service.NewCarService()
+	vehicleList := sv.GetVehicleListByPerson(userId)
 	var nos = make([]string, 0)
-	if err == nil && all != nil {
-		for _,p := range all {
+	if vehicleList != nil {
+		for _,p := range vehicleList {
 			nos = append(nos, p.PlateNo)
 		}
 	}
@@ -171,3 +182,32 @@
 	u.ServeJSON()
 }
 
+// @router /all [get]
+func (u *UserController) GetUserAll() {
+	resp := code.Code{}
+	sv := service.NewCarService()
+	personAll := sv.GetHikPersonList()
+	if personAll != nil {
+		resp.Success = true
+		resp.Status = http.StatusOK
+		resp.Data = personAll
+	}
+	u.Data["json"] = resp
+	u.ServeJSON()
+}
+
+
+// @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