本文整理汇总了Golang中github.com/bbhmakerlab/openinnovation/store.Parser.Time方法的典型用法代码示例。如果您正苦于以下问题:Golang Parser.Time方法的具体用法?Golang Parser.Time怎么用?Golang Parser.Time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/bbhmakerlab/openinnovation/store.Parser
的用法示例。
在下文中一共展示了Parser.Time方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdateMilestone
func UpdateMilestone(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
projectID := parser.Int(r.FormValue("projectID"))
milestoneID := parser.Int(r.FormValue("milestoneID"))
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")
if err := store.UpdateMilestone(store.UpdateMilestoneParams{
MilestoneID: milestoneID,
Title: title,
Description: description,
Date: date,
}); err != nil {
response.ServerError(w, err)
return
}
response.OK(w, nil)
}
示例2: CreateTask
func CreateTask(w http.ResponseWriter, r *http.Request) {
var parser store.Parser
projectID := parser.Int(r.FormValue("projectID"))
startDate := parser.Time(r.FormValue("startDate"))
endDate := parser.Time(r.FormValue("endDate"))
if parser.Err != nil {
response.ClientError(w, http.StatusBadRequest)
return
}
if startDate.After(endDate) {
response.ClientError(w, http.StatusBadRequest)
return
}
user := context.Get(r, "user").(store.User)
if !user.IsMember(projectID) {
response.ClientError(w, http.StatusForbidden)
return
}
var taskID int64
var err error
if taskID, err = store.CreateTask(store.CreateTaskParams{
AuthorID: user.ID(),
ProjectID: projectID,
Title: r.FormValue("title"),
Description: r.FormValue("description"),
Done: false,
Tags: strings.Split(r.FormValue("tags"), ","),
StartDate: startDate,
EndDate: endDate,
}); err != nil {
response.ServerError(w, err)
return
}
response.OK(w, taskID)
}