docs(api): 补全 OpenAPI 注释与生成文档
为接口、模型与脚本补齐 Swagger/OpenAPI 注释,生成最新文档,并增加一键生成与查看入口。
This commit is contained in:
@@ -9,6 +9,17 @@ import (
|
||||
"github.com/easyai/easyai-ai-gateway/apps/api/internal/store"
|
||||
)
|
||||
|
||||
// listPricingRuleSets godoc
|
||||
// @Summary 列出定价规则集
|
||||
// @Description 管理端返回可分配给平台、模型、租户或用户组的定价规则集。
|
||||
// @Tags pricing
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} PricingRuleSetListResponse
|
||||
// @Failure 401 {object} ErrorEnvelope
|
||||
// @Failure 403 {object} ErrorEnvelope
|
||||
// @Failure 500 {object} ErrorEnvelope
|
||||
// @Router /api/admin/pricing/rule-sets [get]
|
||||
func (s *Server) listPricingRuleSets(w http.ResponseWriter, r *http.Request) {
|
||||
items, err := s.store.ListPricingRuleSets(r.Context())
|
||||
if err != nil {
|
||||
@@ -19,6 +30,21 @@ func (s *Server) listPricingRuleSets(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusOK, map[string]any{"items": items})
|
||||
}
|
||||
|
||||
// createPricingRuleSet godoc
|
||||
// @Summary 创建定价规则集
|
||||
// @Description 管理端创建定价规则集,ruleSetKey、name 和至少一条 rule 必填。
|
||||
// @Tags pricing
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param input body store.PricingRuleSetInput true "定价规则集请求"
|
||||
// @Success 201 {object} store.PricingRuleSet
|
||||
// @Failure 400 {object} ErrorEnvelope
|
||||
// @Failure 401 {object} ErrorEnvelope
|
||||
// @Failure 403 {object} ErrorEnvelope
|
||||
// @Failure 409 {object} ErrorEnvelope
|
||||
// @Failure 500 {object} ErrorEnvelope
|
||||
// @Router /api/admin/pricing/rule-sets [post]
|
||||
func (s *Server) createPricingRuleSet(w http.ResponseWriter, r *http.Request) {
|
||||
var input store.PricingRuleSetInput
|
||||
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
|
||||
@@ -42,6 +68,23 @@ func (s *Server) createPricingRuleSet(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusCreated, item)
|
||||
}
|
||||
|
||||
// updatePricingRuleSet godoc
|
||||
// @Summary 更新定价规则集
|
||||
// @Description 管理端更新定价规则集及其规则列表。
|
||||
// @Tags pricing
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param ruleSetID path string true "定价规则集 ID"
|
||||
// @Param input body store.PricingRuleSetInput true "定价规则集请求"
|
||||
// @Success 200 {object} store.PricingRuleSet
|
||||
// @Failure 400 {object} ErrorEnvelope
|
||||
// @Failure 401 {object} ErrorEnvelope
|
||||
// @Failure 403 {object} ErrorEnvelope
|
||||
// @Failure 404 {object} ErrorEnvelope
|
||||
// @Failure 409 {object} ErrorEnvelope
|
||||
// @Failure 500 {object} ErrorEnvelope
|
||||
// @Router /api/admin/pricing/rule-sets/{ruleSetID} [patch]
|
||||
func (s *Server) updatePricingRuleSet(w http.ResponseWriter, r *http.Request) {
|
||||
var input store.PricingRuleSetInput
|
||||
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
|
||||
@@ -69,6 +112,19 @@ func (s *Server) updatePricingRuleSet(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusOK, item)
|
||||
}
|
||||
|
||||
// deletePricingRuleSet godoc
|
||||
// @Summary 删除定价规则集
|
||||
// @Description 管理端删除非默认定价规则集;默认规则集受保护。
|
||||
// @Tags pricing
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param ruleSetID path string true "定价规则集 ID"
|
||||
// @Success 204 "No Content"
|
||||
// @Failure 401 {object} ErrorEnvelope
|
||||
// @Failure 403 {object} ErrorEnvelope
|
||||
// @Failure 404 {object} ErrorEnvelope
|
||||
// @Failure 500 {object} ErrorEnvelope
|
||||
// @Router /api/admin/pricing/rule-sets/{ruleSetID} [delete]
|
||||
func (s *Server) deletePricingRuleSet(w http.ResponseWriter, r *http.Request) {
|
||||
if err := s.store.DeletePricingRuleSet(r.Context(), r.PathValue("ruleSetID")); err != nil {
|
||||
if store.IsNotFound(err) {
|
||||
|
||||
Reference in New Issue
Block a user