feat: add post buy count
This commit is contained in:
@@ -38,3 +38,22 @@ func (ctl *medias) Show(ctx fiber.Ctx, id int64) error {
|
||||
|
||||
return ctx.Redirect().To(url)
|
||||
}
|
||||
|
||||
// Delete
|
||||
// @Router /v1/admin/medias/:id [delete]
|
||||
// @Bind id path
|
||||
func (ctl *medias) Delete(ctx fiber.Ctx, id int64) error {
|
||||
media, err := models.Medias.GetByID(ctx.Context(), id)
|
||||
if err != nil {
|
||||
return ctx.SendString("Media not found")
|
||||
}
|
||||
|
||||
if err := ctl.oss.Delete(ctx.Context(), media.Path); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := models.Medias.Delete(ctx.Context(), id); err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.SendStatus(fiber.StatusNoContent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user