app.go 951 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package http
  2. import (
  3. "go-common/app/interface/bbq/app-bbq/api/http/v1"
  4. bm "go-common/library/net/http/blademaster"
  5. "strings"
  6. "github.com/json-iterator/go"
  7. )
  8. func appSetting(c *bm.Context) {
  9. args := &v1.AppSettingRequest{}
  10. if err := c.Bind(args); err != nil {
  11. return
  12. }
  13. data, err := srv.AppSetting(c, args)
  14. if err != nil {
  15. c.JSON(nil, err)
  16. return
  17. }
  18. if strings.ToLower(args.Base.Client) == "ios" {
  19. c.JSON(data, err)
  20. return
  21. }
  22. resp := struct {
  23. Code int `json:"code"`
  24. Message string `json:"message"`
  25. TTL int `json:"ttl"`
  26. Data interface{} `json:"data,omitempty"`
  27. }{
  28. Code: 0,
  29. Message: "0",
  30. TTL: 1,
  31. Data: data,
  32. }
  33. str, _ := jsoniter.MarshalToString(resp)
  34. c.String(0, strings.Replace(str, "\\\\", "\\", -1))
  35. }
  36. func appPackage(c *bm.Context) {
  37. args := struct {
  38. Lastest int `json:"lastest" form:"lastest"`
  39. }{}
  40. c.Bind(&args)
  41. c.JSON(srv.AppPackage(c, args.Lastest))
  42. }