本文整理匯總了Golang中ibookings/entity.Data.Data方法的典型用法代碼示例。如果您正苦於以下問題:Golang Data.Data方法的具體用法?Golang Data.Data怎麽用?Golang Data.Data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ibookings/entity.Data
的用法示例。
在下文中一共展示了Data.Data方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Category
func (this *SelectController) Category() {
w := this.ResponseWriter
r := this.Request
categoryArry := []m.Select{}
data := e.Data{Status: 1, Msg: "操作成功"}
r.ParseForm()
// t, err := t.ParseFiles("views/User.edit.area.tpl")
// if err != nil {
// log.Println(err)
// }
flag := r.FormValue("type")
log.Println("技能項", flag)
value := r.FormValue("value") //
categoryArry = m.CategoryCache
if "subCategory" == flag {
categoryArry = m.SubCategoryCache[value]
}
if "item" == flag {
categoryArry = m.ItermCache[value]
}
data.Data = categoryArry
log.Println("category", data)
u.OutputJson(w, &data)
}
示例2: Area
func (this *SelectController) Area() {
w := this.ResponseWriter
r := this.Request
areaArry := []m.Select{}
data := e.Data{Status: 1, Msg: "操作成功"}
r.ParseForm()
// t, err := t.ParseFiles("views/User.edit.area.tpl")
// if err != nil {
// log.Println(err)
// }
flag := r.FormValue("type") //區別省市區
value := r.FormValue("value") //
areaArry = m.ProvinceCache
city := m.CityCache
country := m.CountyCache
if "city" == flag {
areaArry = city[value]
} else if "country" == flag {
areaArry = country[value]
}
data.Data = areaArry
u.OutputJson(w, &data)
}
示例3: Check
func (this *LoginController) Check() {
data := e.Data{Status: 1, Msg: "已登錄"}
cookie := u.Cookie{HTTP: this.HTTP}
cookie = cookie.GetCookie()
if cookie.UserId == nil { //沒有登錄
data.Status = 0
data.Msg = "沒有登錄"
data.Data = "/login"
}
u.OutputJson(this.ResponseWriter, &data)
}
示例4: Post
func (this *AvatarController) Post() {
w := this.ResponseWriter
r := this.Request
data := e.Data{Status: 1, Msg: "上傳成功"}
log.Println("頭像上傳post")
r.ParseMultipartForm(32 << 20)
log.Println("表單解析")
file, handler, err := r.FormFile("realPicFile")
if err != nil {
log.Println("上傳錯誤")
return
}
fileext := filepath.Ext(handler.Filename)
log.Println("文件後綴名字" + fileext)
if u.Check(fileext) == false {
data.Status = 0
data.Msg = "不允許的上傳類型"
u.OutputJson(w, &data)
return
}
cookie := u.Cookie{HTTP: this.HTTP}
filename := cookie.GetCookie().UserId.Value + ".png"
log.Println("文件名稱" + filename)
imgfile, _ := os.OpenFile(Upload_Dir+filename, os.O_CREATE|os.O_WRONLY, 0660)
defer imgfile.Close()
//把圖片變成400X400尺寸的
m1, err := jpeg.Decode(file)
if err != nil {
panic(err)
}
bounds := m1.Bounds()
//如果第二參數為0則保持橫縱比
g := gift.New(
gift.Resize(400, 400, gift.LanczosResampling),
)
dst := image.NewRGBA(g.Bounds(bounds))
g.Draw(dst, m1)
err = png.Encode(imgfile, dst)
if err != nil {
log.Println("上傳失敗")
return
}
filedir := Show_Dir + filename
data.Data = filedir
log.Println(data)
u.OutputJson(w, &data)
}
示例5: Add
func (this *OrderController) Add() {
w := this.ResponseWriter
r := this.Request
data := e.Data{Msg: "生成訂單成功", Status: 1}
r.ParseForm()
money := r.FormValue("money")
startTime := r.FormValue("startTime")
endTime := r.FormValue("endTime")
address := r.FormValue("address")
ruserId := r.FormValue("ruser")
remark := r.FormValue("remark")
skillId := r.FormValue("skill")
order := m.Order{}
order.Skill.Id = skillId
order.Skill = order.Skill.GetSkillById()
order.RUser = ruserId
cookie := u.Cookie{HTTP: this.HTTP}
cookie = cookie.GetCookie()
if cookie.UserId != nil {
order.OUser = cookie.UserId.Value
}
log.Println(startTime)
log.Println(endTime)
order.BeginTime, _ = time.Parse("2006-01-02 15:04", startTime)
order.EndTime, _ = time.Parse("2006-01-02 15:04", endTime)
order.OrderTime = time.Now()
order.Status = "預約"
order.Remark = remark
order.Address = address
order.TotalPrice, _ = strconv.ParseFloat(money, 32)
ordered, err := order.InsertOrder()
data.Data = ordered
if err != nil {
data.Msg = "訂單生成失敗"
data.Status = 0
}
u.OutputJson(w, &data)
}
示例6: 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)
}