sys_jwt_blacklist.go 826 B

12345678910111213141516171819202122232425262728293031
  1. package system
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "go.uber.org/zap"
  6. "lc-base-frame/model/common/response"
  7. "lc-base-frame/model/system"
  8. )
  9. type JwtApi struct{}
  10. // JsonInBlacklist
  11. // @Tags Jwt
  12. // @Summary jwt加入黑名单
  13. // @Security ApiKeyAuth
  14. // @accept application/json
  15. // @Produce application/json
  16. // @Success 200 {object} response.Response{msg=string} "jwt加入黑名单"
  17. // @Router /jwt/jsonInBlacklist [post]
  18. func (j *JwtApi) JsonInBlacklist(c *gin.Context) {
  19. token := c.Request.Header.Get("x-token")
  20. jwt := system.JwtBlacklist{Jwt: token}
  21. err := jwtService.JsonInBlacklist(jwt)
  22. if err != nil {
  23. logrus.Error("jwt作废失败!", zap.Error(err))
  24. response.FailWithMessage("jwt作废失败", c)
  25. return
  26. }
  27. response.OkWithMessage("jwt作废成功", c)
  28. }