mirror of
https://github.com/gowvp/gb28181.git
synced 2025-10-25 00:10:35 +08:00
55 lines
1.7 KiB
Go
Executable File
55 lines
1.7 KiB
Go
Executable File
// Code generated by gowebx, DO AVOID EDIT.
|
|
package api
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gowvp/gb28181/internal/core/media"
|
|
"github.com/ixugo/goweb/pkg/web"
|
|
)
|
|
|
|
type MediaAPI struct {
|
|
mediaCore media.Core
|
|
}
|
|
|
|
// NewMediaAPI 媒体相关接口
|
|
func NewMediaAPI(mc media.Core) MediaAPI {
|
|
return MediaAPI{mediaCore: mc}
|
|
}
|
|
|
|
func registerMediaAPI(g gin.IRouter, api MediaAPI, handler ...gin.HandlerFunc) {
|
|
{
|
|
group := g.Group("/stream_pushs", handler...)
|
|
group.GET("", web.WarpH(api.findStreamPush))
|
|
group.GET("/:id", web.WarpH(api.getStreamPush))
|
|
group.PUT("/:id", web.WarpH(api.editStreamPush))
|
|
group.POST("", web.WarpH(api.addStreamPush))
|
|
group.DELETE("/:id", web.WarpH(api.delStreamPush))
|
|
}
|
|
}
|
|
|
|
// >>> streamPush >>>>>>>>>>>>>>>>>>>>
|
|
|
|
func (a MediaAPI) findStreamPush(c *gin.Context, in *media.FindStreamPushInput) (any, error) {
|
|
items, total, err := a.mediaCore.FindStreamPush(c.Request.Context(), in)
|
|
return gin.H{"items": items, "total": total}, err
|
|
}
|
|
|
|
func (a MediaAPI) getStreamPush(c *gin.Context, _ *struct{}) (any, error) {
|
|
streamPushID := c.Param("id")
|
|
return a.mediaCore.GetStreamPush(c.Request.Context(), streamPushID)
|
|
}
|
|
|
|
func (a MediaAPI) editStreamPush(c *gin.Context, in *media.EditStreamPushInput) (any, error) {
|
|
streamPushID := c.Param("id")
|
|
return a.mediaCore.EditStreamPush(c.Request.Context(), in, streamPushID)
|
|
}
|
|
|
|
func (a MediaAPI) addStreamPush(c *gin.Context, in *media.AddStreamPushInput) (any, error) {
|
|
return a.mediaCore.AddStreamPush(c.Request.Context(), in)
|
|
}
|
|
|
|
func (a MediaAPI) delStreamPush(c *gin.Context, _ *struct{}) (any, error) {
|
|
streamPushID := c.Param("id")
|
|
return a.mediaCore.DelStreamPush(c.Request.Context(), streamPushID)
|
|
}
|