From 27f1012d2fecda7bcc3d9f44c5dd4c10a7cf38a4 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期二, 18 八月 2020 12:13:54 +0800
Subject: [PATCH] add log
---
service/userService.go | 51 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/service/userService.go b/service/userService.go
index 0bd2356..a468dca 100644
--- a/service/userService.go
+++ b/service/userService.go
@@ -37,7 +37,7 @@
}
var tmpUser models.User
- err := tmpUser.SelectByPhoneNum(phoneNum)
+ err := tmpUser.SelectById(hikPersonId)
fmt.Println("login err:", err)
if err != nil { //鐢ㄦ埛涓嶅瓨鍦�,鍒欐柊澧�
u := models.User{
@@ -57,8 +57,25 @@
//瀹㈡埛绔痗id缁戝畾鍒悕
if cid != "" {
go func() {
- bindR, bindE := BindAlias(cid, phoneNum)
- fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
+ var uc models.UserClient
+ ucList := uc.GetByCid(cid)
+ if ucList != nil && len(ucList) >0 {
+ if len(ucList) >1 || ucList[0].PhoneNum != phoneNum {
+ unbindB, unE := UnbindAlias(cid)
+ fmt.Println("unbindB:", unbindB, "err:", unE)
+ }
+ }
+ if !uc.ExistByCid(phoneNum, cid) {
+ new := models.UserClient{
+ Id:uuid.NewV4().String(),
+ PhoneNum: phoneNum,
+ ClientId: cid,
+ BindTime: time.Now().Format("2006-01-02 15:04:05"),
+ }
+ new.Insert()
+ bindR, bindE := BindAlias(cid, phoneNum)
+ fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
+ }
}()
}
return true, &vo.UserInfo{
@@ -71,12 +88,11 @@
return false, nil, errors.New("娉ㄥ唽澶辫触")
}
} else { //鐢ㄦ埛宸插瓨鍦�
- if hikPersonId != tmpUser.Id {
- tmpUser.Id = hikPersonId
- tmpUser.SyncHikPersonId(tmpUser.PhoneNum, hikPersonId)
+ if phoneNum != tmpUser.PhoneNum {
+ tmpUser.UpdatePhoneNum(phoneNum, hikPersonId)
}
var plateNos = make([]string, 0)
- hikVehicles := carSv.GetVehicleListByPerson(tmpUser.Id)
+ hikVehicles := carSv.GetVehicleListByPerson(hikPersonId)
if hikVehicles != nil {
for _,up := range hikVehicles {
@@ -86,8 +102,25 @@
//瀹㈡埛绔痗id缁戝畾鍒悕
if cid != "" {
go func() {
- bindR, bindE := BindAlias(cid, phoneNum)
- fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
+ var uc models.UserClient
+ ucList := uc.GetByCid(cid)
+ if ucList != nil && len(ucList) >0 {
+ if len(ucList) >1 || ucList[0].PhoneNum != phoneNum {
+ unbindB, unE := UnbindAlias(cid)
+ fmt.Println("unbindB:", unbindB, "err:", unE)
+ }
+ }
+ if !uc.ExistByCid(phoneNum, cid) {
+ new := models.UserClient{
+ Id:uuid.NewV4().String(),
+ PhoneNum: phoneNum,
+ ClientId: cid,
+ BindTime: time.Now().Format("2006-01-02 15:04:05"),
+ }
+ new.Insert()
+ bindR, bindE := BindAlias(cid, phoneNum)
+ fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
+ }
}()
}
return true, &vo.UserInfo{
--
Gitblit v1.8.0