本文整理匯總了Golang中github.com/blackmady/NoneCMS/app/models.Admin.Status方法的典型用法代碼示例。如果您正苦於以下問題:Golang Admin.Status方法的具體用法?Golang Admin.Status怎麽用?Golang Admin.Status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/blackmady/NoneCMS/app/models.Admin
的用法示例。
在下文中一共展示了Admin.Status方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Add
//.........這裏部分代碼省略.........
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 {
Status, err := strconv.ParseInt(status, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
admin.Status = Status
} else {
c.Flash.Error("請選擇狀態!")
c.Flash.Out["url"] = "/Admin/Add/"
return c.Redirect("/Message/")
}
if ip := c.Request.Header.Get("X-Forwarded-For"); ip != "" {
ips := strings.Split(ip, ",")
if len(ips) > 0 && ips[0] != "" {
rip := strings.Split(ips[0], ":")
admin.Lastloginip = rip[0]
}
} else {
ip := strings.Split(c.Request.RemoteAddr, ":")
if len(ip) > 0 {
if ip[0] != "[" {
admin.Lastloginip = ip[0]
}
}
}
if admin.Save() {
//******************************************
//管理員日誌
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 := "添加管理員:" + username + "|^|管理員管理"
logs.Save(admin_info, c.Controller, desc)
}
//*****************************************
c.Flash.Success("添加管理員成功!")
c.Flash.Out["url"] = "/Admin/"
return c.Redirect("/Message/")
} else {
c.Flash.Error("添加管理員失敗!")
c.Flash.Out["url"] = "/Admin/Add/"
return c.Redirect("/Message/")
}
}
}
示例2: Edit
//.........這裏部分代碼省略.........
}
var pwdconfirm string = c.Params.Get("pwdconfirm")
if len(pwdconfirm) > 0 {
if password != pwdconfirm {
c.Flash.Error("兩次輸入密碼不一致!")
c.Flash.Out["url"] = "/Admin/Edit/" + id + "/"
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/Edit/" + id + "/"
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/Edit/" + id + "/"
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/Edit/" + id + "/"
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/Edit/" + id + "/"
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)
}
admin.Status = Status
} else {
c.Flash.Error("請選擇是否啟用!")
c.Flash.Out["url"] = "/Admin/Edit/" + id + "/"
return c.Redirect("/Message/")
}
if admin.Edit(Id) {
//******************************************
//管理員日誌
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 := "編輯管理員:" + username + "|^|管理員管理"
logs.Save(admin_info, c.Controller, desc)
}
//*****************************************
c.Flash.Success("編輯管理員成功!")
c.Flash.Out["url"] = "/Admin/"
return c.Redirect("/Message/")
} else {
c.Flash.Error("編輯管理員失敗!")
c.Flash.Out["url"] = "/Admin/Edit/" + id + "/"
return c.Redirect("/Message/")
}
} else {
c.Flash.Error("編輯管理員失敗!")
c.Flash.Out["url"] = "/Admin/Edit/" + id + "/"
return c.Redirect("/Message/")
}
}
}