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,21 @@ func NewExportHandler(exportService *service.ExportService) *ExportHandler {
|
||||
return &ExportHandler{exportService: exportService}
|
||||
}
|
||||
|
||||
// ExportUsers 导出用户
|
||||
// @Summary 导出用户数据
|
||||
// @Description 导出用户数据为 CSV 或 Excel 格式
|
||||
// @Tags 数据导入导出
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param format query string false "导出格式" default(csv) Enums(csv, excel)
|
||||
// @Param fields query string false "导出字段,逗号分隔"
|
||||
// @Param keyword query string false "关键词过滤"
|
||||
// @Param status query int false "用户状态过滤"
|
||||
// @Success 200 {file} file "用户数据文件"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/exports/users [get]
|
||||
func (h *ExportHandler) ExportUsers(c *gin.Context) {
|
||||
format := c.DefaultQuery("format", "csv")
|
||||
fieldsStr := c.Query("fields")
|
||||
@@ -57,6 +72,20 @@ func (h *ExportHandler) ExportUsers(c *gin.Context) {
|
||||
c.Data(http.StatusOK, contentType, data)
|
||||
}
|
||||
|
||||
// ImportUsers 导入用户
|
||||
// @Summary 导入用户数据
|
||||
// @Description 从 CSV 或 Excel 文件导入用户数据
|
||||
// @Tags 数据导入导出
|
||||
// @Accept multipart/form-data
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param file formData file true "导入文件"
|
||||
// @Param format query string false "文件格式" default(csv) Enums(csv, excel)
|
||||
// @Success 200 {object} Response "导入结果"
|
||||
// @Failure 400 {object} Response "请求参数错误"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/exports/users [post]
|
||||
func (h *ExportHandler) ImportUsers(c *gin.Context) {
|
||||
file, _, err := c.Request.FormFile("file")
|
||||
if err != nil {
|
||||
@@ -84,6 +113,17 @@ func (h *ExportHandler) ImportUsers(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// GetImportTemplate 获取导入模板
|
||||
// @Summary 获取用户导入模板
|
||||
// @Description 下载用户批量导入的 CSV 或 Excel 模板
|
||||
// @Tags 数据导入导出
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param format query string false "模板格式" default(csv) Enums(csv, excel)
|
||||
// @Success 200 {file} file "导入模板文件"
|
||||
// @Failure 401 {object} Response "未认证"
|
||||
// @Failure 500 {object} Response "服务器错误"
|
||||
// @Router /api/v1/exports/template [get]
|
||||
func (h *ExportHandler) GetImportTemplate(c *gin.Context) {
|
||||
format := c.DefaultQuery("format", "csv")
|
||||
data, filename, contentType, err := h.exportService.GetImportTemplateByFormat(format)
|
||||
|
||||
Reference in New Issue
Block a user