punch_clock_get_logic.go 1010 B

1234567891011121314151617181920212223242526272829303132333435
  1. package user
  2. import (
  3. "context"
  4. "net/http"
  5. "time"
  6. "git.i2edu.net/i2/i2-bill-api/internal/svc"
  7. "git.i2edu.net/i2/i2-bill-api/internal/types"
  8. "git.i2edu.net/i2/go-zero/core/logx"
  9. )
  10. type PunchClockGetLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewPunchClockGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) PunchClockGetLogic {
  16. return PunchClockGetLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *PunchClockGetLogic) PunchClockGet(r *http.Request) (*types.Response, error) {
  23. // todo: add your logic here and delete this line
  24. res, err := l.svcCtx.DB.SQL("select * from i2bill_acquirer_attendance_record where del_flag = 0 and user_id = ? and DATE_FORMAT(create_time,'%Y-%m-%d') = ? order by id desc limit 0,1", l.svcCtx.GetUserIdByJwt(l.ctx), time.Now().Format("2006-01-02")).Query().List()
  25. if err != nil {
  26. return &types.Response{500, err.Error(), nil}, nil
  27. }
  28. return &types.Response{200, "", res}, nil
  29. }