调整路由以符合 RESTful 规范,新增 API Token 撤销功能
This commit is contained in:
@@ -80,6 +80,16 @@ func (h *TokenHandler) CreateToken(c *gin.Context) {
|
||||
}))
|
||||
}
|
||||
|
||||
// RevokeToken 撤销 API Token
|
||||
// @Summary 撤销 API Token
|
||||
// @Description 将 API Token 标记为已撤销,使其失效但保留记录
|
||||
// @Tags Admin
|
||||
// @Security AdminAuth
|
||||
// @Param id path int true "Token ID"
|
||||
// @Produce json
|
||||
// @Success 200 {object} model.Response
|
||||
// @Failure 500 {object} model.Response
|
||||
// @Router /admin/api-tokens/{id}/revoke [post]
|
||||
func (h *TokenHandler) RevokeToken(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
if err := bootstrap.DB.Model(&model.APIToken{}).Where("id = ?", id).Update("revoked", true).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user