123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package auth
- import (
- "net/http"
- "github.com/zeromicro/go-zero/rest/httpx"
- "wechat-api/internal/logic/auth"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- )
- // swagger:route post /user/login auth Login
- //
- // Log in | 登录
- //
- // Log in | 登录
- //
- // Parameters:
- // + name: body
- // require: true
- // in: body
- // type: LoginReq
- //
- // Responses:
- // 200: LoginResp
- func LoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- var req types.LoginReq
- if err := httpx.Parse(r, &req, true); err != nil {
- httpx.ErrorCtx(r.Context(), w, err)
- return
- }
- l := auth.NewLoginLogic(r.Context(), svcCtx, w)
- resp, err := l.Login(&req)
- if err != nil {
- httpx.ErrorCtx(r.Context(), w, err)
- } else {
- httpx.OkJsonCtx(r.Context(), w, resp)
- }
- }
- }
|