• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang models.Admin类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/blackmady/NoneCMS/app/models.Admin的典型用法代码示例。如果您正苦于以下问题:Golang Admin类的具体用法?Golang Admin怎么用?Golang Admin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Admin类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetPanel

//获取快捷方式
func (c *Ajax) GetPanel(admin_panel *models.Admin_Panel) revel.Result {
	if UserID, ok := c.Session["UserID"]; ok {

		var mid string = c.Params.Get("mid")

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		Mid, err := strconv.ParseInt(mid, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		//获取登陆用户信息
		admin := new(models.Admin)
		admin_info := admin.GetById(UserID)

		panel_info := admin_panel.GetByMid(Mid, admin_info)

		if panel_info.Id > 0 {
			Html := "<span><a target='right' href='/" + panel_info.Url + "/'>" + panel_info.Name + "</a><a class='panel-delete' href='javascript:delete_panel();'></a></span>"
			return c.RenderText(Html)
		} else {
			Html := ""
			return c.RenderText(Html)
		}

	} else {
		Html := "<span><a href='javascript:;'>未登陆</a></span>"
		return c.RenderText(Html)
	}
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:35,代码来源:ajax.go


示例2: Pos

//当前位置
func (c *Ajax) Pos(menu *models.Menu) revel.Result {
	var id string = c.Params.Get("id")

	Id, err := strconv.ParseInt(id, 10, 64)
	if err != nil {
		revel.WARN.Println(err)
	}

	if UserID, ok := c.Session["UserID"]; ok {

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		//获取登陆用户信息
		admin := new(models.Admin)
		admin_info := admin.GetById(UserID)

		menu_str := menu.GetPos(Id, admin_info)
		return c.RenderText(menu_str)
	} else {
		return c.RenderText("")
	}
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:26,代码来源:ajax.go


示例3: ScreenUnlock

//解锁
func (c *Ajax) ScreenUnlock(admin *models.Admin) revel.Result {
	var lock_password string = c.Params.Get("lock_password")

	if lock_password == "" || len(lock_password) <= 0 {
		return c.RenderText("2")
	}

	if UserID, ok := c.Session["UserID"]; ok {

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		admin_info := admin.GetById(UserID)

		if admin_info.Password != utils.Md5(lock_password) {
			return c.RenderText("3")
		} else {
			c.Session["lock_screen"] = "0"
			return c.RenderText("1")
		}
	} else {
		return c.RenderText("4")
	}
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:27,代码来源:ajax.go


示例4: Logout

//退出登陆
func (c *User) Logout(admin *models.Admin) revel.Result {

	if UserID, ok := c.Session["UserID"]; ok {

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		admin_info := admin.GetById(UserID)

		//******************************************
		//管理员日志
		logs := new(models.Logs)
		desc := "登陆用户名:" + admin_info.Username + "|^|退出系统!|^|登陆ID:" + fmt.Sprintf("%d", admin_info.Id)
		logs.Save(admin_info, c.Controller, desc)
		//*****************************************

		for k := range c.Session {
			if k != "Lang" {
				delete(c.Session, k)
			}
		}
	}

	c.Flash.Success("安全退出")
	c.Flash.Out["url"] = "/User/Login/"
	return c.Redirect("/Message/")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:30,代码来源:user.go


示例5: CheckLogin

//检测登陆
func CheckLogin(c *revel.Controller) revel.Result {

	//登陆页面,CSS, JS, Ajax, 验证码页面 都不进行登陆验证
	if c.Name == "User" && c.MethodName == "Login" || c.Name == "Ajax" || c.Name == "Static" || c.Name == "Captcha" || c.Name == "Kindeditor" {

		if LANG, ok := c.Session["Lang"]; ok {
			//设置语言
			c.RenderArgs["currentLocale"] = LANG
		} else {
			//设置默认语言
			c.RenderArgs["currentLocale"] = "zh"
		}

		return nil
	} else {

		UserID := utils.GetSession("UserID", c.Session)

		if len(UserID) > 0 {
			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
				return c.Redirect("/Login/")
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)
			if admin_info.Id <= 0 {
				return c.Redirect("/Login/")
			}

			//控制器
			c.RenderArgs["Controller"] = c.Name
			//动作
			c.RenderArgs["action"] = c.Action
			//模型
			c.RenderArgs["Model"] = c.MethodName

			//登陆信息
			c.RenderArgs["admin_info"] = admin_info

			//设置语言
			c.RenderArgs["currentLocale"] = admin_info.Lang
		} else {

			//控制器
			c.RenderArgs["Controller"] = c.Name
			//动作
			c.RenderArgs["action"] = c.Action
			//模型
			c.RenderArgs["Model"] = c.MethodName

			return c.Redirect("/Login/")
		}
	}

	return nil
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:59,代码来源:init.go


示例6: SetStatus

//设置状态
func (c Role) SetStatus(role *models.Role) revel.Result {
	var id string = c.Params.Get("id")
	var status string = c.Params.Get("status")

	data := make(map[string]string)

	if len(id) > 0 && len(status) > 0 {
		Id, err := strconv.ParseInt(id, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		Status, err := strconv.ParseInt(status, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		role.Status = Status

		if role.SetStatus(Id) {

			//******************************************
			//管理员日志
			if UserID, ok := c.Session["UserID"]; ok {
				UserID, err := strconv.ParseInt(UserID, 10, 64)
				if err != nil {
					revel.WARN.Println(err)
				}

				admin := new(models.Admin)
				admin_info := admin.GetById(UserID)

				logs := new(models.Logs)
				if Status == 1 {
					desc := "角色管理|^|设置状态|^|状态:启用"
					logs.Save(admin_info, c.Controller, desc)
				} else {
					desc := "角色管理|^|设置状态|^|状态:锁定"
					logs.Save(admin_info, c.Controller, desc)
				}
			}
			//*****************************************

			data["status"] = "1"
			data["message"] = "设置成功!"
			return c.RenderJson(data)
		} else {
			data["status"] = "0"
			data["message"] = "设置失败!"
			return c.RenderJson(data)
		}
	} else {
		data["status"] = "0"
		data["message"] = "设置失败!"
		return c.RenderJson(data)
	}
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:58,代码来源:role.go


示例7: Delete

//删除公告
func (c Announce) Delete(announce *models.Announce) revel.Result {

	var id string = c.Params.Get("id")

	data := make(map[string]string)

	if len(id) > 0 {
		Id, err := strconv.ParseInt(id, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		if announce.DelByID(Id) {

			//******************************************
			//管理员日志
			UserID := utils.GetSession("UserID", c.Session)
			if len(UserID) > 0 {
				UserID, err := strconv.ParseInt(UserID, 10, 64)
				if err != nil {
					revel.WARN.Println(err)
				}

				admin := new(models.Admin)
				admin_info := admin.GetById(UserID)

				logs := new(models.Logs)
				desc := "删除公告|^|ID:" + id
				logs.Save(admin_info, c.Controller, desc)
			}
			//*****************************************

			data["status"] = "1"
			data["message"] = "删除成功!"
			return c.RenderJson(data)
		} else {
			data["status"] = "0"
			data["message"] = "删除失败!"
			return c.RenderJson(data)
		}
	} else {
		data["status"] = "0"
		data["message"] = "删除失败!"
		return c.RenderJson(data)
	}
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:47,代码来源:announce.go


示例8: Index

func (c Test) Index(admin *models.Admin) revel.Result {
	title := "测试--GoCMS管理系统"

	if UserID, ok := c.Session["UserID"]; ok {

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		admin_info := admin.GetById(UserID)

		admin_panel := new(models.Admin_Panel)
		admin_panel.IsAdd(18, admin_info)
	}

	c.Render(title)
	return c.RenderTemplate("Public/Test.html")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:19,代码来源:test.go


示例9: Delete

//删除栏目
func (c Category) Delete(category *models.Category) revel.Result {
	var id string = c.Params.Get("id")

	data := make(map[string]string)

	if len(id) <= 0 {
		data["status"] = "0"
		data["message"] = "参数错误!"
	}

	Id, err := strconv.ParseInt(id, 10, 64)
	if err != nil {
		revel.WARN.Println(err)
	}

	if category.DelByID(Id) {

		//******************************************
		//管理员日志
		if UserID, ok := c.Session["UserID"]; ok {
			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)

			logs := new(models.Logs)
			desc := "删除栏目|^|ID:" + id
			logs.Save(admin_info, c.Controller, desc)
		}
		//*****************************************

		data["status"] = "1"
		data["message"] = "删除成功!"
	} else {
		data["status"] = "0"
		data["message"] = "删除失败!"
	}

	return c.RenderJson(data)
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:44,代码来源:category.go


示例10: Index

//首页
func (c Menu) Index(menu *models.Menu) revel.Result {
	title := "菜单管理--GoCMS管理系统"

	if UserID, ok := c.Session["UserID"]; ok {

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		admin := new(models.Admin)
		admin_info := admin.GetById(UserID)

		menus := menu.GetMenuHtml(admin_info)

		c.Render(title, menus)
	} else {
		c.Render(title)
	}

	return c.RenderTemplate("Setting/Menu/Index.html")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:22,代码来源:menu.go


示例11: DelPanel

//删除快捷方式
func (c *Ajax) DelPanel(admin_panel *models.Admin_Panel) revel.Result {
	if UserID, ok := c.Session["UserID"]; ok {
		var mid string = c.Params.Get("mid")

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		Mid, err := strconv.ParseInt(mid, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		//获取登陆用户信息
		admin := new(models.Admin)
		admin_info := admin.GetById(UserID)

		is_True := admin_panel.DelPanel(Mid, admin_info)

		data := make(map[string]string)

		if is_True {
			data["status"] = "0"
			data["message"] = "取消成功!"
			return c.RenderJson(data)
		} else {
			data["status"] = "2"
			data["message"] = "取消失败!"
			return c.RenderJson(data)
		}
	} else {
		data := make(map[string]string)
		data["status"] = "1"
		data["message"] = "未登陆!"
		return c.RenderJson(data)
	}
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:39,代码来源:ajax.go


示例12: Index

func (c Category) Index(category *models.Category) revel.Result {
	title := "栏目管理--GoCMS管理系统"

	UserID := utils.GetSession("UserID", c.Session)

	if len(UserID) > 0 {

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		admin := new(models.Admin)
		admin_info := admin.GetById(UserID)

		categorys := category.GetCateGoryHtml(admin_info)

		c.Render(title, categorys)
	} else {
		c.Render(title)
	}

	return c.RenderTemplate("Content/Category/Index.html")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:23,代码来源:category.go


示例13: Member

//成员管理
func (c Role) Member(role *models.Role) revel.Result {
	title := "成员管理--GoCMS管理系统"

	var id string = c.Params.Get("id")
	var page string = c.Params.Get("page")

	if len(id) > 0 {
		Id, err := strconv.ParseInt(id, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		where := make(map[string]string)

		admin := new(models.Admin)

		if len(page) > 0 {
			Page, err := strconv.ParseInt(page, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin_list, pages := admin.GetByAll(Id, where, Page, 10)

			c.Render(title, admin_list, pages)
		} else {
			admin_list, pages := admin.GetByAll(Id, where, 1, 10)

			c.Render(title, admin_list, pages)
		}

	} else {
		c.Render(title)
	}

	return c.RenderTemplate("Setting/Role/Member.html")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:38,代码来源:role.go


示例14: DelAll

//清空日志
func (c Logs) DelAll(logs *models.Logs) revel.Result {

	data := make(map[string]string)

	IsDel := logs.DelAll()

	if IsDel {

		//******************************************
		//管理员日志
		if UserID, ok := c.Session["UserID"]; ok {
			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)

			logs := new(models.Logs)
			desc := "清空日志|^|日志管理"
			logs.Save(admin_info, c.Controller, desc)
		}

		//*****************************************

		data["status"] = "1"
		data["url"] = "/Message/"
		data["message"] = "清空日志完成!"
		return c.RenderJson(data)
	} else {
		data["status"] = "0"
		data["url"] = "/Message/"
		data["message"] = "清空日志失败!"
		return c.RenderJson(data)
	}
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:38,代码来源:logs.go


示例15: Index

//首页
func (c Admin) Index(admin *models.Admin) revel.Result {
	title := "管理员管理--GoCMS管理系统"

	var page string = c.Params.Get("page")

	where := make(map[string]string)

	if len(page) > 0 {
		Page, err := strconv.ParseInt(page, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		admin_list, pages := admin.GetByAll(0, where, Page, 10)

		c.Render(title, admin_list, pages)
	} else {
		admin_list, pages := admin.GetByAll(0, where, 1, 10)

		c.Render(title, admin_list, pages)
	}

	return c.RenderTemplate("Setting/Admin/Index.html")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:25,代码来源:admin.go


示例16: Index

//首页
func (c App) Index(admin *models.Admin) revel.Result {
	title := "首页--GoCMS管理系统"

	UserID := utils.GetSession("UserID", c.Session)

	if len(UserID) > 0 {
		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		admin_info := admin.GetById(UserID)
		if admin_info.Id <= 0 {
			return c.Redirect("/User/Login")
		}

		//导航菜单
		menu := new(models.Menu)
		c.RenderArgs["menus"] = menu.GetAdminMenu(0, admin_info)

		//登陆用户信息
		c.RenderArgs["admin_info"] = admin_info

		//是否锁屏
		if c.Session["lock_screen"] == "" || c.Session["lock_screen"] == "0" {
			c.RenderArgs["lock_screen"] = "0"
		} else {
			c.RenderArgs["lock_screen"] = "1"
		}
	} else {
		return c.Redirect("/User/Login/")
	}

	c.Render(title)
	return c.RenderTemplate("App/Index.html")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:37,代码来源:app.go


示例17: Left

//左侧导航菜单
func (c *User) Left(menu *models.Menu) revel.Result {

	title := "左侧导航--GoCMS管理系统"

	var pid string = c.Params.Get("pid")

	if len(pid) > 0 {
		Pid, err := strconv.ParseInt(pid, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		if UserID, ok := c.Session["UserID"]; ok {

			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)

			//获取左侧导航菜单
			left_menu := menu.GetLeftMenuHtml(Pid, admin_info)

			c.Render(title, left_menu)
		} else {
			c.Render(title)
		}
	} else {
		//获取左侧导航菜单
		//默认获取 首页
		if UserID, ok := c.Session["UserID"]; ok {

			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)

			//获取左侧导航菜单
			left_menu := menu.GetLeftMenuHtml(1, admin_info)

			c.Render(title, left_menu)
		} else {
			c.Render(title)
		}
	}
	return c.RenderTemplate("Public/left.html")
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:53,代码来源:user.go


示例18: Add

//添加角色
func (c Role) Add(role *models.Role) revel.Result {

	if c.Request.Method == "GET" {
		title := "添加角色--GoCMS管理系统"

		if UserID, ok := c.Session["UserID"]; ok {

			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)

			menu := new(models.Menu)
			tree := menu.GetMenuTree("", admin_info)

			c.Render(title, tree)
		} else {
			c.Render(title)
		}

		return c.RenderTemplate("Setting/Role/Add.html")
	} else {

		var rolename string = c.Params.Get("rolename")
		if len(rolename) > 0 {
			role.Rolename = rolename
		} else {
			c.Flash.Error("请输入角色名称!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		var desc string = c.Params.Get("desc")
		if len(desc) > 0 {
			role.Desc = desc
		} else {
			c.Flash.Error("请输入角色描述!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		var data string = c.Params.Get("data")
		if len(data) > 0 {
			role.Data = data
		} else {
			c.Flash.Error("请选择所属权限!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		var status string = c.Params.Get("status")
		if len(status) > 0 {
			Status, err := strconv.ParseInt(status, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			role.Status = Status
		} else {
			c.Flash.Error("请选择是否启用!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		if role.Save() {

			//******************************************
			//管理员日志
			if UserID, ok := c.Session["UserID"]; ok {
				UserID, err := strconv.ParseInt(UserID, 10, 64)
				if err != nil {
					revel.WARN.Println(err)
				}

				admin := new(models.Admin)
				admin_info := admin.GetById(UserID)

				logs := new(models.Logs)
				desc := "添加角色:" + rolename + "|^|角色管理"
				logs.Save(admin_info, c.Controller, desc)
			}
			//*****************************************

			c.Flash.Success("添加角色成功")
			c.Flash.Out["url"] = "/Role/"
			return c.Redirect("/Message/")
		} else {
			c.Flash.Error("添加角色失败")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}
	}
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:96,代码来源:role.go


示例19: Add

//添加管理员
func (c Admin) Add(admin *models.Admin) revel.Result {

	if c.Request.Method == "GET" {
		title := "添加管理员--GoCMS管理系统"

		role := new(models.Role)
		role_list := role.GetRoleList()

		c.Render(title, role_list)
		return c.RenderTemplate("Setting/Admin/Add.html")
	} else {

		var username string = c.Params.Get("username")
		if len(username) > 0 {
			admin.Username = username
		} else {
			c.Flash.Error("请输入用户名!")
			c.Flash.Out["url"] = "/Admin/Add/"
			return c.Redirect("/Message/")
		}

		if admin.HasName() {
			c.Flash.Error("用户名“" + username + "”已存在!")
			c.Flash.Out["url"] = "/Admin/Add/"
			return c.Redirect("/Message/")
		}

		var password string = c.Params.Get("password")
		if len(password) > 0 {
			admin.Password = password
		} else {
			c.Flash.Error("请输入密码!")
			c.Flash.Out["url"] = "/Admin/Add/"
			return c.Redirect("/Message/")
		}

		var pwdconfirm string = c.Params.Get("pwdconfirm")
		if len(pwdconfirm) > 0 {
			if password != pwdconfirm {
				c.Flash.Error("两次输入密码不一致!")
				c.Flash.Out["url"] = "/Admin/Add/"
				return c.Redirect("/Message/")
			}
		} else {
			c.Flash.Error("请输入确认密码!")
			c.Flash.Out["url"] = "/Admin/Add/"
			return c.Redirect("/Message/")
		}

		var email string = c.Params.Get("email")
		if len(email) > 0 {
			admin.Email = email
		} else {
			c.Flash.Error("请输入E-mail!")
			c.Flash.Out["url"] = "/Admin/Add/"
			return c.Redirect("/Message/")
		}

		if admin.HasEmail() {
			c.Flash.Error("E-mail已存在!")
			c.Flash.Out["url"] = "/Admin/Add/"
			return c.Redirect("/Message/")
		}

		var realname string = c.Params.Get("realname")
		if len(realname) > 0 {
			admin.Realname = realname
		} else {
			c.Flash.Error("请输入真实姓名!")
			c.Flash.Out["url"] = "/Admin/Add/"
			return c.Redirect("/Message/")
		}

		var lang string = c.Params.Get("lang")
		if len(lang) > 0 {
			admin.Lang = lang
		} else {
			c.Flash.Error("请选择语言!")
			c.Flash.Out["url"] = "/Admin/Add/"
			return c.Redirect("/Message/")
		}

		var roleid string = c.Params.Get("roleid")
		if len(roleid) > 0 {

			Roleid, err := strconv.ParseInt(roleid, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin.Roleid = Roleid
		} else {
			c.Flash.Error("请选择所属角色!")
			c.Flash.Out["url"] = "/Admin/Add/"
			return c.Redirect("/Message/")
		}

		var status string = c.Params.Get("status")
		if len(status) > 0 {
//.........这里部分代码省略.........
开发者ID:blackmady,项目名称:GoCMS,代码行数:101,代码来源:admin.go


示例20: EditPwd

//修改密码
func (c *User) EditPwd(admin *models.Admin) revel.Result {
	if c.Request.Method == "GET" {
		title := "修改密码--GoCMS管理系统"

		if UserID, ok := c.Session["UserID"]; ok {
			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin_info := admin.GetById(UserID)

			c.Render(title, admin_info)
		} else {
			c.Render(title)
		}

		return c.RenderTemplate("User/EditPwd.html")
	} else {

		if UserID, ok := c.Session["UserID"]; ok {

			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin_info := admin.GetById(UserID)

			var old_password string = c.Params.Get("old_password")
			if len(old_password) > 0 {
				if admin_info.Password != utils.Md5(old_password) {
					c.Flash.Error("旧密码不正确!")
					c.Flash.Out["url"] = "/EditPwd/"
					return c.Redirect("/Message/")
				}
			} else {
				return c.Redirect("/User/EditPwd/")
			}

			var new_password string = c.Params.Get("new_password")
			if len(new_password) > 0 {

			} else {
				c.Flash.Error("新密码不能为空!")
				c.Flash.Out["url"] = "/EditPwd/"
				return c.Redirect("/Message/")
			}

			var new_pwdconfirm string = c.Params.Get("new_pwdconfirm")
			if len(new_pwdconfirm) > 0 {
				if new_pwdconfirm != new_password {
					c.Flash.Error("两次输入密码入不一致!")
					c.Flash.Out["url"] = "/EditPwd/"
					return c.Redirect("/Message/")
				} else {
					admin.Password = new_pwdconfirm
				}
			} else {
				c.Flash.Error("请输入重复新密码!")
				c.Flash.Out["url"] = "/EditPwd/"
				return c.Redirect("/Message/")
			}

			if admin.EditPwd(UserID) {

				//******************************************
				//管理员日志
				logs := new(models.Logs)
				desc := "个人设置|^|修改密码"
				logs.Save(admin_info, c.Controller, desc)
				//*****************************************

				c.Flash.Success("修改成功!")
				c.Flash.Out["url"] = "/EditPwd/"
				return c.Redirect("/Message/")
			} else {
				c.Flash.Error("修改失败!")
				c.Flash.Out["url"] = "/EditPwd/"
				return c.Redirect("/Message/")
			}
		} else {
			c.Flash.Error("未登陆,请先登陆!")
			c.Flash.Out["url"] = "/"
			return c.Redirect("/Message/")
		}
	}
}
开发者ID:blackmady,项目名称:GoCMS,代码行数:89,代码来源:user.go



注:本文中的github.com/blackmady/NoneCMS/app/models.Admin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang models.Article类代码示例发布时间:2022-05-24
下一篇:
Golang logp.Info函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap