當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Logs.Save方法代碼示例

本文整理匯總了Golang中github.com/blackmady/NoneCMS/app/models.Logs.Save方法的典型用法代碼示例。如果您正苦於以下問題:Golang Logs.Save方法的具體用法?Golang Logs.Save怎麽用?Golang Logs.Save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/blackmady/NoneCMS/app/models.Logs的用法示例。


在下文中一共展示了Logs.Save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: Add

//添加公告
func (c Announce) Add(announce *models.Announce) revel.Result {

	if c.Request.Method == "GET" {
		title := "添加公告--GoCMS管理係統"

		c.Render(title)
		return c.RenderTemplate("Module/Announce/Add.html")
	} else {
		var title string = c.Params.Get("title")
		if len(title) > 0 {
			announce.Title = title
		} else {
			c.Flash.Error("請輸入公告標題!")
			c.Flash.Out["url"] = "/Announce/Add/"
			return c.Redirect("/Message/")
		}

		var starttime string = c.Params.Get("starttime")
		if len(starttime) > 0 {
			announce.Starttime = starttime
		} else {
			c.Flash.Error("請輸入起始日期!")
			c.Flash.Out["url"] = "/Announce/Add/"
			return c.Redirect("/Message/")
		}

		var endtime string = c.Params.Get("endtime")
		if len(endtime) > 0 {
			announce.Endtime = endtime
		} else {
			c.Flash.Error("請輸入截止日期!")
			c.Flash.Out["url"] = "/Announce/Add/"
			return c.Redirect("/Message/")
		}

		var content string = c.Params.Get("content")
		if len(content) > 0 {
			announce.Content = content
		} else {
			c.Flash.Error("請輸入公告內容!")
			c.Flash.Out["url"] = "/Announce/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)
			}
			announce.Status = Status
		} else {
			c.Flash.Error("請選擇是否啟用!")
			c.Flash.Out["url"] = "/Announce/Add/"
			return c.Redirect("/Message/")
		}

		if announce.Save() {

			//******************************************
			//管理員日誌
			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 := "添加公告:" + title
				logs.Save(admin_info, c.Controller, desc)
			}
			//*****************************************

			c.Flash.Success("添加公告成功!")
			c.Flash.Out["url"] = "/Announce/"
			return c.Redirect("/Message/")
		} else {
			c.Flash.Error("添加公告失敗!")
			c.Flash.Out["url"] = "/Announce/Add/"
			return c.Redirect("/Message/")
		}
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:89,代碼來源:announce.go

示例7: 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

示例8: 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/")
		}
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:101,代碼來源:admin.go

示例9: 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/")
		}

	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:101,代碼來源:admin.go

示例10: 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

示例11: EditInfo

//個人信息
func (c *User) EditInfo(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/EditInfo.html")
	} else {

		var realname string = c.Params.Get("realname")
		if len(realname) > 0 {
			admin.Realname = realname
		} else {
			c.Flash.Error("請輸入真實姓名!")
			c.Flash.Out["url"] = "/EditInfo/"
			return c.Redirect("/Message/")
		}

		var email string = c.Params.Get("email")
		if len(email) > 0 {
			admin.Email = email
		} else {
			c.Flash.Error("請輸入電子郵件!")
			c.Flash.Out["url"] = "/EditInfo/"
			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"] = "/EditInfo/"
			return c.Redirect("/Message/")
		}

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

			if admin.EditInfo(UserID) {

				//******************************************
				//管理員日誌
				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)

					c.Session["Lang"] = admin_info.Lang

					logs := new(models.Logs)
					desc := "個人設置|^|個人信息"
					logs.Save(admin_info, c.Controller, desc)
				}

				if LANG, ok := c.Session["Lang"]; ok {
					//設置語言
					c.Request.Locale = LANG
				} else {
					//設置默認語言
					c.Request.Locale = "zh"
				}

				c.Flash.Success(c.Message("operation_success"))
				c.Flash.Out["url"] = "/EditInfo/"
				return c.Redirect("/Message/")
			} else {
				c.Flash.Error(c.Message("operation_failure"))
				c.Flash.Out["url"] = "/EditInfo/"
				return c.Redirect("/Message/")
			}
		} else {
			c.Flash.Error(c.Message("not_login"))
			c.Flash.Out["url"] = "/"
			return c.Redirect("/Message/")
		}
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:96,代碼來源:user.go

示例12: Login


//.........這裏部分代碼省略.........
			//設置默認語言
			c.Request.Locale = "zh"
		}

		if !captcha.VerifyString(captchaId, verify) {
			data["status"] = "0"
			data["url"] = "/"
			data["message"] = c.Message("verification_code")
			return c.RenderJson(data)
		}

		if len(username) <= 0 {
			data["status"] = "0"
			data["url"] = "/"
			data["message"] = c.Message("login_user_name")
			return c.RenderJson(data)
		}

		if len(password) <= 0 {
			data["status"] = "0"
			data["url"] = "/"
			data["message"] = c.Message("login_password")
			return c.RenderJson(data)
		}

		if len(verify) <= 0 {
			data["status"] = "0"
			data["url"] = "/"
			data["message"] = c.Message("login_verification_code")
			return c.RenderJson(data)
		}

		admin_info := admin.GetByName(username)

		if admin_info.Id <= 0 {
			data["status"] = "0"
			data["url"] = "/"
			data["message"] = c.Message("admin_username_error")
		} else if admin_info.Status == 0 && admin_info.Id != 1 {
			data["status"] = "0"
			data["url"] = "/"
			data["message"] = c.Message("admin_forbid_login")
		} else if admin_info.Role.Status == 0 && admin_info.Id != 1 {
			data["status"] = "0"
			data["url"] = "/"
			data["message"] = c.Message("admin_forbid_role_login")
		} else if username == admin_info.Username && utils.Md5(password) == admin_info.Password {

			/*
			* %% 印出百分比符號,不轉換。
			* %c 整數轉成對應的 ASCII 字元。
			* %d 整數轉成十進位。
			* %f 倍精確度數字轉成浮點數。
			* %o 整數轉成八進位。
			* %s 整數轉成字符串。
			* %x 整數轉成小寫十六進位。
			* %X 整數轉成大寫十六進位
			 */
			c.Session["UserID"] = fmt.Sprintf("%d", admin_info.Id)
			c.Session["Lang"] = admin_info.Lang

			c.Flash.Success(c.Message("login_success"))
			c.Flash.Out["url"] = "/"

			//更新登陸時間
			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]
					}
				}
			}
			admin.UpdateLoginTime(admin_info.Id)

			//******************************************
			//管理員日誌
			logs := new(models.Logs)
			desc := "登陸用戶名:" + admin_info.Username + "|^|登陸係統!|^|登陸ID:" + fmt.Sprintf("%d", admin_info.Id)
			logs.Save(admin_info, c.Controller, desc)
			//*****************************************

			data["status"] = "1"
			data["url"] = "/Message/"
			data["message"] = c.Message("login_success")
		} else {
			data["status"] = "0"
			data["url"] = "/"
			data["message"] = c.Message("login_password_error")
		}

		return c.RenderJson(data)
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:101,代碼來源:user.go

示例13: Add


//.........這裏部分代碼省略.........
		}

		var enname string = c.Params.Get("enname")
		if len(enname) > 0 {
			category.Enname = enname
		} else {
			c.Flash.Error("請輸入英文欄目名稱!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		//欄目地址
		var url string = c.Params.Get("url")
		if len(url) > 0 {
			category.Url = url
		} else {
			c.Flash.Error("請輸入欄目地址!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		//描述
		var desc string = c.Params.Get("desc")
		if len(desc) > 0 {
			category.Desc = desc
		} else {
			c.Flash.Error("請輸入描述!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		//是否在導航顯示
		var ismenu string = c.Params.Get("ismenu")
		if len(ismenu) > 0 {
			IsMenu, err := strconv.ParseInt(ismenu, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			category.Ismenu = IsMenu
		} else {
			c.Flash.Error("請選擇是否在導航顯示!")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}

		Setting := make(map[string]interface{})

		//欄目生成Html
		var ishtml string = c.Params.Get("ishtml")
		Setting["ishtml"] = ishtml

		var content_ishtml string = c.Params.Get("content_ishtml")
		Setting["content_ishtml"] = content_ishtml

		var meta_title string = c.Params.Get("meta_title")
		Setting["meta_title"] = meta_title

		var meta_keywords string = c.Params.Get("meta_keywords")
		Setting["meta_keywords"] = meta_keywords

		var meta_desc string = c.Params.Get("meta_desc")
		Setting["meta_desc"] = meta_desc

		//欄目設置
		Setting_Text, err := json.Marshal(Setting)
		if err != nil {
			revel.WARN.Println(err)
		}
		category.SettingText = Setting
		category.Setting = string(Setting_Text)

		if category.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 := "添加欄目:" + name + "|^|欄目管理"
				logs.Save(admin_info, c.Controller, desc)
			}

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

			c.Flash.Success("添加欄目成功")
			c.Flash.Out["url"] = "/Category/"
			return c.Redirect("/Message/")
		} else {
			c.Flash.Error("添加欄目失敗")
			c.Flash.Out["url"] = "/Category/Add/"
			return c.Redirect("/Message/")
		}
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:101,代碼來源:category.go

示例14: Add


//.........這裏部分代碼省略.........
			config_file = strings.Replace(config_file, "/", separator, -1)
			config_conf, _ := config.ReadDefault(config_file)

			//上傳文件目錄
			upload_dir, _ := config_conf.String("upload", "upload.dir")
			//允許上傳的後綴名
			filesuffix, _ := config_conf.String("upload", "upload.filesuffix")

			//文件類型檢測
			if !strings.Contains(filesuffix, path.Ext(header.Filename)) {
				c.Flash.Error("文件隻支持圖片!")
				c.Flash.Out["url"] = "/Copyfrom/Add/"
				return c.Redirect("/Message/")
			}

			//文件保存目錄
			web_save_path := fmt.Sprintf("/%s/copyfrom/%s", upload_dir, time.Now().Format("2006/01/02/"))
			save_path := fmt.Sprintf("%s/www/%s/copyfrom/%s", basepath, upload_dir, time.Now().Format("2006/01/02/"))
			//字符串替換 /替換為係統分隔符
			save_path = strings.Replace(save_path, "/", separator, -1)

			//新文件名
			rand.Seed(time.Now().UnixNano())
			rand_num := rand.Intn(99999)
			new_file_name := time.Now().Format("20060102150404") + strconv.Itoa(rand_num) + path.Ext(header.Filename)

			//創建目錄
			error := os.MkdirAll(save_path, os.ModePerm)
			if error != nil {
				c.Flash.Error(error.Error())
				c.Flash.Out["url"] = "/Copyfrom/Add/"
				return c.Redirect("/Message/")
			}

			//保存文件
			file_dir := save_path + new_file_name
			save_url := web_save_path + new_file_name

			e := ioutil.WriteFile(file_dir, fileData, os.ModePerm)
			if e != nil {
				c.Flash.Error(e.Error())
				c.Flash.Out["url"] = "/Copyfrom/Add/"
				return c.Redirect("/Message/")
			}

			//來源logo
			copyfrom.Thumb = save_url
		}

		//來源名稱
		var sitename string = c.Params.Get("sitename")
		if len(sitename) > 0 {
			copyfrom.Sitename = sitename
		} else {
			c.Flash.Error("請輸入來源名稱!")
			c.Flash.Out["url"] = "/Copyfrom/Add/"
			return c.Redirect("/Message/")
		}

		//來源鏈接
		var siteurl string = c.Params.Get("siteurl")
		if len(siteurl) > 0 {
			copyfrom.Siteurl = siteurl
		} else {
			c.Flash.Error("請輸入來源鏈接!")
			c.Flash.Out["url"] = "/Copyfrom/Add/"
			return c.Redirect("/Message/")
		}

		if copyfrom.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 := "添加來源:" + sitename + "|^|來源管理"
				logs.Save(admin_info, c.Controller, desc)
			}

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

			c.Flash.Success("添加來源成功!")
			c.Flash.Out["url"] = "/Copyfrom/"
			return c.Redirect("/Message/")
		} else {
			c.Flash.Error("添加來源失敗")
			c.Flash.Out["url"] = "/Copyfrom/Add/"
			return c.Redirect("/Message/")
		}

	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:101,代碼來源:copyfrom.go

示例15: Add


//.........這裏部分代碼省略.........

		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)
			}
			menu.Pid = Pid
		} else {
			c.Flash.Error("請選擇父菜單!")
			c.Flash.Out["url"] = "/Menu/Add/"
			return c.Redirect("/Message/")
		}

		var name string = c.Params.Get("name")
		if len(name) > 0 {
			menu.Name = name
		} else {
			c.Flash.Error("請輸入中文語言名稱!")
			c.Flash.Out["url"] = "/Menu/Add/"
			return c.Redirect("/Message/")
		}

		var enname string = c.Params.Get("enname")
		if len(enname) > 0 {
			menu.Enname = enname
		} else {
			c.Flash.Error("請輸入英文語言名稱!")
			c.Flash.Out["url"] = "/Menu/Add/"
			return c.Redirect("/Message/")
		}

		var url string = c.Params.Get("url")
		if len(url) > 0 {
			menu.Url = url
		} else {
			c.Flash.Error("請輸入菜單地址!")
			c.Flash.Out["url"] = "/Menu/Add/"
			return c.Redirect("/Message/")
		}

		var order string = c.Params.Get("order")
		if len(order) > 0 {
			Order, err := strconv.ParseInt(order, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			menu.Order = Order
		} else {
			c.Flash.Error("請輸入排序!")
			c.Flash.Out["url"] = "/Menu/Add/"
			return c.Redirect("/Message/")
		}

		var data string = c.Params.Get("data")
		menu.Data = data

		var display string = c.Params.Get("display")
		if len(display) > 0 {
			Display, err := strconv.ParseInt(display, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			menu.Display = Display
		} else {
			c.Flash.Error("請選擇是否顯示菜單!")
			c.Flash.Out["url"] = "/Menu/Add/"
			return c.Redirect("/Message/")
		}

		if menu.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 := "添加菜單:" + name + "|^|菜單管理"
				logs.Save(admin_info, c.Controller, desc)
			}

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

			c.Flash.Success("添加菜單成功")
			c.Flash.Out["url"] = "/Menu/"
			return c.Redirect("/Message/")
		} else {
			c.Flash.Error("添加菜單失敗")
			c.Flash.Out["url"] = "/Menu/Add/"
			return c.Redirect("/Message/")
		}
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:101,代碼來源:menu.go


注:本文中的github.com/blackmady/NoneCMS/app/models.Logs.Save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。