selection_delete.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_b_api/consts"
  6. "youngee_b_api/db"
  7. "youngee_b_api/model/http_model"
  8. "youngee_b_api/util"
  9. )
  10. func WrapDeleteSelectionHandler(ctx *gin.Context) {
  11. handler := NewDeleteSelection(ctx)
  12. baseRun(handler)
  13. }
  14. type DeleteSelectionHandler struct {
  15. ctx *gin.Context
  16. req *http_model.DeleteSelectionRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (d DeleteSelectionHandler) getContext() *gin.Context {
  20. return d.ctx
  21. }
  22. func (d DeleteSelectionHandler) getResponse() interface{} {
  23. return d.resp
  24. }
  25. func (d DeleteSelectionHandler) getRequest() interface{} {
  26. return d.req
  27. }
  28. func (d DeleteSelectionHandler) run() {
  29. err := db.DeleteSelection(d.ctx, d.req.SelectionId)
  30. if err != nil {
  31. logrus.WithContext(d.ctx).Errorf("[DeleteSelectionHandler] error DeleteSelection, err:%+v", err)
  32. util.HandlerPackErrorResp(d.resp, consts.ErrorInternal, consts.DefaultToast)
  33. return
  34. }
  35. d.resp.Message = "选品删除成功"
  36. d.resp.Status = 20000
  37. return
  38. }
  39. func (d DeleteSelectionHandler) checkParam() error {
  40. return nil
  41. }
  42. func NewDeleteSelection(ctx *gin.Context) *DeleteSelectionHandler {
  43. return &DeleteSelectionHandler{
  44. ctx: ctx,
  45. req: http_model.NewDeleteSelectionRequest(),
  46. resp: http_model.NewDeleteSelectionResponse(),
  47. }
  48. }