You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
565 B
36 lines
565 B
package photo
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"os"
|
|
"path/filepath"
|
|
"recook/internal/back"
|
|
"recook/internal/static_path"
|
|
"recook/tools"
|
|
)
|
|
|
|
type removePhotoParam struct {
|
|
URL string `json:"url" validate:"required,min=15"`
|
|
}
|
|
|
|
/*
|
|
删除图片
|
|
*/
|
|
func RemovePhoto(c *gin.Context) {
|
|
var p removePhotoParam
|
|
err := tools.Params(&p, c)
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
|
|
uri := filepath.Join(static_path.Dir.Root, p.URL)
|
|
err = os.Remove(uri)
|
|
if err != nil {
|
|
back.Err(c, err.Error())
|
|
return
|
|
}
|
|
|
|
back.Suc(c, "操作成功", nil)
|
|
}
|