| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- package v1
- import (
- "dsbqj-admin/app/service"
- "dsbqj-admin/pkg/app"
- "dsbqj-admin/pkg/e"
- "dsbqj-admin/pkg/serializer"
- "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())
- }
- }
- func PlatformList(c *gin.Context) {
- var g = app.Gin{C: c}
- v, err := (&service.PlatformListService{}).List()
- if err != nil {
- g.Response(http.StatusOK, e.ERROR, err.Error())
- return
- }
- g.Response(http.StatusOK, e.SUCCESS, serializer.BuildPlatformList(v))
- }
- func PlatformCreate(c *gin.Context) {
- var g = app.Gin{C: c}
- var s service.PlatformCreateService
- if err := c.ShouldBindJSON(&s); err != nil {
- g.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
- return
- }
- g.Response(http.StatusOK, e.SUCCESS, s.Create())
- }
- func PlatformUpdate(c *gin.Context) {
- var g = app.Gin{C: c}
- var s service.PlatformUpdateService
- if err := c.ShouldBindJSON(&s); err != nil {
- g.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
- return
- }
- g.Response(http.StatusOK, e.SUCCESS, s.Update())
- }
- func PlatformDelete(c *gin.Context) {
- var g = app.Gin{C: c}
- var s service.PlatformDeleteService
- if err := c.ShouldBindJSON(&s); err != nil {
- g.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
- return
- }
- g.Response(http.StatusOK, e.SUCCESS, s.Delete())
- }
- // 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)
- }
|