本文整理汇总了Golang中github.com/dhamidi/ess.Command类的典型用法代码示例。如果您正苦于以下问题:Golang Command类的具体用法?Golang Command怎么用?Golang Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Command类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SignUp
func (self *User) SignUp(params *ess.Command) error {
err := ess.NewValidationError()
if self.signedUp {
err.Add("username", "not_unique")
}
if err.Ok() {
self.events.PublishEvent(
ess.NewEvent("user.signed-up").
For(self).
Add("username", params.Get("username").String()).
Add("password", params.Get("password").String()).
Add("email", params.Get("email").String()),
)
}
return err.Return()
}
示例2: HandleCommand
func (self *User) HandleCommand(command *ess.Command) error {
switch command.Name {
case "sign-up":
return self.SignUp(command)
case "login":
return self.Login(command.Get("session").String(), command.Get("password").(*ess.BcryptedPassword))
case "logout":
return self.Logout(command.Get("session").String())
}
return nil
}
示例3: HandleCommand
func (self *User) HandleCommand(command *ess.Command) error {
switch command.Name {
case "sign-up":
return self.SignUp(
command.Get("name").String(),
command.Get("email").String(),
command.Get("password").String(),
)
}
return nil
}
示例4: ShowEditPostFormError
func ShowEditPostFormError(w http.ResponseWriter, params *ess.Command, err error) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
NewHTMLDocument("Edit Post",
EditPostForm.
Fill(params, err).
Action("/posts/"+params.AggregateId()+"/edit").
Param("id", params.AggregateId()).
Param("username", params.Get("username").String()).
ToHTML("Edit post"),
).WriteHTML(w, "", " ")
}
示例5: NewUserFromCommand
func NewUserFromCommand(command *ess.Command) ess.Aggregate {
return NewUser(command.Get("username").String())
}
示例6: UserFromCommand
func UserFromCommand(params *ess.Command) ess.Aggregate {
return NewUser(params.Get("username").String())
}
示例7: PostFromCommand
func PostFromCommand(params *ess.Command) ess.Aggregate {
return NewPost(params.AggregateId())
}
示例8: HandleCommand
func (self *Post) HandleCommand(command *ess.Command) error {
switch command.Name {
case "write-post":
return self.Write(
command.Get("title").String(),
command.Get("body").String(),
command.Get("username").String(),
)
case "edit-post":
return self.Edit(
command.Get("title").String(),
command.Get("body").String(),
command.Get("reason").String(),
command.Get("username").String(),
)
}
return nil
}