仓库自包含化:Docker/CI/文档/规范入库,路由分组拆分
CI / test (push) Successful in 15s

This commit is contained in:
Wang Defa
2026-07-09 19:18:04 +08:00
parent b9a3e97e84
commit 3e0389c1e9
83 changed files with 20241 additions and 248 deletions
+17
View File
@@ -24,6 +24,17 @@ type loginRequest struct {
TotpCode string `json:"totpCode"`
}
// login 校验用户名密码(与可选 TOTP)后签发 JWT。
//
// @Summary 登录
// @Tags 认证
// @Accept json
// @Produce json
// @Param body body loginRequest true "登录凭据"
// @Success 200 {object} map[string]any "token 与 expiresAt"
// @Failure 401 {object} map[string]string "凭据错误"
// @Failure 428 {object} map[string]any "需要两步验证码(totpRequired=true)"
// @Router /api/v1/auth/login [post]
func (h *authHandler) login(c *gin.Context) {
var req loginRequest
if err := c.ShouldBindJSON(&req); err != nil {
@@ -61,6 +72,12 @@ func (h *authHandler) login(c *gin.Context) {
}
// logout 把当前令牌拉黑至自然过期(secured 组内,写请求由系统日志中间件留痕)。
//
// @Summary 登出
// @Tags 认证
// @Success 204 "令牌已吊销"
// @Security BearerAuth
// @Router /api/v1/auth/logout [post]
func (h *authHandler) logout(c *gin.Context) {
token, ok := strings.CutPrefix(c.GetHeader("Authorization"), "Bearer ")
if ok && token != "" {