You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
895 B

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