setting.go 800 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package http
  2. import (
  3. "go-common/app/admin/main/spy/model"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func settingList(c *bm.Context) {
  9. var (
  10. err error
  11. data []*model.Setting
  12. )
  13. if data, err = spySrv.SettingList(c); err != nil {
  14. c.JSON(nil, err)
  15. return
  16. }
  17. c.JSON(data, err)
  18. }
  19. func updateSetting(c *bm.Context) {
  20. var (
  21. err error
  22. params = c.Request.Form
  23. name = params.Get("name")
  24. prop = params.Get("prop")
  25. val = params.Get("val")
  26. )
  27. if name == "" || prop == "" || val == "" {
  28. c.JSON(nil, ecode.RequestErr)
  29. return
  30. }
  31. if err = spySrv.UpdateSetting(c, name, prop, val); err != nil {
  32. log.Error("s.UpdateSetting(%s,%s,%s) error(%v)", name, prop, val, err)
  33. c.JSON(nil, err)
  34. return
  35. }
  36. c.JSON(nil, nil)
  37. }