deletePhotoUrl.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_m_api/consts"
  6. "youngee_m_api/db"
  7. "youngee_m_api/model/http_model"
  8. "youngee_m_api/util"
  9. )
  10. func WrapDeletePhotoUrlHandler(ctx *gin.Context) {
  11. handler := newDeletePhotoUrl(ctx)
  12. BaseRun(handler)
  13. }
  14. type DeletePhotoUrl struct {
  15. req *http_model.DeletePhotoUrlRequest
  16. resp *http_model.CommonResponse
  17. ctx *gin.Context
  18. }
  19. func (d DeletePhotoUrl) getContext() *gin.Context {
  20. return d.ctx
  21. }
  22. func (d DeletePhotoUrl) getResponse() interface{} {
  23. return d.resp
  24. }
  25. func (d DeletePhotoUrl) getRequest() interface{} {
  26. return d.req
  27. }
  28. func (d DeletePhotoUrl) run() {
  29. err := db.DeletePhotoUrl(d.ctx, d.req.PhotoUrl)
  30. if err != nil {
  31. logrus.WithContext(d.ctx).Errorf("[DeletePhotoUrl] error DeletePhotoUrl, err:%+v", err)
  32. util.HandlerPackErrorResp(d.resp, consts.ErrorInternal, consts.DefaultToast)
  33. return
  34. }
  35. d.resp.Message = "图片删除成功"
  36. }
  37. func (d DeletePhotoUrl) checkParam() error {
  38. return nil
  39. }
  40. func newDeletePhotoUrl(ctx *gin.Context) *DeletePhotoUrl {
  41. return &DeletePhotoUrl{
  42. req: http_model.NewDeletePhotoUrlRequest(),
  43. resp: http_model.NewDeletePhotoUrlResponse(),
  44. ctx: ctx,
  45. }
  46. }