activity.go 978 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package http
  2. import (
  3. "go-common/library/ecode"
  4. "go-common/library/log"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func showActivity(c *bm.Context) {
  8. v := new(struct {
  9. ActivityID int64 `form:"activity_id" validate:"required"`
  10. })
  11. if err := c.Bind(v); err != nil {
  12. return
  13. }
  14. midI, ok := c.Get("mid")
  15. if !ok {
  16. c.JSON(nil, ecode.NoLogin)
  17. return
  18. }
  19. mid, _ := midI.(int64)
  20. data, err := svc.ShowActivity(c, mid, v.ActivityID)
  21. if err != nil {
  22. log.Error("svc.ShowActivity error(%v)", err)
  23. c.JSON(nil, err)
  24. return
  25. }
  26. c.JSON(data, nil)
  27. }
  28. func signUpActivity(c *bm.Context) {
  29. var err error
  30. v := new(struct {
  31. ActivityID int64 `form:"activity_id" validate:"required"`
  32. })
  33. if err = c.Bind(v); err != nil {
  34. return
  35. }
  36. midI, ok := c.Get("mid")
  37. if !ok {
  38. c.JSON(nil, ecode.NoLogin)
  39. return
  40. }
  41. mid, _ := midI.(int64)
  42. if err = svc.SignUpActivity(c, mid, v.ActivityID); err != nil {
  43. log.Error("svc.SignUpActivity error(%v)", err)
  44. }
  45. c.JSON(nil, err)
  46. }