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 --- service/userService.go | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diff --git a/service/userService.go b/service/userService.go index dc2f08b..7d0c770 100644 --- a/service/userService.go +++ b/service/userService.go @@ -7,7 +7,9 @@ "errors" "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi" + "github.com/astaxie/beego" "github.com/satori/go.uuid" + "strings" "sync" "time" ) @@ -82,6 +84,7 @@ UserId: u.Id, PhoneNum: phoneNum, PlateNos: plateNos, + IsAdmin: isAdmin(phoneNum), }, nil } else { fmt.Println("u.Insert err:", e) @@ -89,7 +92,7 @@ } } else { //鐢ㄦ埛宸插瓨鍦� if phoneNum != tmpUser.PhoneNum { - tmpUser.UpdatePhoneNum(tmpUser.PhoneNum, hikPersonId) + tmpUser.UpdatePhoneNum(phoneNum, hikPersonId) } var plateNos = make([]string, 0) hikVehicles := carSv.GetVehicleListByPerson(hikPersonId) @@ -127,6 +130,7 @@ UserId: tmpUser.Id, PhoneNum: phoneNum, PlateNos: plateNos, + IsAdmin: isAdmin(phoneNum), }, nil } } else { @@ -134,6 +138,18 @@ } } +func isAdmin(phoneNum string) bool { + managers := beego.AppConfig.String("nightManagerPhones") + arr := strings.Split(managers, ",") + for _,s := range arr { + if s == phoneNum { + return true + } + } + + return false +} + func (sv *UserService) AddPlateNo(userId, plateNo string) bool { var uc models.UserCar if uc.Exist(userId, plateNo) { -- Gitblit v1.8.0