From 37f69af50f54e1a15cbfbf8d652fb1042618fb78 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期二, 01 九月 2020 17:56:12 +0800
Subject: [PATCH] add user isAdmin

---
 service/userService.go |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/service/userService.go b/service/userService.go
index a468dca..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)
@@ -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