get_erp_mkt_active_logic.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package mkt_active
  2. import (
  3. "context"
  4. "git.i2edu.net/i2/i2-bill-erp/transform"
  5. "net/http"
  6. "strconv"
  7. "git.i2edu.net/i2/i2-bill-api/internal/svc"
  8. "git.i2edu.net/i2/i2-bill-api/internal/types"
  9. "git.i2edu.net/i2/go-zero/core/logx"
  10. )
  11. type GetErpMktActiveLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewGetErpMktActiveLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetErpMktActiveLogic {
  17. return GetErpMktActiveLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *GetErpMktActiveLogic) GetErpMktActive(r *http.Request) (*types.Response, error) {
  24. // todo: add your logic here and delete this line
  25. r.ParseForm()
  26. schIdStr := r.Form.Get("sch_id")
  27. schId, err := strconv.ParseUint(schIdStr, 10, 64)
  28. if err != nil {
  29. logx.Error(err.Error())
  30. return &types.Response{500, err.Error(), nil}, nil
  31. }
  32. resp, err := l.svcCtx.Transformer.GetErpActive(l.ctx, &transform.GetErpActiveReq{SchId: schId})
  33. if err != nil {
  34. logx.Error(err.Error())
  35. return &types.Response{500, err.Error(), nil}, nil
  36. }
  37. return &types.Response{200, "", resp}, nil
  38. }