mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
ai路由完成
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package ai_api
|
||||
|
||||
import (
|
||||
ai_api_dto "github.com/APIParkLab/APIPark/module/ai-api/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type IAPIController interface {
|
||||
Create(ctx *gin.Context, serviceId string, input *ai_api_dto.CreateAPI) (*ai_api_dto.API, error)
|
||||
Edit(ctx *gin.Context, serviceId string, apiId string, input *ai_api_dto.EditAPI) (*ai_api_dto.API, error)
|
||||
Delete(ctx *gin.Context, serviceId string, apiId string) error
|
||||
List(ctx *gin.Context, keyword string, serviceId string) ([]*ai_api_dto.APIItem, error)
|
||||
Get(ctx *gin.Context, serviceId string, apiId string) (*ai_api_dto.API, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IAPIController](func() reflect.Value {
|
||||
m := new(imlAPIController)
|
||||
return reflect.ValueOf(m)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package ai_api
|
||||
|
||||
import (
|
||||
ai_api "github.com/APIParkLab/APIPark/module/ai-api"
|
||||
ai_api_dto "github.com/APIParkLab/APIPark/module/ai-api/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var _ IAPIController = (*imlAPIController)(nil)
|
||||
|
||||
type imlAPIController struct {
|
||||
module ai_api.IAPIModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Create(ctx *gin.Context, serviceId string, input *ai_api_dto.CreateAPI) (*ai_api_dto.API, error) {
|
||||
return i.module.Create(ctx, serviceId, input)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Edit(ctx *gin.Context, serviceId string, apiId string, input *ai_api_dto.EditAPI) (*ai_api_dto.API, error) {
|
||||
return i.module.Edit(ctx, serviceId, apiId, input)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Delete(ctx *gin.Context, serviceId string, apiId string) error {
|
||||
return i.module.Delete(ctx, serviceId, apiId)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) List(ctx *gin.Context, keyword string, serviceId string) ([]*ai_api_dto.APIItem, error) {
|
||||
return i.module.List(ctx, keyword, serviceId)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Get(ctx *gin.Context, serviceId string, apiId string) (*ai_api_dto.API, error) {
|
||||
return i.module.Get(ctx, serviceId, apiId)
|
||||
}
|
||||
Reference in New Issue
Block a user