// Code generated by gowebx, DO AVOID EDIT. package api import ( "github.com/gin-gonic/gin" "github.com/gowvp/gb28181/internal/core/proxy" "github.com/gowvp/gb28181/internal/core/proxy/store/proxydb" "github.com/gowvp/gb28181/internal/core/uniqueid" "github.com/ixugo/goweb/pkg/orm" "github.com/ixugo/goweb/pkg/web" "gorm.io/gorm" ) type ProxyAPI struct { proxyCore *proxy.Core } func NewProxyAPI(db *gorm.DB, uni uniqueid.Core) ProxyAPI { core := proxy.NewCore(proxydb.NewDB(db).AutoMigrate(orm.EnabledAutoMigrate), uni) return ProxyAPI{proxyCore: core} } func registerProxy(g gin.IRouter, api ProxyAPI, handler ...gin.HandlerFunc) { { group := g.Group("/stream_proxys", handler...) group.GET("", web.WarpH(api.findStreamProxy)) group.GET("/:id", web.WarpH(api.getStreamProxy)) group.PUT("/:id", web.WarpH(api.editStreamProxy)) group.POST("", web.WarpH(api.addStreamProxy)) group.DELETE("/:id", web.WarpH(api.delStreamProxy)) } } // >>> streamProxy >>>>>>>>>>>>>>>>>>>> func (a ProxyAPI) findStreamProxy(c *gin.Context, in *proxy.FindStreamProxyInput) (any, error) { items, total, err := a.proxyCore.FindStreamProxy(c.Request.Context(), in) return gin.H{"items": items, "total": total}, err } func (a ProxyAPI) getStreamProxy(c *gin.Context, _ *struct{}) (any, error) { streamProxyID := c.Param("id") return a.proxyCore.GetStreamProxy(c.Request.Context(), streamProxyID) } func (a ProxyAPI) editStreamProxy(c *gin.Context, in *proxy.EditStreamProxyInput) (any, error) { streamProxyID := c.Param("id") return a.proxyCore.EditStreamProxy(c.Request.Context(), in, streamProxyID) } func (a ProxyAPI) addStreamProxy(c *gin.Context, in *proxy.AddStreamProxyInput) (any, error) { return a.proxyCore.AddStreamProxy(c.Request.Context(), in) } func (a ProxyAPI) delStreamProxy(c *gin.Context, _ *struct{}) (any, error) { streamProxyID := c.Param("id") return a.proxyCore.DelStreamProxy(c.Request.Context(), streamProxyID) }