package v1 import ( "dsbqj-admin/app/service" "dsbqj-admin/pkg/app" "dsbqj-admin/pkg/e" "net/http" "github.com/gin-gonic/gin" ) func ChannelAll(c *gin.Context) { var appG = app.Gin{C: c} service := service.GameChannelService{} if err := c.ShouldBind(&service); err == nil { if res, err := service.All(); err != nil { appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error()) } else { appG.Response(http.StatusOK, e.SUCCESS, res) } } else { appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error()) } } // ChannelList 渠道列表 func ChannelList(c *gin.Context) { var appG = app.Gin{C: c} var svc service.ChannelListService if err := c.ShouldBindQuery(&svc); err != nil { appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error()) return } res, err := svc.List() if err != nil { appG.Response(http.StatusOK, e.ERROR, err.Error()) return } appG.Response(http.StatusOK, e.SUCCESS, res) } // ChannelCreate 渠道新增 func ChannelCreate(c *gin.Context) { var appG = app.Gin{C: c} var svc service.ChannelCreateService if err := c.ShouldBindJSON(&svc); err != nil { appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error()) return } if err := svc.Create(); err != nil { appG.Response(http.StatusOK, e.ERROR, err.Error()) return } appG.Response(http.StatusOK, e.SUCCESS, nil) } // ChannelUpdate 渠道修改 func ChannelUpdate(c *gin.Context) { var appG = app.Gin{C: c} var svc service.ChannelUpdateService if err := c.ShouldBindJSON(&svc); err != nil { appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error()) return } if err := svc.Update(); err != nil { appG.Response(http.StatusOK, e.ERROR, err.Error()) return } appG.Response(http.StatusOK, e.SUCCESS, nil) } // ChannelDelete 渠道删除 func ChannelDelete(c *gin.Context) { var appG = app.Gin{C: c} var svc service.ChannelDeleteService if err := c.ShouldBindJSON(&svc); err != nil { appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error()) return } if err := svc.Delete(); err != nil { appG.Response(http.StatusOK, e.ERROR, err.Error()) return } appG.Response(http.StatusOK, e.SUCCESS, nil) }