logout_handler.go 713 B

1234567891011121314151617181920212223242526272829303132
  1. package user
  2. import (
  3. "net/http"
  4. "github.com/zeromicro/go-zero/rest/httpx"
  5. "github.com/suyuan32/simple-admin-core/api/internal/logic/user"
  6. "github.com/suyuan32/simple-admin-core/api/internal/svc"
  7. )
  8. // swagger:route get /user/logout user Logout
  9. //
  10. // Log out | 退出登陆
  11. //
  12. // Log out | 退出登陆
  13. //
  14. // Responses:
  15. // 200: BaseMsgResp
  16. func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  17. return func(w http.ResponseWriter, r *http.Request) {
  18. l := user.NewLogoutLogic(r.Context(), svcCtx)
  19. resp, err := l.Logout()
  20. if err != nil {
  21. err = svcCtx.Trans.TransError(r.Context(), err)
  22. httpx.ErrorCtx(r.Context(), w, err)
  23. } else {
  24. httpx.OkJsonCtx(r.Context(), w, resp)
  25. }
  26. }
  27. }