调整路由以符合 RESTful 规范,新增 API Token 撤销功能

This commit is contained in:
2026-01-14 10:13:57 +08:00
parent 9c10dfd496
commit 5160ae78cc
10 changed files with 658 additions and 536 deletions

View File

@@ -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 {