acquirer_student_page_logic.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "git.i2edu.net/i2/i2-bill-api/internal/svc"
  6. "git.i2edu.net/i2/i2-bill-api/internal/types"
  7. "git.i2edu.net/i2/i2-bill-api/internal/utils"
  8. "net/http"
  9. "strconv"
  10. "time"
  11. "git.i2edu.net/i2/go-zero/core/logx"
  12. )
  13. type AcquirerStudentPageLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewAcquirerStudentPageLogic(ctx context.Context, svcCtx *svc.ServiceContext) AcquirerStudentPageLogic {
  19. return AcquirerStudentPageLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *AcquirerStudentPageLogic) AcquirerStudentPage(r *http.Request) (*types.Response, error) {
  26. // todo: add your logic here and delete this line
  27. r.ParseForm()
  28. create_time_sta := r.Form.Get("create_time_sta")
  29. create_time_end := r.Form.Get("create_time_end")
  30. page, _ := strconv.Atoi(r.Form.Get("page"))
  31. rows, _ := strconv.Atoi(r.Form.Get("rows"))
  32. check_state := r.Form.Get("check_state")
  33. sort := r.Form.Get("__sort__")
  34. userId := fmt.Sprintf("%d", l.svcCtx.GetUserIdByJwt(l.ctx))
  35. if create_time_end != "" {
  36. end, err := time.Parse("2006-01-02", create_time_end)
  37. if err != nil {
  38. return &types.Response{500, err.Error(), nil}, nil
  39. }
  40. create_time_end = end.Add(time.Second*24*60*60 - 1*time.Second).Format("2006-01-02 15:04:05")
  41. }
  42. if sort == "" {
  43. sort = "id desc"
  44. }
  45. paramMap_i_t := map[string]interface{}{
  46. "page": page,
  47. "rows": rows,
  48. "create_time_sta": create_time_sta,
  49. "create_time_end": create_time_end,
  50. "user_id": userId,
  51. "check_state": check_state,
  52. "__sort__": sort,
  53. }
  54. res, err := utils.PageSearch(l.svcCtx.DB, "i2bill_acquirer_student", "page", "i2bill_acquirer_student", paramMap_i_t)
  55. if err != nil {
  56. return &types.Response{500, err.Error(), res}, nil
  57. }
  58. return &types.Response{200, "", res}, nil
  59. }