goweb-gin-demo/server/api/system/sys_jwt_blacklist.go

31 lines
809 B
Go
Raw Normal View History

2021-11-10 11:11:14 +08:00
package system
2021-10-29 14:39:50 +08:00
import (
2021-11-02 17:48:39 +08:00
"github.com/gin-gonic/gin"
"go.uber.org/zap"
2021-10-29 14:44:41 +08:00
"goweb-gin-demo/global"
"goweb-gin-demo/model/common/response"
2021-11-10 11:11:14 +08:00
"goweb-gin-demo/model/system"
2021-10-29 14:39:50 +08:00
)
type JwtApi struct {
}
// @Tags Jwt
// @Summary jwt加入黑名单
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"拉黑成功"}"
// @Router /jwt/jsonInBlacklist [post]
func (j *JwtApi) JsonInBlacklist(c *gin.Context) {
token := c.Request.Header.Get("x-token")
2021-11-10 11:11:14 +08:00
jwt := system.JwtBlacklist{Jwt: token}
2021-10-29 14:39:50 +08:00
if err := jwtService.JsonInBlacklist(jwt); err != nil {
global.GLOBAL_LOG.Error("jwt作废失败!", zap.Any("err", err))
response.FailWithMessage("jwt作废失败", c)
} else {
response.OkWithMessage("jwt作废成功", c)
}
}