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

---
 conf/app.conf          |    2 +-
 vo/user.go             |    2 ++
 service/userService.go |   16 ++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/conf/app.conf b/conf/app.conf
index f303ef1..7f05f50 100644
--- a/conf/app.conf
+++ b/conf/app.conf
@@ -21,4 +21,4 @@
 pushLowerLimit = 5
 initPushLeft = 88
 testPushPhones = 18601263339
-nightManagerPhones = 18601263339
+nightManagerPhones = 15210613764
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) {
diff --git a/vo/user.go b/vo/user.go
index dd04367..bf9a5bb 100644
--- a/vo/user.go
+++ b/vo/user.go
@@ -5,4 +5,6 @@
 	PhoneNum 	string 		`json:"phoneNum"`
 	TrueName 	string 		`json:"trueName"`
 	PlateNos	[]string 	`json:"plateNos"`
+
+	IsAdmin 	bool 		`json:"isAdmin"` //鏄惁鏄鐞嗗憳
 }
\ No newline at end of file

--
Gitblit v1.8.0