本文整理匯總了Golang中github.com/ericflo/irlmoji/src/models.DB.DeleteIMWithId方法的典型用法代碼示例。如果您正苦於以下問題:Golang DB.DeleteIMWithId方法的具體用法?Golang DB.DeleteIMWithId怎麽用?Golang DB.DeleteIMWithId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ericflo/irlmoji/src/models.DB
的用法示例。
在下文中一共展示了DB.DeleteIMWithId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: HandleDeleteIRLMoji
func HandleDeleteIRLMoji(r render.Render, db *models.DB, params martini.Params, backchannel Backchannel) {
if backchannel.UserId() == "" {
r.JSON(403, JsonErr("The provided credentials were invalid."))
return
}
user, err := db.GetUserWithId(backchannel.UserId())
if err != nil {
r.JSON(403, "Could not find a user with your credentials.")
return
}
irlmojiId, err := strconv.ParseUint(params["irlmojiId"], 10, 64)
if err != nil {
r.JSON(404, JsonErr("Invalid IRLMoji id provided:"+
params["irlmojiId"]))
}
im, err := db.GetIMWithId(irlmojiId)
if err != nil {
r.JSON(404, JsonErr("The provided IRLMoji id was invalid."))
return
}
if im.UserId != user.Id && !user.IsAdmin {
r.JSON(403, "You are not allowed to delete that IRLMoji.")
return
}
err = db.DeleteIMWithId(im.Id)
if err != nil {
log.Println("Error deleting IRLMoji:", err.Error())
r.JSON(500, JsonErr("There was an error deleting that IRLMoji."))
}
r.JSON(200, map[string]string{"status": "ok"})
}