Преглед изворни кода

update: 优化用户模块登录认证

zoie пре 2 година
родитељ
комит
0fca63a99a
5 измењених фајлова са 50 додато и 259 уклоњено
  1. 2 2
      Nats/NatsServer/NatsWorkOrder.go
  2. 3 4
      Nats/NatsServer/NatsWx.go
  3. 39 247
      controllers/User.go
  4. 4 3
      controllers/lib/lib.go
  5. 2 3
      routers/filter.go

+ 2 - 2
Nats/NatsServer/NatsWorkOrder.go

@@ -17,7 +17,7 @@ func Read_WorkOrderT_State_Count(T_pids string) (int64, int64) {
 	type T_R struct {
 		Code                  int16  `xml:"Code"`
 		Msg                   string `xml:"Msg"`
-		WorkOrderNum          int64  // 工单数量
+		TodayWorkOrderNum     int64  // 今日工单数量
 		UntreatedWorkOrderNum int64  // 未处理工单数量
 	}
 	var t_R T_R
@@ -27,6 +27,6 @@ func Read_WorkOrderT_State_Count(T_pids string) (int64, int64) {
 		return 0, 0
 	}
 
-	return t_R.WorkOrderNum, t_R.UntreatedWorkOrderNum
+	return t_R.TodayWorkOrderNum, t_R.UntreatedWorkOrderNum
 
 }

+ 3 - 4
Nats/NatsServer/NatsWx.go

@@ -14,10 +14,9 @@ func Wx_GenerateQRCode(T_uuid string) (string, bool) {
 	msg, err := lib.Nats.Request("Wx_GenerateQR", []byte(T_uuid), 3*time.Second)
 	if err != nil {
 		fmt.Println(err)
-	} else {
-		fmt.Printf("Wx_GenerateQR : %s\n", string(msg.Data))
-		return string(msg.Data), true
+		return "", false
 	}
+	fmt.Printf("Wx_GenerateQR : %s\n", string(msg.Data))
+	return string(msg.Data), true
 
-	return string(msg.Data), false
 }

+ 39 - 247
controllers/User.go

@@ -18,6 +18,17 @@ import (
 
 type UserController struct {
 	beego.Controller
+	Admin_r Account.Admin // 登陆的用户
+	T_pid   int           // 公司id
+}
+
+func (c *UserController) Prepare() {
+	c.Admin_r = lib.Admin_r
+	T_pid := c.Admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = strconv.Atoi(c.Ctx.Request.Header.Get("T_pid"))
+	}
+	c.T_pid = T_pid
 }
 
 // 获取微信二维码  ( 扫描后 ,Nats 自动绑定在 Admin->T_wx )
@@ -40,18 +51,10 @@ func (c *UserController) User_WxQRCode() {
 
 // 公司管理
 func (c *UserController) Company_Tree() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	var r_jsons lib.R_JSONS
 
 	T_name := c.GetString("T_name")
-	r_jsons.Data, r_jsons.Num = Account.Read_Company_Tree(admin_r, T_name)
+	r_jsons.Data, r_jsons.Num = Account.Read_Company_Tree(c.Admin_r, T_name)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
 	c.ServeJSON()
@@ -81,15 +84,6 @@ func (c *UserController) Company_List() {
 }
 
 func (c *UserController) Company_Add() {
-
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_mid, _ := c.GetInt("T_mid")
 	T_name := c.GetString("T_name")
 
@@ -106,7 +100,7 @@ func (c *UserController) Company_Add() {
 		return
 	}
 
-	System.Add_UserLogs_T(admin_r.T_uuid, "公司管理", "添加", var_)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "公司管理", "添加", var_)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: id}
 	c.ServeJSON()
 	return
@@ -114,13 +108,6 @@ func (c *UserController) Company_Add() {
 
 func (c *UserController) Company_Edit() {
 
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
 	Id, Id_err := c.GetInt("Id")
 	if Id_err != nil {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id Err!"}
@@ -152,7 +139,7 @@ func (c *UserController) Company_Edit() {
 		return
 	}
 
-	System.Add_UserLogs_T(admin_r.T_uuid, "公司管理", "修改", Company_r)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "公司管理", "修改", Company_r)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -160,13 +147,6 @@ func (c *UserController) Company_Edit() {
 
 func (c *UserController) Company_Del() {
 
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
 	Id, Id_err := c.GetInt("Id")
 	if Id_err != nil {
 		c.Data["json"] = lib.JSONS{Code: 204, Msg: "Id Err!"}
@@ -188,7 +168,7 @@ func (c *UserController) Company_Del() {
 		return
 	}
 
-	System.Add_UserLogs_T(admin_r.T_uuid, "公司管理", "删除", Company_r)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "公司管理", "删除", Company_r)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -198,13 +178,6 @@ func (c *UserController) Company_Del() {
 
 // 用户管理
 func (c *UserController) User_List() {
-	// 验证登录
-	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
 
 	var r_jsons lib.R_JSONS
 
@@ -237,14 +210,6 @@ func (c *UserController) User_List() {
 }
 
 func (c *UserController) User_Get() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_uuid := c.GetString("T_uuid")
 	if len(T_uuid) < 8 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
@@ -264,14 +229,6 @@ func (c *UserController) User_Get() {
 }
 
 func (c *UserController) User_Info() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	type User_ struct {
 		User Account.Admin_R
 		//Power Account.Power // 权限
@@ -280,7 +237,7 @@ func (c *UserController) User_Info() {
 	}
 
 	Admin_r := User_{}
-	Admin_r.User = Account.AdminToAdmin_R(admin_r)
+	Admin_r.User = Account.AdminToAdmin_R(c.Admin_r)
 	//Admin_r.Power, _ = Account.Read_Power_ById(admin_r.T_power)
 	//Admin_r.Menu = Account.Read_Menu_Tree(Power.T_menu, T_pid)
 
@@ -290,14 +247,7 @@ func (c *UserController) User_Info() {
 }
 
 func (c *UserController) User_Post() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
+	admin_r := c.Admin_r
 	T_name := c.GetString("T_name")
 	T_pass := c.GetString("T_pass")
 	T_phone := c.GetString("T_phone")
@@ -331,7 +281,7 @@ func (c *UserController) User_Post() {
 		return
 	}
 	admin_r.T_pass = "******"
-	System.Add_UserLogs_T(admin_r.T_uuid, "用户管理", "修改个人信息", admin_r)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "修改个人信息", admin_r)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -339,14 +289,6 @@ func (c *UserController) User_Post() {
 
 func (c *UserController) User_Add() {
 
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_power, _ := c.GetInt("T_power")
 	T_pid, _ := c.GetInt("T_pid")
 	T_name := c.GetString("T_name")
@@ -394,7 +336,7 @@ func (c *UserController) User_Add() {
 	}
 
 	var_.T_pass = "******"
-	System.Add_UserLogs_T(admin_r.T_uuid, "用户管理", "添加", var_)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "添加", var_)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -402,13 +344,6 @@ func (c *UserController) User_Add() {
 
 func (c *UserController) User_Edit() {
 
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
 	T_uuid := c.GetString("T_uuid")
 	if len(T_uuid) < 8 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
@@ -461,21 +396,13 @@ func (c *UserController) User_Edit() {
 		return
 	}
 	r.T_pass = "******"
-	System.Add_UserLogs_T(admin_r.T_uuid, "用户管理", "编辑", r)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "编辑", r)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 }
 
 func (c *UserController) User_Del() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_uuid := c.GetString("T_uuid")
 	if len(T_uuid) <= 0 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
@@ -494,7 +421,7 @@ func (c *UserController) User_Del() {
 		return
 	}
 
-	System.Add_UserLogs_T(admin_r.T_uuid, "用户管理", "删除", T_uuid)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "删除", T_uuid)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -504,12 +431,7 @@ func (c *UserController) User_Del() {
 // 管理员
 func (c *UserController) User_Home() {
 	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
+	admin_r := c.Admin_r
 
 	type Info struct {
 		T_name                string           // 姓名
@@ -549,14 +471,6 @@ func (c *UserController) User_Home() {
 
 // 内部用户管理
 func (c *UserController) Admin_List() {
-	// 验证登录
-	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	var r_jsons lib.R_JSONS
 
 	page, _ := c.GetInt("page")
@@ -582,14 +496,6 @@ func (c *UserController) Admin_List() {
 }
 
 func (c *UserController) Admin_Get() {
-	// 验证登录
-	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_uuid := c.GetString("T_uuid")
 	if len(T_uuid) < 8 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
@@ -609,15 +515,6 @@ func (c *UserController) Admin_Get() {
 }
 
 func (c *UserController) Admin_Add() {
-
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_power, _ := c.GetInt("T_power")
 	T_name := c.GetString("T_name")
 	T_user := c.GetString("T_user")
@@ -660,21 +557,13 @@ func (c *UserController) Admin_Add() {
 	}
 
 	var_.T_pass = "******"
-	System.Add_UserLogs_T(admin_r.T_uuid, "用户管理", "添加", var_)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "添加", var_)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 }
 
 func (c *UserController) Admin_Edit() {
-
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
 	T_uuid := c.GetString("T_uuid")
 	if len(T_uuid) < 8 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
@@ -727,21 +616,13 @@ func (c *UserController) Admin_Edit() {
 		return
 	}
 	r.T_pass = "********"
-	System.Add_UserLogs_T(admin_r.T_uuid, "用户管理", "编辑", r)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "编辑", r)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 }
 
 func (c *UserController) Admin_Del() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_uuid := c.GetString("T_uuid")
 	if len(T_uuid) <= 0 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
@@ -760,7 +641,7 @@ func (c *UserController) Admin_Del() {
 		return
 	}
 
-	System.Add_UserLogs_T(admin_r.T_uuid, "用户管理", "删除", T_uuid)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "删除", T_uuid)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -769,14 +650,6 @@ func (c *UserController) Admin_Del() {
 
 // 报警通知的用户列表
 func (c *UserController) User_Notice_List() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	type R_JSONS struct {
 		//必须的大写开头
 		AdminList []Account.Admin_R
@@ -785,15 +658,16 @@ func (c *UserController) User_Notice_List() {
 
 	var r_jsons R_JSONS
 
-	T_pid := admin_r.T_pid
-	if T_pid == 0 {
-		T_pid, _ = strconv.Atoi(c.Ctx.Request.Header.Get("T_pid"))
+	if c.T_pid == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
+		c.ServeJSON()
+		return
 	}
 
 	// 绑定公司id的内部用户列表
-	r_jsons.AdminList = Account.Read_Admin_List_T_pids(T_pid)
+	r_jsons.AdminList = Account.Read_Admin_List_T_pids(c.T_pid)
 	// 绑定公司id的公司用户列表
-	r_jsons.UserList = Account.Read_Admin_List_T_pid(T_pid)
+	r_jsons.UserList = Account.Read_Admin_List_T_pid(c.T_pid)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
 	c.ServeJSON()
@@ -841,14 +715,6 @@ func (c *UserController) AdminCompanyBind_List() {
 	return
 }
 func (c *UserController) AdminCompanyBind_Add() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_uuid := c.GetString("T_uuid")
 	if len(T_uuid) < 8 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
@@ -880,20 +746,12 @@ func (c *UserController) AdminCompanyBind_Add() {
 		return
 	}
 
-	System.Add_UserLogs(admin_r.T_uuid, "内部用户管理", "公司绑定添加", T_uuid+"-"+strconv.Itoa(T_pid))
+	System.Add_UserLogs(c.Admin_r.T_uuid, "内部用户管理", "公司绑定添加", T_uuid+"-"+strconv.Itoa(T_pid))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 }
 func (c *UserController) AdminCompanyBind_Del() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_uuid := c.GetString("T_uuid")
 	if len(T_uuid) < 8 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_uuid Err!"}
@@ -925,7 +783,7 @@ func (c *UserController) AdminCompanyBind_Del() {
 		return
 	}
 
-	System.Add_UserLogs(admin_r.T_uuid, "内部用户管理", "公司绑定删除", T_uuid+"-"+strconv.Itoa(T_pid))
+	System.Add_UserLogs(c.Admin_r.T_uuid, "内部用户管理", "公司绑定删除", T_uuid+"-"+strconv.Itoa(T_pid))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -933,14 +791,6 @@ func (c *UserController) AdminCompanyBind_Del() {
 
 // 权限管理
 func (c *UserController) Power_List() {
-	// 验证登录
-	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	var r_jsons lib.R_JSONS
 
 	page, _ := c.GetInt("page")
@@ -966,15 +816,7 @@ func (c *UserController) Power_List() {
 
 // 权限管理
 func (c *UserController) Power_List_All() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
-	r, err := Account.Read_Power_ById(admin_r.T_power)
+	r, err := Account.Read_Power_ById(c.Admin_r.T_power)
 	if err != nil {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id Err!"}
 		c.ServeJSON()
@@ -991,13 +833,6 @@ func (c *UserController) Power_List_All() {
 }
 
 func (c *UserController) Power_Get() {
-	// 验证登录
-	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
 	type Data struct {
 		Power        Account.Power_
 		Menu         []Account.Menu
@@ -1060,14 +895,6 @@ func (c *UserController) Power_Get() {
 }
 
 func (c *UserController) Power_Add() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	T_name := c.GetString("T_name")
 	T_select := c.GetString("T_select")
 	T_warning := c.GetString("T_warning")
@@ -1088,20 +915,13 @@ func (c *UserController) Power_Add() {
 		return
 	}
 
-	System.Add_UserLogs_T(admin_r.T_uuid, "权限管理", "添加", var_)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "权限管理", "添加", var_)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 }
 
 func (c *UserController) Power_Edit() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
 	Id, Id_err := c.GetInt("T_id")
 	if Id_err != nil || Id == 0 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id Err!"}
@@ -1143,20 +963,13 @@ func (c *UserController) Power_Edit() {
 		c.ServeJSON()
 		return
 	}
-	System.Add_UserLogs_T(admin_r.T_uuid, "权限管理", "修改", r)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "权限管理", "修改", r)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 }
 
 func (c *UserController) Power_Del() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
 	id, id_err := c.GetInt("T_id")
 	if id_err != nil || id == 0 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id Err!"}
@@ -1177,7 +990,7 @@ func (c *UserController) Power_Del() {
 		return
 	}
 
-	System.Add_UserLogs(admin_r.T_uuid, "权限管理", "删除", strconv.Itoa(id))
+	System.Add_UserLogs(c.Admin_r.T_uuid, "权限管理", "删除", strconv.Itoa(id))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -1185,28 +998,15 @@ func (c *UserController) Power_Del() {
 
 // 菜单列表
 func (c *UserController) User_Menu_List() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
-	T_pid := admin_r.T_pid
-	if T_pid == 0 {
-		T_pid, _ = strconv.Atoi(c.Ctx.Request.Header.Get("T_pid"))
-	}
-
 	var r_jsons lib.R_JSONS
-	power, err := Account.Read_Power_ById(admin_r.T_power)
+	power, err := Account.Read_Power_ById(c.Admin_r.T_power)
 	if err != nil {
 		c.Data["json"] = lib.JSONS{Code: 200, Msg: "获取菜单失败"}
 		c.ServeJSON()
 		return
 	}
 
-	r_jsons.Data = Account.Read_Menu_Bind_List(power.T_menu, T_pid)
+	r_jsons.Data = Account.Read_Menu_Bind_List(power.T_menu, c.T_pid)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
 	c.ServeJSON()
@@ -1215,14 +1015,6 @@ func (c *UserController) User_Menu_List() {
 
 // 权限菜单列表
 func (c *UserController) Menu_List_All() {
-	// 验证登录
-	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
 	var r_jsons lib.R_JSONS
 
 	r_jsons.Data, _ = Account.Read_Menu_List_All()

+ 4 - 3
controllers/lib/lib.go

@@ -79,12 +79,13 @@ func Verification(GetCookie string, GetString string) (bool, Account.Admin) {
 	if !is {
 		return false, Account.Admin{}
 	}
-	admin_r, err := Account.Read_Admin_ByUuid(tokey)
+	var err error
+	Admin_r, err = Account.Read_Admin_ByUuid(tokey)
 	if err != nil {
 		return false, Account.Admin{}
 	}
-	log.Println("登录 Admin_name 为:", admin_r.T_name)
-	return true, admin_r
+	log.Println("登录 Admin_name 为:", Admin_r.T_name)
+	return true, Admin_r
 }
 
 // 登录验证

+ 2 - 3
routers/filter.go

@@ -40,8 +40,7 @@ func FilterRBAC(ctx *context.Context) {
 	if _, ok := filterExcludeURLMap[ctx.Request.URL.Path]; ok {
 		return
 	}
-	var b_ bool
-	b_, lib.Admin_r = lib.Verification(ctx.GetCookie("User_tokey"), ctx.Input.Query("User_tokey"))
+	b_, admin_r := lib.Verification(ctx.GetCookie("User_tokey"), ctx.Input.Query("User_tokey"))
 	if !b_ {
 		ctx.Output.JSON(lib.JSONS{Code: 201, Msg: "请重新登陆!"}, true, false)
 
@@ -51,7 +50,7 @@ func FilterRBAC(ctx *context.Context) {
 		return
 	}
 
-	power, _ := Account.Read_Power_ById(lib.Admin_r.T_power)
+	power, _ := Account.Read_Power_ById(admin_r.T_power)
 
 	if power.T_menu == "*" {
 		return