channel.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package v1
  2. import (
  3. "dsbqj-admin/app/service"
  4. "dsbqj-admin/pkg/app"
  5. "dsbqj-admin/pkg/e"
  6. "net/http"
  7. "github.com/gin-gonic/gin"
  8. )
  9. func ChannelAll(c *gin.Context) {
  10. var appG = app.Gin{C: c}
  11. service := service.GameChannelService{}
  12. if err := c.ShouldBind(&service); err == nil {
  13. if res, err := service.All(); err != nil {
  14. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  15. } else {
  16. appG.Response(http.StatusOK, e.SUCCESS, res)
  17. }
  18. } else {
  19. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  20. }
  21. }
  22. // ChannelList 渠道列表
  23. func ChannelList(c *gin.Context) {
  24. var appG = app.Gin{C: c}
  25. var svc service.ChannelListService
  26. if err := c.ShouldBindQuery(&svc); err != nil {
  27. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  28. return
  29. }
  30. res, err := svc.List()
  31. if err != nil {
  32. appG.Response(http.StatusOK, e.ERROR, err.Error())
  33. return
  34. }
  35. appG.Response(http.StatusOK, e.SUCCESS, res)
  36. }
  37. // ChannelCreate 渠道新增
  38. func ChannelCreate(c *gin.Context) {
  39. var appG = app.Gin{C: c}
  40. var svc service.ChannelCreateService
  41. if err := c.ShouldBindJSON(&svc); err != nil {
  42. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  43. return
  44. }
  45. if err := svc.Create(); err != nil {
  46. appG.Response(http.StatusOK, e.ERROR, err.Error())
  47. return
  48. }
  49. appG.Response(http.StatusOK, e.SUCCESS, nil)
  50. }
  51. // ChannelUpdate 渠道修改
  52. func ChannelUpdate(c *gin.Context) {
  53. var appG = app.Gin{C: c}
  54. var svc service.ChannelUpdateService
  55. if err := c.ShouldBindJSON(&svc); err != nil {
  56. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  57. return
  58. }
  59. if err := svc.Update(); err != nil {
  60. appG.Response(http.StatusOK, e.ERROR, err.Error())
  61. return
  62. }
  63. appG.Response(http.StatusOK, e.SUCCESS, nil)
  64. }
  65. // ChannelDelete 渠道删除
  66. func ChannelDelete(c *gin.Context) {
  67. var appG = app.Gin{C: c}
  68. var svc service.ChannelDeleteService
  69. if err := c.ShouldBindJSON(&svc); err != nil {
  70. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  71. return
  72. }
  73. if err := svc.Delete(); err != nil {
  74. appG.Response(http.StatusOK, e.ERROR, err.Error())
  75. return
  76. }
  77. appG.Response(http.StatusOK, e.SUCCESS, nil)
  78. }