本文整理匯總了Golang中github.com/bbhmakerlab/openinnovation/store.Parser類的典型用法代碼示例。如果您正苦於以下問題:Golang Parser類的具體用法?Golang Parser怎麽用?Golang Parser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Parser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetFriends
func GetFriends(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
userID := parser.Int(r.FormValue("userID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
users, err := store.GetFriends(userID)
if err != nil {
response.ServerError(w, err)
return
}
for i := range users {
if _, ok := h.connections[users[i].ID()]; ok {
users[i].SetStatus("Online")
} else {
users[i].SetStatus("Offline")
}
}
response.OK(w, users)
}
示例2: RemoveMember
func RemoveMember(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
projectID := parser.Int(r.FormValue("projectID"))
userID := parser.Int(r.FormValue("userID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
user := context.Get(r, "user").(store.User)
if user.ID() != userID {
response.ClientError(w, http.StatusForbidden)
return
}
if exists, err := store.MemberExists(projectID, userID); err != nil {
response.ServerError(w, err)
return
} else if !exists {
response.OK(w, nil)
return
}
if err := store.RemoveMember(projectID, userID); err != nil {
response.ServerError(w, err)
return
}
response.OK(w, nil)
}
示例3: GetProject
func GetProject(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
projectID := parser.Int(r.FormValue("projectID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
p, err := store.GetProject(projectID)
if err != nil {
response.ServerError(w, err)
return
}
if p.Author, err = store.GetUser(p.AuthorID); err != nil {
response.ServerError(w, err)
return
}
user := context.Get(r, "user").(store.User)
p.IsMember = store.IsMember(projectID, user.ID())
response.OK(w, p)
}
示例4: SetFeaturedProject
func SetFeaturedProject(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
const existSQL = `
SELECT COUNT(*) FROM featured_project
WHERE project_id = $1`
projectID := parser.Int(r.FormValue("projectID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
if exists, err := store.Exists(existSQL, projectID); err != nil {
response.ServerError(w, err)
return
} else if exists {
response.OK(w, nil)
return
}
if err := store.SetFeaturedProject(projectID); err != nil {
response.ServerError(w, err)
}
response.OK(w, nil)
}
示例5: CreateMilestone
func CreateMilestone(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
projectID := parser.Int(r.FormValue("projectID"))
date := parser.Time(r.FormValue("date"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
user := context.Get(r, "user").(store.User)
if !user.IsAuthor(projectID) {
response.ClientError(w, http.StatusForbidden)
return
}
title := r.FormValue("title")
description := r.FormValue("description")
var milestoneID int64
var err error
if milestoneID, err = store.CreateMilestone(store.CreateMilestoneParams{
ProjectID: projectID,
Title: title,
Description: description,
Date: date,
}); err != nil {
response.ServerError(w, err)
return
}
response.OK(w, milestoneID)
}
示例6: UpdateTask
func UpdateTask(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
projectID := parser.Int(r.FormValue("projectID"))
if parser.Err != nil {
response.ServerError(w, parser.Err)
return
}
user := context.Get(r, "user").(store.User)
if !user.IsMember(projectID) {
response.ClientError(w, http.StatusForbidden)
return
}
var taskID int64
if err := store.UpdateTask(store.UpdateTaskParams{
TaskID: r.FormValue("taskID"),
Title: r.FormValue("title"),
Description: r.FormValue("description"),
Tags: r.Form["tags"],
StartDate: r.FormValue("startDate"),
EndDate: r.FormValue("endDate"),
}); err != nil {
response.ServerError(w, err)
return
}
response.OK(w, taskID)
}
示例7: PostChat
func PostChat(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
userID := parser.Int(r.FormValue("userID"))
channelID := parser.Int(r.FormValue("channelID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
chatParams := store.PostChatParams{
UserID: userID,
ChannelID: channelID,
ChannelType: r.FormValue("channelType"),
Text: r.FormValue("text"),
}
id, err := store.PostChat(chatParams)
if err != nil {
response.ServerError(w, err)
return
}
if err = store.NotifyChat(store.NotifyChatParams{id, chatParams}); err != nil {
debug.Warn(err)
return
}
response.OK(w, id)
}
示例8: GetUser
func GetUser(w http.ResponseWriter, r *http.Request) {
userIDStr := r.FormValue("userID")
if userIDStr == "me" {
response.OK(w, store.CurrentUser(r))
return
}
var parser store.Parser
userID := parser.Int(userIDStr)
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
user := context.Get(r, "user").(store.User)
otherUser, err := store.GetUserWithParams(userID, store.GetUserParams{user.ID()})
if err != nil {
response.ServerError(w, err)
return
}
if otherUser == nil {
response.ClientError(w, http.StatusNotFound)
return
}
response.OK(w, otherUser)
}
示例9: UnassignWorker
func UnassignWorker(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
taskID := parser.Int(r.FormValue("taskID"))
userID := parser.Int(r.FormValue("userID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
store.DeleteWorker(taskID, userID)
}
示例10: UnsetFeaturedProject
func UnsetFeaturedProject(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
projectID := parser.Int(r.FormValue("projectID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
if err := store.UnsetFeaturedProject(projectID); err != nil {
response.ServerError(w, err)
return
}
response.OK(w, nil)
}
示例11: DeleteMilestone
func DeleteMilestone(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
milestoneID := parser.Int(r.FormValue("milestoneID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
if err := store.DeleteMilestone(milestoneID); err != nil {
response.ServerError(w, err)
return
}
response.OK(w, nil)
}
示例12: CompletedProjects
func CompletedProjects(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
userID := parser.Int(r.FormValue("userID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
ps, err := store.CompletedProjects(userID)
if err != nil {
response.ServerError(w, err)
return
}
response.OK(w, ps)
}
示例13: LatestTasks
func LatestTasks(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
count := parser.Int(r.FormValue("count"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
tasks, err := store.LatestTasks(r.FormValue("title"), count)
if err != nil {
response.ServerError(w, err)
return
}
response.OK(w, tasks)
}
示例14: FeaturedProjects
func FeaturedProjects(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
count := parser.Int(r.FormValue("count"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
projects, err := store.FeaturedProjects(count)
if err != nil {
response.ServerError(w, err)
return
}
response.OK(w, projects)
}
示例15: GetMilestones
func GetMilestones(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
projectID := parser.Int(r.FormValue("projectID"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
milestones, err := store.GetMilestones(projectID)
if err != nil {
response.ServerError(w, err)
return
}
response.OK(w, milestones)
}