refactor(api): standardize DTOs and update swagger

Decouple API contract from internal models by introducing dedicated DTOs for requests and responses.
- Add Response DTOs for all resources (API Keys, Bindings, Models, Namespaces, etc.)
- Update Swagger annotations to use DTOs with field examples instead of internal models
- Refactor handlers to bind and return DTO structures
- Consolidate request/response definitions in the dto package
This commit is contained in:
zenfun
2026-01-10 02:05:55 +08:00
parent f52c7acbe6
commit 2098bc4abe
20 changed files with 4156 additions and 3760 deletions

View File

@@ -3,17 +3,24 @@ package api
import (
"net/http"
"github.com/ez-api/ez-api/internal/dto"
"github.com/ez-api/ez-api/internal/service"
"github.com/gin-gonic/gin"
)
// Ensure dto types are referenced for swagger generation
var (
_ dto.LogWebhookConfigResponse
_ dto.UpdateLogWebhookConfigRequest
)
// GetLogWebhookConfig godoc
// @Summary Get log webhook config
// @Description Returns current webhook notification config
// @Tags admin
// @Produce json
// @Security AdminAuth
// @Success 200 {object} ResponseEnvelope{data=service.LogWebhookConfig}
// @Success 200 {object} ResponseEnvelope{data=dto.LogWebhookConfigResponse}
// @Failure 500 {object} ResponseEnvelope{data=MapData}
// @Router /admin/logs/webhook [get]
func (h *Handler) GetLogWebhookConfig(c *gin.Context) {
@@ -36,8 +43,8 @@ func (h *Handler) GetLogWebhookConfig(c *gin.Context) {
// @Accept json
// @Produce json
// @Security AdminAuth
// @Param request body service.LogWebhookConfig true "Webhook config"
// @Success 200 {object} ResponseEnvelope{data=service.LogWebhookConfig}
// @Param request body dto.UpdateLogWebhookConfigRequest true "Webhook config"
// @Success 200 {object} ResponseEnvelope{data=dto.LogWebhookConfigResponse}
// @Failure 400 {object} ResponseEnvelope{data=MapData}
// @Failure 500 {object} ResponseEnvelope{data=MapData}
// @Router /admin/logs/webhook [put]