wx-server/internal/server/file/delete.go

37 lines
798 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package file
import (
"fmt"
"mini_server/internal/dao"
"mini_server/internal/server/httpreply"
"net/http"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
type DeleteURI struct {
FileId string `uri:"file_id" binding:"len=32"`
}
// 文件删除接口
func Delete(c *gin.Context) {
reply := httpreply.NewDefaultReplyData()
defer httpreply.Reply(c, reply)
var param DeleteURI
if err := c.ShouldBindUri(&param); err != nil {
reply.Status = http.StatusBadRequest
reply.Message = fmt.Sprintf("invalid uri path,err:%v", err)
return
}
if err := dao.File_Delete(param.FileId); err != nil {
logrus.Errorf("删除文件失败文件id:%s,err:%v", param.FileId, err)
reply.Status = http.StatusInternalServerError
reply.Message = "数据库删除失败"
return
}
}