label.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package http
  2. import (
  3. "go-common/app/admin/ep/melloi/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/net/http/blademaster/binding"
  7. )
  8. func queryLabels(c *bm.Context) {
  9. c.JSON(srv.QueryLabel(c))
  10. }
  11. func addLabel(c *bm.Context) {
  12. label := model.Label{}
  13. if err := c.BindWith(&label, binding.JSON); err != nil {
  14. c.JSON(nil, err)
  15. return
  16. }
  17. c.JSON(nil, srv.AddLabel(&label))
  18. }
  19. func delLabel(c *bm.Context) {
  20. v := new(struct {
  21. ID int64 `form:"id"`
  22. })
  23. if err := c.Bind(v); err != nil {
  24. c.JSON(nil, ecode.RequestErr)
  25. return
  26. }
  27. c.JSON(nil, srv.DeleteLabel(v.ID))
  28. }
  29. func addLabelRelation(c *bm.Context) {
  30. lr := model.LabelRelation{}
  31. if err := c.BindWith(&lr, binding.JSON); err != nil {
  32. c.JSON(nil, err)
  33. return
  34. }
  35. c.JSON(nil, srv.AddLabelRelation(&lr))
  36. }
  37. func delLabelRelation(c *bm.Context) {
  38. v := new(struct {
  39. ID int64 `form:"id"`
  40. })
  41. if err := c.Bind(v); err != nil {
  42. c.JSON(nil, ecode.RequestErr)
  43. return
  44. }
  45. c.JSON(nil, srv.DeleteLabelRelation(v.ID))
  46. }