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.

30 lines
803 B

3 years ago
3 years ago
  1. package system
  2. import (
  3. "gin-vue-admin/global"
  4. "gin-vue-admin/model/common/response"
  5. "gin-vue-admin/model/system"
  6. "github.com/gin-gonic/gin"
  7. "go.uber.org/zap"
  8. )
  9. type JwtApi struct {
  10. }
  11. // @Tags Jwt
  12. // @Summary jwt加入黑名单
  13. // @Security ApiKeyAuth
  14. // @accept application/json
  15. // @Produce application/json
  16. // @Success 200 {string} string "{"success":true,"data":{},"msg":"拉黑成功"}"
  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. if err := jwtService.JsonInBlacklist(jwt); err != nil {
  22. global.GVA_LOG.Error("jwt作废失败!", zap.Any("err", err))
  23. response.FailWithMessage("jwt作废失败", c)
  24. } else {
  25. response.OkWithMessage("jwt作废成功", c)
  26. }
  27. }