gin-vue-admin/server/api/v1/system/sys_jwt_blacklist.go

34 lines
990 B
Go
Raw Normal View History

2021-07-17 14:18:52 +08:00
package system
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
2024-01-04 22:15:41 +08:00
"github.com/flipped-aurora/gin-vue-admin/server/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
2021-12-06 12:44:26 +08:00
type JwtApi struct{}
2021-07-17 14:18:52 +08:00
// JsonInBlacklist
// @Tags Jwt
// @Summary jwt加入黑名单
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{msg=string} "jwt加入黑名单"
// @Router /jwt/jsonInBlacklist [post]
2021-07-17 14:18:52 +08:00
func (j *JwtApi) JsonInBlacklist(c *gin.Context) {
2024-01-04 22:15:41 +08:00
token := utils.GetToken(c)
2021-07-16 20:08:11 +08:00
jwt := system.JwtBlacklist{Jwt: token}
err := jwtService.JsonInBlacklist(jwt)
if err != nil {
global.GVA_LOG.Error("jwt作废失败!", zap.Error(err))
response.FailWithMessage("jwt作废失败", c)
return
}
2024-01-04 22:15:41 +08:00
utils.ClearToken(c)
response.OkWithMessage("jwt作废成功", c)
}