You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dataset.go 1.2 kB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/casbin/casvisor/object"
  5. )
  6. func (c *ApiController) GetGlobalDatasets() {
  7. c.Data["json"] = object.GetGlobalDatasets()
  8. c.ServeJSON()
  9. }
  10. func (c *ApiController) GetDatasets() {
  11. owner := c.Input().Get("owner")
  12. c.Data["json"] = object.GetDatasets(owner)
  13. c.ServeJSON()
  14. }
  15. func (c *ApiController) GetDataset() {
  16. id := c.Input().Get("id")
  17. c.Data["json"] = object.GetDataset(id)
  18. c.ServeJSON()
  19. }
  20. func (c *ApiController) UpdateDataset() {
  21. id := c.Input().Get("id")
  22. var dataset object.Dataset
  23. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataset)
  24. if err != nil {
  25. panic(err)
  26. }
  27. c.Data["json"] = object.UpdateDataset(id, &dataset)
  28. c.ServeJSON()
  29. }
  30. func (c *ApiController) AddDataset() {
  31. var dataset object.Dataset
  32. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataset)
  33. if err != nil {
  34. panic(err)
  35. }
  36. c.Data["json"] = object.AddDataset(&dataset)
  37. c.ServeJSON()
  38. }
  39. func (c *ApiController) DeleteDataset() {
  40. var dataset object.Dataset
  41. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataset)
  42. if err != nil {
  43. panic(err)
  44. }
  45. c.Data["json"] = object.DeleteDataset(&dataset)
  46. c.ServeJSON()
  47. }

No Description

Contributors (1)