1234567891011121314151617181920212223242526272829303132333435 |
- package user
- import (
- "net/http"
- "git.i2edu.net/i2/go-zero/rest/httpx"
- "git.i2edu.net/i2/i2-bill-api/internal/logic/user"
- "git.i2edu.net/i2/i2-bill-api/internal/svc"
- "git.i2edu.net/i2/i2-bill-api/internal/types"
- "git.i2edu.net/i2/i2-bill-api/internal/utils"
- )
- func PunchClockHandler(ctx *svc.ServiceContext) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- uid, skey, err := ctx.GetClaims(r)
- if err != nil {
- httpx.OkJson(w, utils.ReturnHTTPFail(err))
- return
- }
- var req types.PunchClockRequest
- if err := httpx.Parse(r, &req); err != nil {
- httpx.OkJson(w, utils.ReturnHTTPFail(err))
- return
- }
- l := user.NewPunchClockLogic(r.Context(), ctx)
- l.UserId = uid
- l.SessionKey = skey
- resp, err := l.PunchClock(req)
- if err != nil {
- httpx.OkJson(w, utils.ReturnHTTPFail(err))
- } else {
- httpx.OkJson(w, utils.ReturnHTTPSuccess(resp))
- }
- }
- }
|