|
@@ -264,6 +264,49 @@ func (c *UserController) User_Entry() {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (c *UserController) V2_User_Entry() {
|
|
|
|
+ // 验证登录
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Admin_power > 6 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Admin_uuid := c.GetString("T_uuid")
|
|
|
|
+ if len(Admin_uuid) > 0 {
|
|
|
|
+ admin_r_a, err := Admin.Read_Admin_ByUuid(Admin_uuid)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "e!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Id != admin_r_a.Admin_master {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "e!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ User_tokey := Admin.Add_Tokey_Set(admin_r_a.Admin_uuid)
|
|
|
|
+ c.Ctx.SetCookie("User_tokey", User_tokey, time.Second*60*60)
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "e!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ System.Add_UserLogs(admin_r.Admin_uuid, "用户管理", "无钥匙进入", Admin_uuid)
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
// 用户管理
|
|
// 用户管理
|
|
func (c *UserController) User_html() {
|
|
func (c *UserController) User_html() {
|
|
// 验证登录
|
|
// 验证登录
|
|
@@ -272,6 +315,7 @@ func (c *UserController) User_html() {
|
|
c.Ctx.Redirect(302, "Login")
|
|
c.Ctx.Redirect(302, "Login")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
page, _ := c.GetInt("page")
|
|
page, _ := c.GetInt("page")
|
|
println(page)
|
|
println(page)
|
|
if page < 1 {
|
|
if page < 1 {
|
|
@@ -301,6 +345,46 @@ func (c *UserController) User_html() {
|
|
c.TplName = "User/User.html"
|
|
c.TplName = "User/User.html"
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 用户管理
|
|
|
|
+func (c *UserController) V2_User_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 {
|
|
|
|
+ //必须的大写开头
|
|
|
|
+ Data []Admin.Admin
|
|
|
|
+ Num int64
|
|
|
|
+ Page int
|
|
|
|
+ Page_size int
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var r_jsons R_JSONS
|
|
|
|
+
|
|
|
|
+ page, _ := c.GetInt("page")
|
|
|
|
+ println(page)
|
|
|
|
+ if page < 1 {
|
|
|
|
+ page = 1
|
|
|
|
+ }
|
|
|
|
+ page_z, _ := c.GetInt("page_z")
|
|
|
|
+ if page_z < 1 {
|
|
|
|
+ page_z = conf.Page_size
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Name := c.GetString("T_name")
|
|
|
|
+
|
|
|
|
+ r_jsons.Data, r_jsons.Num = Admin.Read_v2_Admin_List(admin_r.Id, Name, page, page_z)
|
|
|
|
+ r_jsons.Page = page
|
|
|
|
+ r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
|
|
+
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
func (c *UserController) User_() {
|
|
func (c *UserController) User_() {
|
|
// 验证登录
|
|
// 验证登录
|
|
b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
@@ -378,12 +462,95 @@ func (c *UserController) User_Get() {
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+func (c *UserController) User_v2_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
|
|
|
|
+ }
|
|
|
|
+ type User_ struct {
|
|
|
|
+ User_uuid string
|
|
|
|
+ User_name string //
|
|
|
|
+ User_power int //
|
|
|
|
+ User_telephone string // 电话
|
|
|
|
+ User_mail string // 邮箱
|
|
|
|
+ User_gender int // 性别 0未知 1男 2女
|
|
|
|
+ User_text string // 详情
|
|
|
|
+ User_rh int // 显示湿度
|
|
|
|
+ User_Power Admin.AdminPower // 权限
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ User_uuid := c.GetString("User_uuid")
|
|
|
|
+ if len(User_uuid) < 8 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "User_uuid Err!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ admin_r, err := Admin.Read_Admin_ByUuid(User_uuid)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "User_uuid Err!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Admin_r := User_{}
|
|
|
|
+
|
|
|
|
+ Admin_r.User_rh = admin_r.Admin_rh
|
|
|
|
+ Admin_r.User_uuid = admin_r.Admin_uuid
|
|
|
|
+ Admin_r.User_power = admin_r.Admin_power
|
|
|
|
+ Admin_r.User_name = admin_r.Admin_name
|
|
|
|
+ Admin_r.User_telephone = admin_r.Admin_telephone
|
|
|
|
+ Admin_r.User_mail = admin_r.Admin_mail
|
|
|
|
+ Admin_r.User_gender = admin_r.Admin_gender
|
|
|
|
+ Admin_r.User_text = admin_r.Admin_text
|
|
|
|
+
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Admin_r}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+func (c *UserController) User_v2_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_uuid string
|
|
|
|
+ User_name string //
|
|
|
|
+ User_telephone string // 电话
|
|
|
|
+ User_mail string // 邮箱
|
|
|
|
+ User_gender int // 性别 0未知 1男 2女
|
|
|
|
+ User_text string // 详情
|
|
|
|
+ User_rh int // 显示湿度
|
|
|
|
+ User_Power Admin.AdminPower // 权限
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Admin_r := User_{}
|
|
|
|
+
|
|
|
|
+ Admin_r.User_rh = admin_r.Admin_rh
|
|
|
|
+ Admin_r.User_uuid = admin_r.Admin_uuid
|
|
|
|
+ Admin_r.User_name = admin_r.Admin_name
|
|
|
|
+ Admin_r.User_telephone = admin_r.Admin_telephone
|
|
|
|
+ Admin_r.User_mail = admin_r.Admin_mail
|
|
|
|
+ Admin_r.User_gender = admin_r.Admin_gender
|
|
|
|
+ Admin_r.User_text = admin_r.Admin_text
|
|
|
|
+ Admin_r.User_Power, _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
|
+
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Admin_r}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
func (c *UserController) User_Post() {
|
|
func (c *UserController) User_Post() {
|
|
|
|
|
|
// 验证登录
|
|
// 验证登录
|
|
b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
if !b_ {
|
|
if !b_ {
|
|
- c.Ctx.Redirect(302, "Login")
|
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
|
|
|
|
+ c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
//Adminpower,_ := Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
//Adminpower,_ := Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
@@ -487,6 +654,214 @@ func (c *UserController) User_Post() {
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func (c *UserController) User_v2_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
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Admin_power, _ := c.GetInt("T_power")
|
|
|
|
+ Admin_name := c.GetString("T_name")
|
|
|
|
+ Admin_user := c.GetString("T_user")
|
|
|
|
+ Admin_pass := c.GetString("T_pass")
|
|
|
|
+ Admin_telephone := c.GetString("T_phone")
|
|
|
|
+ Admin_mail := c.GetString("T_mail")
|
|
|
|
+ Admin_text := c.GetString("T_text")
|
|
|
|
+
|
|
|
|
+ var_ := Admin.Admin{
|
|
|
|
+ Admin_uuid: uuid.NewV4().String(),
|
|
|
|
+ Admin_name: Admin_name,
|
|
|
|
+ Admin_master: admin_r.Id,
|
|
|
|
+ Admin_user: Admin_user,
|
|
|
|
+ Admin_telephone: Admin_telephone,
|
|
|
|
+ Admin_mail: Admin_mail,
|
|
|
|
+ Admin_text: Admin_text,
|
|
|
|
+ Admin_pass: Admin_pass,
|
|
|
|
+ Admin_power: Admin_power,
|
|
|
|
+ T_State: 1,
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_pass) > 0 && len(Admin_pass) < 7 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 302, Msg: "Admin_pass Err!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if admin_r.Admin_power > Admin_power {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "你没有权限 配置 权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_pass) < 8 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "密码异常!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ err, _ := Admin.Read_Admin_Admin_user(Admin_user)
|
|
|
|
+ if err == nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 302, Msg: "账户重复!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _, err = Admin.Add_Admin(var_)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var_.Admin_pass = "****************"
|
|
|
|
+
|
|
|
|
+ System.Add_UserLogs_T(admin_r.Admin_uuid, "用户管理", "添加操作", var_)
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (c *UserController) User_v2_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
|
|
|
|
+ }
|
|
|
|
+ Admin_name := c.GetString("T_name")
|
|
|
|
+ Admin_pass := c.GetString("T_pass")
|
|
|
|
+ Admin_telephone := c.GetString("T_phone")
|
|
|
|
+ Admin_mail := c.GetString("T_mail")
|
|
|
|
+ Admin_text := c.GetString("T_text")
|
|
|
|
+
|
|
|
|
+ if len(Admin_name) > 0 {
|
|
|
|
+ admin_r.Admin_name = Admin_name
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_pass) > 0 {
|
|
|
|
+ admin_r.Admin_pass = Admin_pass
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_telephone) > 0 {
|
|
|
|
+ admin_r.Admin_telephone = Admin_telephone
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_mail) > 0 {
|
|
|
|
+ admin_r.Admin_mail = Admin_mail
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_text) > 0 {
|
|
|
|
+ admin_r.Admin_text = Admin_text
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if len(Admin_pass) > 0 && len(Admin_pass) < 7 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "Admin_pass Err!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ is := Admin.Update_Admin(admin_r, "Admin_name", "Admin_pass", "Admin_telephone", "Admin_mail", "Admin_text")
|
|
|
|
+ if !is {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 204, Msg: "修改失败!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ admin_r.Admin_pass = "****************"
|
|
|
|
+
|
|
|
|
+ System.Add_UserLogs_T(admin_r.Admin_uuid, "用户管理", "操作", admin_r)
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (c *UserController) User_v2_AEdit() {
|
|
|
|
+
|
|
|
|
+ // 验证登录
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if admin_r.Admin_power > 6 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 204, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Admin_uuid := c.GetString("T_uuid")
|
|
|
|
+ Admin_user := c.GetString("T_user")
|
|
|
|
+ Admin_name := c.GetString("T_name")
|
|
|
|
+ Admin_pass := c.GetString("T_pass")
|
|
|
|
+ Admin_telephone := c.GetString("T_phone")
|
|
|
|
+ Admin_mail := c.GetString("T_mail")
|
|
|
|
+ Admin_text := c.GetString("T_text")
|
|
|
|
+ Admin_power, _ := c.GetInt("T_power")
|
|
|
|
+
|
|
|
|
+ if len(Admin_uuid) < 5 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 302, Msg: "Admin_uuid Err!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 权限超出
|
|
|
|
+ if admin_r.Admin_power > Admin_power {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "你没有权限 配置 权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ err, r_u := Admin.Read_Admin_ByAdmin_uuid(Admin_uuid)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 302, Msg: "修改失败!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 用户名重复
|
|
|
|
+ if len(Admin_user) > 0 {
|
|
|
|
+ err, y_user := Admin.Read_Admin_Admin_user(Admin_user)
|
|
|
|
+ if err == nil {
|
|
|
|
+ if y_user.Id != r_u.Id {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 302, Msg: "用户名重复!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ r_u.Admin_user = Admin_user
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if len(Admin_name) > 0 {
|
|
|
|
+ r_u.Admin_name = Admin_name
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_pass) > 0 {
|
|
|
|
+ r_u.Admin_pass = Admin_pass
|
|
|
|
+ }
|
|
|
|
+ if Admin_power > 0 {
|
|
|
|
+ r_u.Admin_power = Admin_power
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_telephone) > 0 {
|
|
|
|
+ r_u.Admin_telephone = Admin_telephone
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_mail) > 0 {
|
|
|
|
+ r_u.Admin_mail = Admin_mail
|
|
|
|
+ }
|
|
|
|
+ if len(Admin_text) > 0 {
|
|
|
|
+ r_u.Admin_text = Admin_text
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ is := Admin.Update_Admin(admin_r, "Admin_user", "Admin_name", "Admin_pass", "Admin_telephone", "Admin_mail", "Admin_text", "Admin_power")
|
|
|
|
+ if !is {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 204, Msg: "修改失败!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ r_u.Admin_pass = "****************"
|
|
|
|
+ System.Add_UserLogs_T(admin_r.Admin_uuid, "用户管理", "操作", r_u)
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
func (c *UserController) User_Del() {
|
|
func (c *UserController) User_Del() {
|
|
// 验证登录
|
|
// 验证登录
|
|
b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
@@ -494,7 +869,11 @@ func (c *UserController) User_Del() {
|
|
c.Ctx.Redirect(302, "Login")
|
|
c.Ctx.Redirect(302, "Login")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if admin_r.Admin_power > 6 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 204, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
Admin_uuid := c.GetString("Admin_uuid")
|
|
Admin_uuid := c.GetString("Admin_uuid")
|
|
if len(Admin_uuid) > 0 {
|
|
if len(Admin_uuid) > 0 {
|
|
admin_r_lod, err := Admin.Read_Admin_ByUuid(Admin_uuid)
|
|
admin_r_lod, err := Admin.Read_Admin_ByUuid(Admin_uuid)
|
|
@@ -523,6 +902,48 @@ func (c *UserController) User_Del() {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (c *UserController) V2_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
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Admin_power > 6 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 204, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Admin_uuid := c.GetString("T_uuid")
|
|
|
|
+ if len(Admin_uuid) > 0 {
|
|
|
|
+ admin_r_lod, err := Admin.Read_Admin_ByUuid(Admin_uuid)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 204, Msg: "e!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if admin_r_lod.Admin_master < admin_r.Admin_master {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "e!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ admin_r_lod.T_State = 0
|
|
|
|
+ Admin.Update_Admin(admin_r_lod, "T_State")
|
|
|
|
+ //Admin.Update_Delete_Admin_ByAdmin_uuid(Admin_uuid)
|
|
|
|
+ } else {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "e!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ System.Add_UserLogs_T(admin_r.Admin_uuid, "用户管理", "删除", Admin_uuid)
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
// 权限管理
|
|
// 权限管理
|
|
func (c *UserController) Power_html() {
|
|
func (c *UserController) Power_html() {
|
|
// 验证登录
|
|
// 验证登录
|
|
@@ -563,6 +984,56 @@ func (c *UserController) Power_html() {
|
|
c.TplName = "User/Power.html"
|
|
c.TplName = "User/Power.html"
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 权限管理
|
|
|
|
+func (c *UserController) Power_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
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Id != 1 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Admin_master != 0 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ type R_JSONS struct {
|
|
|
|
+ //必须的大写开头
|
|
|
|
+ Data []Admin.AdminPower
|
|
|
|
+ Num int64
|
|
|
|
+ Page int
|
|
|
|
+ Page_size int
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var r_jsons R_JSONS
|
|
|
|
+
|
|
|
|
+ page, _ := c.GetInt("page")
|
|
|
|
+ println(page)
|
|
|
|
+ if page < 1 {
|
|
|
|
+ page = 1
|
|
|
|
+ }
|
|
|
|
+ page_z, _ := c.GetInt("page_z")
|
|
|
|
+ if page_z < 1 {
|
|
|
|
+ page_z = conf.Page_size
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Name := c.GetString("T_name")
|
|
|
|
+
|
|
|
|
+ r_jsons.Data, r_jsons.Num = Admin.Read_Power_List_ALL(page, Name)
|
|
|
|
+ r_jsons.Page = page
|
|
|
|
+ r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
|
|
+
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
func (c *UserController) Power_() {
|
|
func (c *UserController) Power_() {
|
|
// 验证登录
|
|
// 验证登录
|
|
b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
@@ -587,6 +1058,40 @@ func (c *UserController) Power_() {
|
|
|
|
|
|
c.TplName = "User/Power-.html"
|
|
c.TplName = "User/Power-.html"
|
|
}
|
|
}
|
|
|
|
+func (c *UserController) Power_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
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Id != 1 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Admin_master != 0 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ id, _ := c.GetInt("T_id")
|
|
|
|
+
|
|
|
|
+ if id == 0 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Data, _ := Admin.Read_AdminPower_ById(id)
|
|
|
|
+
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Data}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
func (c *UserController) Power_Post() {
|
|
func (c *UserController) Power_Post() {
|
|
|
|
|
|
var err error
|
|
var err error
|
|
@@ -711,6 +1216,185 @@ func (c *UserController) Power_Del() {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (c *UserController) Power_v2_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
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Id != 1 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Admin_master != 0 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Power_name := c.GetString("Power_name")
|
|
|
|
+ Power_Administration, _ := c.GetInt("Power_Administration")
|
|
|
|
+ Power_User_r, _ := c.GetInt("Power_User_r")
|
|
|
|
+ Power_User_entry, _ := c.GetInt("Power_User_entry")
|
|
|
|
+ Power_Device_r, _ := c.GetInt("Power_Device_r")
|
|
|
|
+ Power_Device_a, _ := c.GetInt("Power_Device_a")
|
|
|
|
+ Power_Device_Parameter_e, _ := c.GetInt("Power_Device_Parameter_e")
|
|
|
|
+ Power_DeviceSensor_Parameter_e, _ := c.GetInt("Power_DeviceSensor_Parameter_e")
|
|
|
|
+ Power_Device_Bind_e, _ := c.GetInt("Power_Device_Bind_e")
|
|
|
|
+ Power_DeviceSensor_Compensate_e, _ := c.GetInt("Power_DeviceSensor_Compensate_e")
|
|
|
|
+ Power_DeviceSensor_Class, _ := c.GetInt("Power_DeviceSensor_Class")
|
|
|
|
+ Power_DataScreen_r, _ := c.GetInt("Power_DataScreen_r")
|
|
|
|
+ Logs_Sys_r, _ := c.GetInt("Logs_Sys_r")
|
|
|
|
+ Logs_User_r, _ := c.GetInt("Logs_User_r")
|
|
|
|
+
|
|
|
|
+ var_ := Admin.AdminPower{
|
|
|
|
+ Power_name: Power_name,
|
|
|
|
+ Power_Administration: Power_Administration,
|
|
|
|
+ Power_User_r: Power_User_r,
|
|
|
|
+ Power_User_entry: Power_User_entry,
|
|
|
|
+ Power_Device_r: Power_Device_r,
|
|
|
|
+ Power_Device_a: Power_Device_a,
|
|
|
|
+ Power_Device_Parameter_e: Power_Device_Parameter_e,
|
|
|
|
+ Power_DeviceSensor_Parameter_e: Power_DeviceSensor_Parameter_e,
|
|
|
|
+ Power_Device_Bind_e: Power_Device_Bind_e,
|
|
|
|
+ Power_DeviceSensor_Class: Power_DeviceSensor_Class,
|
|
|
|
+ Power_DeviceSensor_Compensate_e: Power_DeviceSensor_Compensate_e,
|
|
|
|
+ Power_DataScreen_r: Power_DataScreen_r,
|
|
|
|
+ Logs_Sys_r: Logs_Sys_r,
|
|
|
|
+ Logs_User_r: Logs_User_r,
|
|
|
|
+ T_State: 1,
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _, err := Admin.Add_AdminPower(var_)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ System.Add_UserLogs_T(admin_r.Admin_uuid, "权限管理", "权限操作", var_)
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+func (c *UserController) Power_v2_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
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Id != 1 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Admin_master != 0 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ id, _ := c.GetInt("T_id")
|
|
|
|
+
|
|
|
|
+ Power_name := c.GetString("Power_name")
|
|
|
|
+ Power_Administration, _ := c.GetInt("Power_Administration")
|
|
|
|
+ Power_User_r, _ := c.GetInt("Power_User_r")
|
|
|
|
+ Power_User_entry, _ := c.GetInt("Power_User_entry")
|
|
|
|
+ Power_Device_r, _ := c.GetInt("Power_Device_r")
|
|
|
|
+ Power_Device_a, _ := c.GetInt("Power_Device_a")
|
|
|
|
+ Power_Device_Parameter_e, _ := c.GetInt("Power_Device_Parameter_e")
|
|
|
|
+ Power_DeviceSensor_Parameter_e, _ := c.GetInt("Power_DeviceSensor_Parameter_e")
|
|
|
|
+ Power_Device_Bind_e, _ := c.GetInt("Power_Device_Bind_e")
|
|
|
|
+ Power_DeviceSensor_Compensate_e, _ := c.GetInt("Power_DeviceSensor_Compensate_e")
|
|
|
|
+ Power_DeviceSensor_Class, _ := c.GetInt("Power_DeviceSensor_Class")
|
|
|
|
+ Power_DataScreen_r, _ := c.GetInt("Power_DataScreen_r")
|
|
|
|
+ Logs_Sys_r, _ := c.GetInt("Logs_Sys_r")
|
|
|
|
+ Logs_User_r, _ := c.GetInt("Logs_User_r")
|
|
|
|
+ var_ := Admin.AdminPower{
|
|
|
|
+ Id: id,
|
|
|
|
+ Power_name: Power_name,
|
|
|
|
+ Power_Administration: Power_Administration,
|
|
|
|
+ Power_User_r: Power_User_r,
|
|
|
|
+ Power_User_entry: Power_User_entry,
|
|
|
|
+ Power_Device_r: Power_Device_r,
|
|
|
|
+ Power_Device_a: Power_Device_a,
|
|
|
|
+ Power_Device_Parameter_e: Power_Device_Parameter_e,
|
|
|
|
+ Power_DeviceSensor_Parameter_e: Power_DeviceSensor_Parameter_e,
|
|
|
|
+ Power_Device_Bind_e: Power_Device_Bind_e,
|
|
|
|
+ Power_DeviceSensor_Class: Power_DeviceSensor_Class,
|
|
|
|
+ Power_DeviceSensor_Compensate_e: Power_DeviceSensor_Compensate_e,
|
|
|
|
+ Power_DataScreen_r: Power_DataScreen_r,
|
|
|
|
+ Logs_Sys_r: Logs_Sys_r,
|
|
|
|
+ Logs_User_r: Logs_User_r,
|
|
|
|
+ T_State: 1,
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ err := Admin.Update_AdminPower_ById_Basics(var_)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 302, Msg: "修改失败!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ System.Add_UserLogs_T(admin_r.Admin_uuid, "权限管理", "权限操作", var_)
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+func (c *UserController) Power_v2_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
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Id != 1 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if admin_r.Admin_master != 0 {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ id, _ := c.GetInt("T_id")
|
|
|
|
+
|
|
|
|
+ if id > 0 {
|
|
|
|
+ admin_r_lod, err := Admin.Read_AdminPower_ById(id)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "e!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ Admin_List_ALL_AdminPower := Admin.Read_Admin_List_ALL_AdminPower(admin_r_lod.Id)
|
|
|
|
+
|
|
|
|
+ if len(Admin_List_ALL_AdminPower) > 0 {
|
|
|
|
+ S_Msg := "无法删除!【"
|
|
|
|
+ for _, v := range Admin_List_ALL_AdminPower {
|
|
|
|
+ S_Msg += v.Admin_name + ","
|
|
|
|
+ }
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 205, Msg: S_Msg + "】 属于该权限!删除这些账号后即可删除! "}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ Admin.Update_Delete_AdminPower_Byid(admin_r_lod.Id)
|
|
|
|
+ } else {
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 204, Msg: "e!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ System.Add_UserLogs(admin_r.Admin_uuid, "权限管理", "权限删除", strconv.Itoa(id))
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
|
+ c.ServeJSON()
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
// 同步面板
|
|
// 同步面板
|
|
func (c *UserController) Panel_plan_Syn() {
|
|
func (c *UserController) Panel_plan_Syn() {
|
|
// 验证登录
|
|
// 验证登录
|