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


Golang models.User類代碼示例

本文整理匯總了Golang中admin/app/models.User的典型用法代碼示例。如果您正苦於以下問題:Golang User類的具體用法?Golang User怎麽用?Golang User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: Move

//移動
func (c *User) Move(user *models.User) revel.Result {

	var groupid string = c.Params.Get("groupid")
	var ids string = c.Params.Get("ids")

	data := make(map[string]string)

	if len(ids) <= 0 {
		data["status"] = "0"
		data["message"] = "請至少選擇一個!"
		return c.RenderJson(data)
	}

	if len(groupid) <= 0 {
		data["status"] = "0"
		data["message"] = "請選擇會員組!"
		return c.RenderJson(data)
	}

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

	if user.Move(Groupid, ids) {
		data["status"] = "1"
		data["message"] = "移動成功!"
		return c.RenderJson(data)
	} else {
		data["status"] = "0"
		data["message"] = "移動失敗!"
		return c.RenderJson(data)
	}
}
開發者ID:zacklin923,項目名稱:GoCMS,代碼行數:35,代碼來源:user.go

示例2: UserInfo

//個人信息
func (c *User) UserInfo(user *models.User) revel.Result {
	title := "個人信息--GoCMS管理係統"

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

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

		//內容
		user_info := user.GetById(Id)

		c.Render(title, id, user_info)
	} else {
		c.Render(title, id)
	}
	return c.RenderTemplate("User/Manage/UserInfo.html")
}
開發者ID:zacklin923,項目名稱:GoCMS,代碼行數:21,代碼來源:user.go

示例3: Index

//首頁
func (c *User) Index(user *models.User) revel.Result {
	title := "會員首頁--GoCMS管理係統"

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

	var Page int64 = 1

	if len(page) > 0 {
		Page, _ = strconv.ParseInt(page, 10, 64)
	}

	user_list, pages, where := user.GetUserList(search, Page, 10)

	//會員組
	user_group := new(models.User_Group)
	group_list := user_group.GetGroupList()

	c.Render(title, user_list, group_list, pages, where)
	return c.RenderTemplate("User/Manage/Index.html")
}
開發者ID:zacklin923,項目名稱:GoCMS,代碼行數:22,代碼來源:user.go

示例4: Unlock

//解鎖
func (c *User) Unlock(user *models.User) revel.Result {

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

	data := make(map[string]string)

	if len(ids) <= 0 {
		data["status"] = "0"
		data["message"] = "請至少選擇一個!"
		return c.RenderJson(data)
	}

	if user.Unlock(ids) {
		data["status"] = "1"
		data["message"] = "解鎖成功!"
		return c.RenderJson(data)
	} else {
		data["status"] = "0"
		data["message"] = "解鎖失敗!"
		return c.RenderJson(data)
	}
}
開發者ID:zacklin923,項目名稱:GoCMS,代碼行數:23,代碼來源:user.go

示例5: Add

//添加會員
func (c *User) Add(user *models.User) revel.Result {

	if c.Request.Method == "GET" {

		title := "添加會員--GoCMS管理係統"

		//會員組
		user_group := new(models.User_Group)
		group_list := user_group.GetGroupList()

		c.Render(title, group_list)
		return c.RenderTemplate("User/Manage/Add.html")
	} else {

		data := make(map[string]string)

		var username string = c.Params.Get("username")
		if len(username) <= 0 {
			data["status"] = "0"
			data["message"] = "請輸入用戶名!"
			return c.RenderJson(data)
		} else {
			user.Username = username
		}

		if user.HasName() {
			data["status"] = "0"
			data["message"] = "用戶名‘" + username + "’已有!"
			return c.RenderJson(data)
		}

		var email string = c.Params.Get("email")
		if len(email) <= 0 {
			data["status"] = "0"
			data["message"] = "請輸入郵箱!"
			return c.RenderJson(data)
		} else {
			user.Email = email
		}

		if user.HasEmail() {
			data["status"] = "0"
			data["message"] = "郵箱‘" + email + "’已有!"
			return c.RenderJson(data)
		}

		var password string = c.Params.Get("password")
		if len(password) <= 0 {
			data["status"] = "0"
			data["message"] = "請輸入密碼!"
			return c.RenderJson(data)
		}

		var pwdconfirm string = c.Params.Get("pwdconfirm")
		if len(pwdconfirm) <= 0 {
			data["status"] = "0"
			data["message"] = "請輸入確認密碼!"
			return c.RenderJson(data)
		} else {
			if password != pwdconfirm {
				data["status"] = "0"
				data["message"] = "兩次輸入密碼不一致!"
				return c.RenderJson(data)
			} else {
				user.Password = password
			}
		}

		var nickname string = c.Params.Get("nickname")
		if len(nickname) <= 0 {
			data["status"] = "0"
			data["message"] = "請輸入昵稱!"
			return c.RenderJson(data)
		} else {
			user.Nickname = nickname
		}

		var mobile string = c.Params.Get("mobile")
		if len(mobile) <= 0 {
			data["status"] = "0"
			data["message"] = "請輸入手機號碼!"
			return c.RenderJson(data)
		} else {
			user.Mobile = mobile
		}

		var groupid string = c.Params.Get("groupid")
		if len(groupid) <= 0 {
			data["status"] = "0"
			data["message"] = "請選擇會員組!"
			return c.RenderJson(data)
		} else {
			Groupid, err := strconv.ParseInt(groupid, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			user.Groupid = Groupid
		}
//.........這裏部分代碼省略.........
開發者ID:zacklin923,項目名稱:GoCMS,代碼行數:101,代碼來源:user.go

示例6: Edit

//編輯會員
func (c *User) Edit(user *models.User) revel.Result {

	if c.Request.Method == "GET" {

		title := "編輯會員--GoCMS管理係統"

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

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

			//內容
			user_info := user.GetById(Id)

			//會員組
			user_group := new(models.User_Group)
			group_list := user_group.GetGroupList()

			c.Render(title, id, group_list, user_info)
		} else {
			c.Render(title, id)
		}

		return c.RenderTemplate("User/Manage/Edit.html")
	} else {
		data := make(map[string]string)

		var id string = c.Params.Get("id")
		if len(id) <= 0 {
			data["status"] = "0"
			data["message"] = "參數錯誤,編輯失敗!"
			return c.RenderJson(data)
		}

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

		var email string = c.Params.Get("email")
		if len(email) <= 0 {
			data["status"] = "0"
			data["message"] = "請輸入郵箱!"
			return c.RenderJson(data)
		} else {
			user.Email = email
		}

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

		var pwdconfirm string = c.Params.Get("pwdconfirm")
		if len(pwdconfirm) > 0 {
			if password != pwdconfirm {
				data["status"] = "0"
				data["message"] = "兩次輸入密碼不一致!"
				return c.RenderJson(data)
			} else {
				user.Password = password
			}
		}

		var nickname string = c.Params.Get("nickname")
		if len(nickname) <= 0 {
			data["status"] = "0"
			data["message"] = "請輸入昵稱!"
			return c.RenderJson(data)
		} else {
			user.Nickname = nickname
		}

		var mobile string = c.Params.Get("mobile")
		if len(mobile) <= 0 {
			data["status"] = "0"
			data["message"] = "請輸入手機號碼!"
			return c.RenderJson(data)
		} else {
			user.Mobile = mobile
		}

		var groupid string = c.Params.Get("groupid")
		if len(groupid) <= 0 {
			data["status"] = "0"
			data["message"] = "請選擇會員組!"
			return c.RenderJson(data)
		} else {
			Groupid, err := strconv.ParseInt(groupid, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			user.Groupid = Groupid
		}

		var islock string = c.Params.Get("islock")
		if len(islock) <= 0 {
			data["status"] = "0"
//.........這裏部分代碼省略.........
開發者ID:zacklin923,項目名稱:GoCMS,代碼行數:101,代碼來源:user.go


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