• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang store.Parser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/bbhmakerlab/openinnovation/store.Parser的典型用法代码示例。如果您正苦于以下问题:Golang Parser类的具体用法?Golang Parser怎么用?Golang Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Parser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:25,代码来源:friend.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:31,代码来源:member.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:25,代码来源:project.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:27,代码来源:project.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:34,代码来源:milestone.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:30,代码来源:task.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:30,代码来源:chat.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:29,代码来源:user.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:12,代码来源:user.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:16,代码来源:project.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:16,代码来源:milestone.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:17,代码来源:project.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:17,代码来源:task.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:17,代码来源:featured_project.go


示例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)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:17,代码来源:milestone.go


示例16: onNotify

// id/userID/channelID/channelType
func onNotify(channel, extra string) {
	params := strings.Split(extra, "/")
	if len(params) < 5 {
		return
	}

	var parser store.Parser
	id := parser.Int(params[1])
	userID := parser.Int(params[2])
	channelID := parser.Int(params[3])
	channelType := params[4]
	if parser.Err != nil {
		return
	}

	notification := struct {
		ID          int64  `json:"id"`
		UserID      int64  `json:"userID"`
		ChannelID   int64  `json:"channelID"`
		ChannelType string `json:"channelType"`
	}{
		ID:          id,
		UserID:      userID,
		ChannelID:   channelID,
		ChannelType: channelType,
	}

	switch channelType {
	case "user":
		h.notifyUser(userID, channelID, "newChatMessage", notification)
	case "project":
		h.notifyProject(channelID, "newChatMessage", notification)
	}
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:35,代码来源:chat.go


示例17: GetChats

func GetChats(w http.ResponseWriter, r *http.Request) {
	if err := r.ParseForm(); err != nil {
		response.ServerError(w, err)
		return
	}

	var parser store.Parser
	var startID int64
	var count int64 = 10

	if v, ok := r.Form["count"]; ok {
		count = parser.Int(v[0])
	}

	if v, ok := r.Form["startID"]; ok {
		startID = parser.Int(v[0])
	}

	channelID := parser.Int(r.FormValue("channelID"))
	if parser.Err != nil {
		response.ClientError(w, http.StatusBadRequest)
		return
	}
	channelType := r.FormValue("channelType")

	user := context.Get(r, "user").(store.User)
	chats, err := store.GetChats(user.ID(), channelID, channelType, startID, count)
	if err != nil {
		response.ServerError(w, err)
		return
	}

	response.OK(w, chats)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:34,代码来源:chat.go


示例18: UpdateProject

func UpdateProject(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
	}

	user := context.Get(r, "user").(store.User)
	if !user.IsAuthor(projectID) {
		response.ClientError(w, http.StatusForbidden)
		return
	}

	for k, v := range r.Form {
		var err error

		if len(v) == 0 {
			continue
		}

		switch k {
		case "title":
			err = store.UpdateProjectTitle(projectID, v[0])
		case "tagline":
			err = store.UpdateProjectTagline(projectID, v[0])
		case "description":
			err = store.UpdateProjectDescription(projectID, v[0])
		}
		if err != nil {
			response.ServerError(w, err)
			return
		}
	}

	if _, err := store.SaveProjectImage(w, r, projectID); err != nil {
		response.ServerError(w, err)
		return
	}

	response.OK(w, nil)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:43,代码来源:project.go


示例19: PersonalizedTasks

func PersonalizedTasks(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
	}

	user := context.Get(r, "user").(store.User)

	tasks, err := store.PersonalizedTasks(user.ID(), count)
	if err != nil {
		response.ServerError(w, err)
		return
	}

	response.OK(w, tasks)
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:19,代码来源:task.go


示例20: DeleteProject

func DeleteProject(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
	}

	user := context.Get(r, "user").(store.User)
	if !user.IsAuthor(projectID) {
		response.ClientError(w, http.StatusUnauthorized)
		return
	}

	if err := store.DeleteProject(projectID); err != nil {
		response.ServerError(w, err)
		return
	}
}
开发者ID:bbh-labs,项目名称:openinnovation-old,代码行数:20,代码来源:project.go



注:本文中的github.com/bbhmakerlab/openinnovation/store.Parser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang store.DBConn类代码示例发布时间:2022-05-24
下一篇:
Golang response.ServerError函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap