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


Golang User.GetOneUserById方法代碼示例

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


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

示例1: Cash

func (this *AccountController) Cash() {
	data := e.Data{Msg: "申請成功", Status: 1}
	w := this.ResponseWriter
	r := this.Request
	r.ParseForm()
	userId := r.FormValue("user")
	money, _ := strconv.ParseFloat(r.FormValue("cash"), 32)
	user := m.User{Id: userId}
	user = user.GetOneUserById()
	if user.RealName == "" { //無開戶人姓名
		data.Status = 0
		data.Msg = "真實姓名為空,請先設置真實姓名"
	}
	if data.Status == 1 && user.ABalance < money {
		data.Status = 0
		data.Msg = "提取金額有誤"
	}
	if data.Status == 1 {
		username := user.RealName
		bank := r.FormValue("bank")

		card := r.FormValue("card")
		address := r.FormValue("address")
		cash := m.Cash{Id: this.getCashId(userId), UserId: userId, UserName: username, Bank: bank, Card: card, Address: address, Money: money, BeginTime: time.Now(), Status: "申請"}
		cash.InsertCash()
		user.ABalance = user.ABalance - money
		user.UpdateABalance()
	}
	u.OutputJson(w, &data)
}
開發者ID:jjjachyty,項目名稱:ibookings,代碼行數:30,代碼來源:Account.go

示例2: Edit

func (this *UserController) Edit() {
	w := this.ResponseWriter
	r := this.Request
	data := e.TData{}

	common := CommonController{HTTP: this.HTTP}

	t := common.getTpl("User.edit.introduction.tpl", "User.edit.tpl", "User.edit.avatar.tpl", "User.edit.baseinfo.tpl", "User.edit.skills.tpl", "User.edit.skill.tpl", "User.edit.introduction.tpl")

	r.ParseForm()
	userId := r.FormValue("id")
	user := m.User{Id: userId}

	cookie := u.Cookie{HTTP: this.HTTP}
	cookie = cookie.GetCookie()

	flag := true
	if cookie.UserId == nil || userId != cookie.UserId.Value { //無登錄cookie
		flag = false
	}
	if flag {
		user = user.GetOneUserById()
		data.CurrentUser = user
		data.Data = user
		data.Flag = flag
		t.Execute(w, &data)
	} else {
		Error{HTTP: this.HTTP}.Get()
	}

}
開發者ID:jjjachyty,項目名稱:ibookings,代碼行數:31,代碼來源:User.go

示例3: Q

func (this *UserController) Q() {
	w := this.ResponseWriter
	r := this.Request
	r.ParseForm()
	parId := r.FormValue("id")

	common := CommonController{HTTP: this.HTTP}

	t := common.getTpl("UserDetail", "T.user.tpl", "Order.add.tpl")

	showuser := m.User{Id: parId}
	data := e.TData{}
	flag := false
	isCurrentUser := false
	cookie := u.Cookie{HTTP: this.HTTP}
	cookie = cookie.GetCookie()
	// log.Println("獲取cookie中的用戶名")
	// username := u.GetCookieUserName(w, r)
	// if username != "" { //如果已經登錄了
	// 	user = user.GetOneUserByName(username)
	// } else {

	// }

	log.Println(parId)
	if parId == "" {
		log.Println("url有錯誤")
	}
	showuser = showuser.GetOneUserById()
	loginuser := m.User{}
	userId := cookie.UserId //登錄用戶

	log.Println(showuser.RealName)
	if showuser.RealName != "" { //查到用戶
		if userId != nil { //查到有登錄用戶
			loginuser.Id = userId.Value
			flag = true
			if showuser.Id == loginuser.Id { //已登錄的用戶瀏覽別人的資料
				isCurrentUser = true
			}
		}
		if !isCurrentUser { //別人瀏覽
			telph := u.SubString(showuser.UserName, 0, len(showuser.UserName)-4) + "****"
			idCard := u.SubString(showuser.IDCard, 0, len(showuser.IDCard)-4) + "****"
			showuser.UserName = telph
			showuser.IDCard = idCard
		}

		data = e.TData{Data: showuser, CurrentUser: loginuser, Flag: flag}

		t.Execute(w, &data)
	}

}
開發者ID:jjjachyty,項目名稱:ibookings,代碼行數:54,代碼來源:User.go

示例4: Info

func (this *AccountController) Info() {
	w := this.ResponseWriter
	r := this.Request
	r.ParseForm()
	parId := r.FormValue("id")

	common := CommonController{HTTP: this.HTTP}

	t := common.getTpl("account", "Account.info.tpl")

	showuser := m.User{Id: parId}
	data := e.TData{}
	flag := false

	cookie := u.Cookie{HTTP: this.HTTP}
	cookie = cookie.GetCookie()
	// log.Println("獲取cookie中的用戶名")
	// username := u.GetCookieUserName(w, r)
	// if username != "" { //如果已經登錄了
	// 	user = user.GetOneUserByName(username)
	// } else {

	// }

	log.Println(parId)
	if parId == "" {
		log.Println("url有錯誤")
	}
	showuser = showuser.GetOneUserById()
	loginuser := m.User{}
	log.Println(showuser.ABalance, showuser.FBalance)
	userId := cookie.UserId //登錄用戶

	log.Println(showuser.RealName)
	if showuser.RealName != "" { //查到用戶
		if userId != nil { //查到有登錄用戶
			loginuser.Id = userId.Value
			flag = true
			if showuser.Id == loginuser.Id { //自己瀏覽自己
				data = e.TData{Data: showuser, CurrentUser: loginuser, Flag: flag}
				t.Execute(w, &data)
			}
		}

	}
}
開發者ID:jjjachyty,項目名稱:ibookings,代碼行數:46,代碼來源:Account.go


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