docs: add Swagger annotations to 5 handlers
Add comprehensive Swagger/Swagger comments to: - export_handler.go (ExportUsers, ImportUsers, GetImportTemplate) - sms_handler.go (SendCode, LoginByCode) - sso_handler.go (Authorize, Token, Introspect, Revoke, UserInfo) - theme_handler.go (8 endpoints) - webhook_handler.go (5 endpoints) All 18 handlers now have Swagger annotations.
This commit is contained in:
@@ -20,6 +20,18 @@ func NewThemeHandler(themeService *service.ThemeService) *ThemeHandler {
|
||||
}
|
||||
|
||||
// CreateTheme 创建主题
|
||||
// @Summary 创建主题
|
||||
// @Description 创建新的主题配置
|
||||
// @Tags 主题管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param request body service.CreateThemeRequest true "主题信息"
|
||||
// @Success 201 {object} Response{data=domain.Theme} "主题创建成功"
|
||||
// @Failure 400 {object} Response "请求参数错误"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/themes [post]
|
||||
func (h *ThemeHandler) CreateTheme(c *gin.Context) {
|
||||
var req service.CreateThemeRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -41,6 +53,19 @@ func (h *ThemeHandler) CreateTheme(c *gin.Context) {
|
||||
}
|
||||
|
||||
// UpdateTheme 更新主题
|
||||
// @Summary 更新主题
|
||||
// @Description 更新指定主题的配置
|
||||
// @Tags 主题管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "主题ID"
|
||||
// @Param request body service.UpdateThemeRequest true "更新信息"
|
||||
// @Success 200 {object} Response{data=domain.Theme} "主题更新成功"
|
||||
// @Failure 400 {object} Response "请求参数错误"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/themes/{id} [put]
|
||||
func (h *ThemeHandler) UpdateTheme(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
@@ -68,6 +93,17 @@ func (h *ThemeHandler) UpdateTheme(c *gin.Context) {
|
||||
}
|
||||
|
||||
// DeleteTheme 删除主题
|
||||
// @Summary 删除主题
|
||||
// @Description 删除指定的主题
|
||||
// @Tags 主题管理
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "主题ID"
|
||||
// @Success 200 {object} Response "主题删除成功"
|
||||
// @Failure 400 {object} Response "请求参数错误"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/themes/{id} [delete]
|
||||
func (h *ThemeHandler) DeleteTheme(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
@@ -87,6 +123,17 @@ func (h *ThemeHandler) DeleteTheme(c *gin.Context) {
|
||||
}
|
||||
|
||||
// GetTheme 获取主题
|
||||
// @Summary 获取主题
|
||||
// @Description 根据ID获取主题详情
|
||||
// @Tags 主题管理
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "主题ID"
|
||||
// @Success 200 {object} Response{data=domain.Theme} "主题详情"
|
||||
// @Failure 400 {object} Response "请求参数错误"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/themes/{id} [get]
|
||||
func (h *ThemeHandler) GetTheme(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
@@ -107,7 +154,16 @@ func (h *ThemeHandler) GetTheme(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// ListThemes 获取所有主题
|
||||
// ListThemes 获取主题列表
|
||||
// @Summary 获取主题列表
|
||||
// @Description 获取所有已启用的主题
|
||||
// @Tags 主题管理
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} Response{data=[]domain.Theme} "主题列表"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/themes [get]
|
||||
func (h *ThemeHandler) ListThemes(c *gin.Context) {
|
||||
themes, err := h.themeService.ListThemes(c.Request.Context())
|
||||
if err != nil {
|
||||
@@ -123,6 +179,15 @@ func (h *ThemeHandler) ListThemes(c *gin.Context) {
|
||||
}
|
||||
|
||||
// ListAllThemes 获取所有主题(包括禁用的)
|
||||
// @Summary 获取所有主题
|
||||
// @Description 获取所有主题(包括已禁用的)
|
||||
// @Tags 主题管理
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} Response{data=[]domain.Theme} "主题列表"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/themes/all [get]
|
||||
func (h *ThemeHandler) ListAllThemes(c *gin.Context) {
|
||||
themes, err := h.themeService.ListAllThemes(c.Request.Context())
|
||||
if err != nil {
|
||||
@@ -138,6 +203,15 @@ func (h *ThemeHandler) ListAllThemes(c *gin.Context) {
|
||||
}
|
||||
|
||||
// GetDefaultTheme 获取默认主题
|
||||
// @Summary 获取默认主题
|
||||
// @Description 获取系统默认主题
|
||||
// @Tags 主题管理
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} Response{data=domain.Theme} "默认主题"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/themes/default [get]
|
||||
func (h *ThemeHandler) GetDefaultTheme(c *gin.Context) {
|
||||
theme, err := h.themeService.GetDefaultTheme(c.Request.Context())
|
||||
if err != nil {
|
||||
@@ -153,6 +227,17 @@ func (h *ThemeHandler) GetDefaultTheme(c *gin.Context) {
|
||||
}
|
||||
|
||||
// SetDefaultTheme 设置默认主题
|
||||
// @Summary 设置默认主题
|
||||
// @Description 将指定主题设为系统默认主题
|
||||
// @Tags 主题管理
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path int true "主题ID"
|
||||
// @Success 200 {object} Response "设置成功"
|
||||
// @Failure 400 {object} Response "请求参数错误"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/themes/{id}/default [put]
|
||||
func (h *ThemeHandler) SetDefaultTheme(c *gin.Context) {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
@@ -171,7 +256,14 @@ func (h *ThemeHandler) SetDefaultTheme(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// GetActiveTheme 获取当前生效的主题(公开接口)
|
||||
// GetActiveTheme 获取当前生效的主题
|
||||
// @Summary 获取当前生效的主题
|
||||
// @Description 获取当前系统正在使用的主题(公开接口)
|
||||
// @Tags 主题管理
|
||||
// @Produce json
|
||||
// @Success 200 {object} Response{data=domain.Theme} "当前生效主题"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/themes/active [get]
|
||||
func (h *ThemeHandler) GetActiveTheme(c *gin.Context) {
|
||||
theme, err := h.themeService.GetActiveTheme(c.Request.Context())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user