本文整理匯總了Golang中ibookings/models.User.InsertUser方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.InsertUser方法的具體用法?Golang User.InsertUser怎麽用?Golang User.InsertUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ibookings/models.User
的用法示例。
在下文中一共展示了User.InsertUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Post
func (this *SignupController) Post() {
w := this.ResponseWriter
r := this.Request
user := m.User{}
data := e.Data{Msg: "注冊成功", Status: 1}
r.ParseForm()
userName := r.FormValue("username")
passWord1 := r.FormValue("password1")
passWord2 := r.FormValue("password2")
reg := regexp.MustCompile(mobile)
pleng := len(passWord1)
if userName == "" {
data.Status = 0
data.Msg = "用戶名不能為空"
}
if data.Status != 0 && !reg.MatchString(userName) {
data.Status = 0
data.Msg = "手機號碼格式錯誤"
}
if data.Status != 0 && passWord1 == "" {
data.Status = 0
data.Msg = "密碼不能為空"
}
if data.Status != 0 && (pleng < 6 || pleng > 12) {
data.Status = 0
data.Msg = "密碼為6-12位字母或者數字組合"
}
if data.Status != 0 && passWord2 == "" {
data.Status = 0
data.Msg = "確認密碼不能為空"
}
if data.Status != 0 && passWord1 != passWord2 { //後端驗證兩次密碼不一致
data.Status = 0
data.Msg = "兩次密碼不一致!"
}
log.Println(template.HTMLEscapeString(passWord1))
if data.Status != 0 {
user.UserName = userName
user.TelPhone = userName
user.PassWord = passWord2
/*新增用戶*/
user, err := user.InsertUser()
if err != nil {
data.Status = 0
data.Msg = "用戶注冊出錯"
data.Data = err.Error()
} else {
data.Data = user
}
}
u.OutputJson(w, &data)
// user.Id = "9527"
// user.RealName = "張力"
// user.IDCard = "5002351991000000"
// user.UserName = "15520010009"
// user.Area = "重慶"
// honours := make([]m.Honours, 1, 5)
// h1 := m.Honours{"實名認證用戶", "card"}
// h2 := m.Honours{"會員", "vip"}
// honours[0] = h1
// honours = append(honours, h2)
// user.Honours = honours
// log.Println(cap(honours))
// skills := make([]m.Skill, 2, 10)
// skills[0].Category = "運動"
// skills[0].Item = "遊泳"
// skills[0].Price = 50.00
// skills[0].Bid = 0.00
// skills[0].Experience = 2
// skills[0].Sales = 90
// skills[0].Title = "重慶市渝北區遊泳館高級遊泳教練"
// skills[0].Area = "重慶 雲陽"
// skills[0].UserId = "9530"
// skills[1].Category = "電竟"
// skills[1].Item = "LOL"
// skills[1].Price = 10.00
// skills[1].Bid = 0.00
// skills[1].Experience = 3
// skills[1].Sales = 1000
// skills[1].Title = "英雄聯盟LOL巨神峰白銀高級帶練"
// skills[0].Area = "重慶 渝北"
// skills[0].UserId = "9530"
// skills[0].InsertSkills(skills)
// user.Skill = skills
// user.Introduction = "我就是愛音樂別讓我停下來"
// user.InsertUser(user)
//log.Println(user)
}