group.go 944 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package http
  2. import (
  3. "go-common/app/service/openplatform/abtest/model"
  4. "go-common/app/service/openplatform/abtest/model/validator"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. //add group
  8. func addGroup(c *bm.Context) {
  9. params := new(validator.AddGroupParams)
  10. if err := c.Bind(params); err != nil {
  11. return
  12. }
  13. g := model.Group{
  14. Name: params.Name,
  15. Desc: params.Desc,
  16. }
  17. c.JSON(abSvr.AddGroup(c, g))
  18. }
  19. //list group
  20. func listGroup(c *bm.Context) {
  21. c.JSON(abSvr.ListGroup(c))
  22. }
  23. //update group
  24. func updateGroup(c *bm.Context) {
  25. params := new(validator.UpdateGroupParams)
  26. if err := c.Bind(params); err != nil {
  27. return
  28. }
  29. g := model.Group{
  30. ID: params.ID,
  31. Name: params.Name,
  32. Desc: params.Desc,
  33. }
  34. c.JSON(abSvr.UpdateGroup(c, g))
  35. }
  36. //delete group
  37. func deleteGroup(c *bm.Context) {
  38. params := new(validator.DeleteGroupParams)
  39. if err := c.Bind(params); err != nil {
  40. return
  41. }
  42. c.JSON(abSvr.DeleteGroup(c, params.ID))
  43. }