fix: fix post handling

This commit is contained in:
Damillora 2021-05-11 18:06:48 +07:00
parent 44eebcedfb
commit 9ff897a14f
3 changed files with 14 additions and 11 deletions

View File

@ -170,6 +170,7 @@ func postUpdate(c *gin.Context) {
Code: http.StatusBadRequest,
Message: err.Error(),
})
return
}
c.JSON(http.StatusOK, models.PostListItem{

View File

@ -72,9 +72,6 @@ func UpdatePost(id string, model models.PostUpdateModel) (*database.Post, error)
if result.Error != nil {
return nil, result.Error
}
database.DB.Model(&post).Association("Tags").Replace(tags)
post.SourceURL = model.SourceURL
result = database.DB.Save(&post)
@ -82,6 +79,10 @@ func UpdatePost(id string, model models.PostUpdateModel) (*database.Post, error)
return nil, result.Error
}
err = database.DB.Model(&post).Association("Tags").Replace(tags)
if err != nil {
return nil, err
}
return &post, nil
}

View File

@ -51,15 +51,16 @@
searchTerms = value.detail.tags;
};
onMount(() => {
$: {
queryParams = queryString.parse(location.search);
if (queryParams.tags) {
searchTerms = queryParams.tags.split(" ");
} else {
searchTerms = [];
}
posts = [];
getData();
});
}
const onSearch = (i) => {
if (searchTerms.length > 0) {