mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
Added edition workflow
This commit is contained in:
@@ -70,3 +70,23 @@ func DeleteArticleHandler(c *gin.Context) {
|
||||
|
||||
SendOk(c, fmt.Sprintf("%d articles were successfully deleted!", deleteCount))
|
||||
}
|
||||
|
||||
func EditArticleHandler(c *gin.Context) {
|
||||
id := c.Params.ByName("id")
|
||||
|
||||
var articleUpdate DocumentUpdate
|
||||
articleUpdate.Filter = gin.H{"id_name": id}
|
||||
c.BindJSON(&articleUpdate.Update)
|
||||
|
||||
editCount, err := editDocument(articlesLocation, articleUpdate)
|
||||
if err != nil {
|
||||
SendBadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if editCount != 0 {
|
||||
SendOk(c, fmt.Sprintf("%d articles were successfully edited!", editCount))
|
||||
} else {
|
||||
SendOk(c, "No articles were edited.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user