dialog.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package http
  2. import (
  3. "go-common/app/admin/main/vip/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func dialogList(c *bm.Context) {
  8. arg := new(struct {
  9. AppID int64 `form:"app_id"`
  10. Platform int64 `form:"platform"`
  11. Status string `form:"status"`
  12. })
  13. if err := c.Bind(arg); err != nil {
  14. return
  15. }
  16. c.JSON(vipSvc.DialogAll(c, arg.AppID, arg.Platform, arg.Status))
  17. }
  18. func dialogInfo(c *bm.Context) {
  19. arg := new(model.ArgID)
  20. if err := c.Bind(arg); err != nil {
  21. return
  22. }
  23. c.JSON(vipSvc.DialogByID(c, arg))
  24. }
  25. func dialogSave(c *bm.Context) {
  26. arg := new(model.ConfDialog)
  27. if err := c.Bind(arg); err != nil {
  28. return
  29. }
  30. if arg.StartTime != 0 && arg.EndTime != 0 && arg.StartTime >= arg.EndTime {
  31. c.JSON(nil, ecode.VipDialogTimeErr)
  32. return
  33. }
  34. username, ok := c.Get("username")
  35. if !ok {
  36. c.JSON(nil, ecode.AccessDenied)
  37. return
  38. }
  39. arg.Operator = username.(string)
  40. c.JSON(vipSvc.DialogSave(c, arg))
  41. }
  42. func dialogEnable(c *bm.Context) {
  43. arg := new(struct {
  44. ID int64 `form:"id" validate:"required"`
  45. Stage bool `form:"stage"`
  46. })
  47. if err := c.Bind(arg); err != nil {
  48. return
  49. }
  50. username, ok := c.Get("username")
  51. if !ok {
  52. c.JSON(nil, ecode.AccessDenied)
  53. return
  54. }
  55. c.JSON(vipSvc.DialogEnable(c, &model.ConfDialog{ID: arg.ID, Stage: arg.Stage, Operator: username.(string)}))
  56. }
  57. func dialogDel(c *bm.Context) {
  58. arg := new(model.ArgID)
  59. if err := c.Bind(arg); err != nil {
  60. return
  61. }
  62. username, ok := c.Get("username")
  63. if !ok {
  64. c.JSON(nil, ecode.AccessDenied)
  65. return
  66. }
  67. c.JSON(vipSvc.DialogDel(c, arg, username.(string)))
  68. }