log_delete.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package http
  2. import (
  3. "go-common/app/admin/main/search/model"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func logDelete(c *bm.Context) {
  9. form := c.Request.Form
  10. appidStr := form.Get("appid")
  11. switch appidStr {
  12. case "log_audit":
  13. logAuditDelete(c)
  14. case "log_user_action":
  15. logUserActionDelete(c)
  16. default:
  17. c.JSON(nil, ecode.RequestErr)
  18. }
  19. }
  20. func logAuditDelete(c *bm.Context) {
  21. var (
  22. err error
  23. sp = &model.LogParams{
  24. Bsp: &model.BasicSearchParams{},
  25. }
  26. )
  27. if err = c.Bind(sp); err != nil {
  28. c.JSON(nil, ecode.RequestErr)
  29. return
  30. }
  31. if err = c.Bind(sp.Bsp); err != nil {
  32. c.JSON(nil, ecode.RequestErr)
  33. return
  34. }
  35. business, ok := svr.Check("log_audit", sp.Business)
  36. if !ok {
  37. c.JSON(nil, ecode.RequestErr)
  38. return
  39. }
  40. res, err := svr.LogAuditDelete(c, c.Request.Form, sp, business)
  41. if err != nil {
  42. log.Error("srv.LogAuditDelete(%v) error(%v)", sp, err)
  43. c.JSON(nil, err)
  44. return
  45. }
  46. c.JSON(res, err)
  47. }
  48. func logUserActionDelete(c *bm.Context) {
  49. var (
  50. err error
  51. sp = &model.LogParams{
  52. Bsp: &model.BasicSearchParams{},
  53. }
  54. )
  55. if err = c.Bind(sp); err != nil {
  56. c.JSON(nil, ecode.RequestErr)
  57. return
  58. }
  59. if err = c.Bind(sp.Bsp); err != nil {
  60. c.JSON(nil, ecode.RequestErr)
  61. return
  62. }
  63. business, ok := svr.Check("log_user_action", sp.Business)
  64. if !ok {
  65. c.JSON(nil, ecode.RequestErr)
  66. return
  67. }
  68. res, err := svr.LogUserActionDelete(c, c.Request.Form, sp, business)
  69. if err != nil {
  70. log.Error("srv.logUserActionDelete(%v) error(%v)", sp, err)
  71. c.JSON(nil, err)
  72. return
  73. }
  74. c.JSON(res, err)
  75. }