mkt_qr_get_logic.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package mk_qr
  2. import (
  3. "context"
  4. "git.i2edu.net/i2/i2-bill-api/model"
  5. "net/http"
  6. "strings"
  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 MktQrGetLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewMktQrGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) MktQrGetLogic {
  17. return MktQrGetLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *MktQrGetLogic) MktQrGet(r *http.Request) (*types.Response, error) {
  24. // todo: add your logic here and delete this line
  25. r.ParseForm()
  26. mk_id := r.Form.Get("mk_id")
  27. bean := new(model.I2billMktQr)
  28. _, err := l.svcCtx.DB.Where("mk_id = ? and del_flag = 0", mk_id).Get(bean)
  29. if err != nil {
  30. return &types.Response{500, err.Error(), nil}, nil
  31. }
  32. if bean.Qr != "" {
  33. bean.Qr = strings.TrimLeft(bean.Qr, "/")
  34. domain := strings.TrimRight(l.svcCtx.Config.AliYunOss.FileUrl, "/")
  35. bean.Qr = domain + "/" + bean.Qr
  36. }
  37. return &types.Response{200, "", bean}, nil
  38. }