本文整理匯總了Golang中get/2cloud/org/twocloud.RequestBundle.GetUsersByActivity方法的典型用法代碼示例。如果您正苦於以下問題:Golang RequestBundle.GetUsersByActivity方法的具體用法?Golang RequestBundle.GetUsersByActivity怎麽用?Golang RequestBundle.GetUsersByActivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類get/2cloud/org/twocloud.RequestBundle
的用法示例。
在下文中一共展示了RequestBundle.GetUsersByActivity方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getUsers
func getUsers(w http.ResponseWriter, r *twocloud.RequestBundle) {
if !r.AuthUser.IsAdmin {
Respond(w, r, http.StatusForbidden, "You don't have access to the user list.", []interface{}{})
return
}
active_afterstr := r.Request.URL.Query().Get("active_after")
active_beforestr := r.Request.URL.Query().Get("active_before")
joined_afterstr := r.Request.URL.Query().Get("joined_after")
joined_beforestr := r.Request.URL.Query().Get("joined_before")
var joined_before, joined_after, active_before, active_after time.Time
countstr := r.Request.URL.Query().Get("count")
count := 20
var err error
if countstr != "" {
count, err = strconv.Atoi(countstr)
if err != nil {
r.Log.Error(err.Error())
Respond(w, r, http.StatusBadRequest, "Invalid count param.", []interface{}{})
return
}
}
if count > 100 {
count = 100
}
if active_afterstr != "" {
active_after, err = time.Parse(time.RFC3339, active_afterstr)
if err != nil {
r.Log.Error(err.Error())
Respond(w, r, http.StatusBadRequest, "Invalid active_after value.", []interface{}{})
return
}
}
if active_beforestr != "" {
active_before, err = time.Parse(time.RFC3339, active_beforestr)
if err != nil {
r.Log.Error(err.Error())
Respond(w, r, http.StatusBadRequest, "Invalid active_before value.", []interface{}{})
return
}
}
if active_beforestr != "" || active_afterstr != "" {
users, err := r.GetUsersByActivity(count, active_after, active_before)
if err != nil {
r.Log.Error(err.Error())
Respond(w, r, http.StatusInternalServerError, "Internal server error.", []interface{}{})
return
}
Respond(w, r, http.StatusOK, "Successfully retrieved a list of users", []interface{}{users})
return
}
if joined_afterstr != "" {
joined_after, err = time.Parse(time.RFC3339, joined_afterstr)
if err != nil {
r.Log.Error(err.Error())
Respond(w, r, http.StatusBadRequest, "Invalid joined_after value.", []interface{}{})
return
}
}
if joined_beforestr != "" {
joined_before, err = time.Parse(time.RFC3339, joined_beforestr)
if err != nil {
r.Log.Error(err.Error())
Respond(w, r, http.StatusBadRequest, "Invalid joined_before value.", []interface{}{})
return
}
}
users, err := r.GetUsersByJoinDate(count, joined_after, joined_before)
if err != nil {
r.Log.Error(err.Error())
Respond(w, r, http.StatusInternalServerError, "Internal server error.", []interface{}{users})
return
}
Respond(w, r, http.StatusOK, "Successfully retrieved a list of users", []interface{}{users})
return
}