channel.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. // ChannelList 渠道列表
  10. func ChannelList(c *gin.Context) {
  11. var appG = app.Gin{C: c}
  12. var svc service.ChannelListService
  13. if err := c.ShouldBindQuery(&svc); err != nil {
  14. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  15. return
  16. }
  17. res, err := svc.List()
  18. if err != nil {
  19. appG.Response(http.StatusOK, e.ERROR, err.Error())
  20. return
  21. }
  22. appG.Response(http.StatusOK, e.SUCCESS, res)
  23. }
  24. // ChannelCreate 渠道新增
  25. func ChannelCreate(c *gin.Context) {
  26. var appG = app.Gin{C: c}
  27. var svc service.ChannelCreateService
  28. if err := c.ShouldBindJSON(&svc); err != nil {
  29. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  30. return
  31. }
  32. if err := svc.Create(); err != nil {
  33. appG.Response(http.StatusOK, e.ERROR, err.Error())
  34. return
  35. }
  36. appG.Response(http.StatusOK, e.SUCCESS, nil)
  37. }
  38. // ChannelUpdate 渠道修改
  39. func ChannelUpdate(c *gin.Context) {
  40. var appG = app.Gin{C: c}
  41. var svc service.ChannelUpdateService
  42. if err := c.ShouldBindJSON(&svc); err != nil {
  43. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  44. return
  45. }
  46. if err := svc.Update(); err != nil {
  47. appG.Response(http.StatusOK, e.ERROR, err.Error())
  48. return
  49. }
  50. appG.Response(http.StatusOK, e.SUCCESS, nil)
  51. }
  52. // ChannelDelete 渠道删除
  53. func ChannelDelete(c *gin.Context) {
  54. var appG = app.Gin{C: c}
  55. var svc service.ChannelDeleteService
  56. if err := c.ShouldBindJSON(&svc); err != nil {
  57. appG.Response(http.StatusOK, e.INVALID_PARAMS, err.Error())
  58. return
  59. }
  60. if err := svc.Delete(); err != nil {
  61. appG.Response(http.StatusOK, e.ERROR, err.Error())
  62. return
  63. }
  64. appG.Response(http.StatusOK, e.SUCCESS, nil)
  65. }