auto.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package http
  2. import (
  3. "net/http"
  4. "go-common/library/log"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/net/http/blademaster/render"
  7. )
  8. var (
  9. _username = "shaozhenyu"
  10. )
  11. func autoBreach(c *bm.Context) {
  12. var err error
  13. v := new(struct {
  14. Type int `form:"type"`
  15. AIDs []int64 `form:"aids,split" validate:"required"`
  16. MID int64 `form:"mid" validate:"required"`
  17. Reason string `form:"reason" validate:"required"`
  18. })
  19. if err = c.Bind(v); err != nil {
  20. return
  21. }
  22. err = incomeSvr.ArchiveBreach(c, v.Type, v.AIDs, v.MID, v.Reason, _username)
  23. if err != nil {
  24. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  25. "code": 500,
  26. "message": err.Error(),
  27. }))
  28. } else {
  29. c.JSON(nil, nil)
  30. }
  31. }
  32. func autoDismiss(c *bm.Context) {
  33. var err error
  34. v := new(struct {
  35. Type int `form:"type"`
  36. MID int64 `form:"mid" validate:"required"`
  37. Reason string `form:"reason" validate:"required"`
  38. })
  39. if err = c.Bind(v); err != nil {
  40. return
  41. }
  42. err = svr.AutoDismiss(c, _username, v.Type, v.MID, v.Reason)
  43. if err != nil {
  44. log.Error("growup svr.Dismiss error(%v)", err)
  45. }
  46. c.JSON(nil, err)
  47. }
  48. func autoForbid(c *bm.Context) {
  49. var err error
  50. v := new(struct {
  51. Type int `form:"type"`
  52. MID int64 `form:"mid" validate:"required"`
  53. Reason string `form:"reason" validate:"required"`
  54. Days int `form:"days"`
  55. })
  56. if err = c.Bind(v); err != nil {
  57. return
  58. }
  59. err = svr.AutoForbid(c, _username, v.Type, v.MID, v.Reason, v.Days, v.Days*86400)
  60. if err != nil {
  61. log.Error("growup svr.Forbid error(%v)", err)
  62. }
  63. c.JSON(nil, err)
  64. }