本文整理匯總了Golang中github.com/Centny/gwf/routing.HTTPSession.MsgResE方法的典型用法代碼示例。如果您正苦於以下問題:Golang HTTPSession.MsgResE方法的具體用法?Golang HTTPSession.MsgResE怎麽用?Golang HTTPSession.MsgResE使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Centny/gwf/routing.HTTPSession
的用法示例。
在下文中一共展示了HTTPSession.MsgResE方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PassengerFindDriver
func PassengerFindDriver(hs *routing.HTTPSession) routing.HResult {
var uid int64
var startTime int64
var sLat float64
var sLng float64
var eLat float64
var eLng float64
var sCity string
var eCity string
t := time.Now()
err := hs.ValidCheckVal(`
uid,R|I,R:0;
startTime,R|I,R:0;
sLat,R|F,R:0;
sLng,R|F,R:0;
eLat,R|F,R:0;
eLng,R|F,R:0;
sCity,R|S,L:0;
eCity,R|S,L:0;
`, &uid, &startTime, &sLat, &sLng, &eLat, &eLng, &sCity, &eCity)
if err != nil {
return hs.MsgResErr(100, "config error", err)
} else if t.Unix()-startTime < 1800 {
return hs.MsgResE(1, "invalid startTime , need > 30min from now")
} else {
s, err := db.FindDriverRoute(uid, startTime, sLat, sLng, eLat, eLng, sCity, eCity)
if err != nil {
return hs.MsgResErr2(1, "", err)
} else {
return hs.MsgRes(s)
}
}
}
示例2: ListChapter
func ListChapter(hs *routing.HTTPSession) routing.HResult {
var id int64 = 0
err := hs.ValidRVal(`
id,R|I,R:-1~10
`, &id)
if err != nil {
return hs.MsgResE(1, err.Error())
}
is := []Item{}
for i := 0; i < 10; i++ {
it := Item{}
it.Id = i
it.Name = fmt.Sprintf("ch-%d-%d", id, i)
is = append(is, it)
}
return hs.MsgRes(is)
}
示例3: GetAnswerRecord
func GetAnswerRecord(hs *routing.HTTPSession) routing.HResult {
var aId int64
err := hs.ValidCheckVal(`
aId,R|I,R:0;
`, &aId)
if err != nil {
log.E("GetAnswerRecord arg error:%v", err)
return hs.MsgResE(1, fmt.Sprintf("%s:%s", common_.ARG_ERROR, err.Error()))
}
conn := dbMgr.DbConn()
var content sql.NullString
if err := conn.QueryRow("select content from ebs_answer where tid=?", aId).Scan(&content); err != nil {
if err != sql.ErrNoRows {
return hs.MsgResE(2, err.Error())
}
}
return hs.MsgRes(content.String)
}
示例4: SaveAnswer
func SaveAnswer(hs *routing.HTTPSession) routing.HResult {
var aId int64
var a string
err := hs.ValidCheckVal(`
aId,R|I,R:0;
a,R|S,L:0;
`, &aId, &a)
if err != nil {
log.E("SaveAnswer arg error:%v", err)
return hs.MsgResE(1, fmt.Sprintf("%s:%s", common_.ARG_ERROR, err.Error()))
}
aParse := []ANSWER2{}
if err := json.Unmarshal([]byte(a), &aParse); err != nil {
log.E("%v", err)
return hs.MsgResE(1, fmt.Sprintf("%s:作答內容格式錯誤,%s", common_.ARG_ERROR, err.Error()))
}
sql_ := `update ebs_answer set content=? where tid=?`
conn := dbMgr.DbConn()
if _, err := conn.Exec(sql_, a, aId); err != nil {
log.E("SaveAnswer db error:%v,sql:%s,args:%v", err, sql_, a)
return hs.MsgResE(2, fmt.Sprintf("%s:%s", common_.DB_ERROR, err.Error()))
}
return hs.MsgRes("success")
}