server_platformconfig.go 1016 B

123456789101112131415161718192021222324252627282930313233
  1. package service
  2. // 考虑到未更新的服务器还会调用此接口
  3. import (
  4. "bet24.com/log"
  5. "bet24.com/servers/coreservice/client"
  6. platformconfig "bet24.com/servers/micros/platformconfig/proto"
  7. "context"
  8. "encoding/json"
  9. "errors"
  10. )
  11. func (s *Server) GetPlatformConfig(ctx context.Context, args *client.Request, reply *client.Reply) error {
  12. reply.Resp.Data = platformconfig.GetConfig(args.Data)
  13. return nil
  14. }
  15. func (s *Server) GetPlatformConfigList(ctx context.Context, args *client.Request, reply *client.Reply) error {
  16. ret := platformconfig.GetConfigList()
  17. d, _ := json.Marshal(ret)
  18. reply.Resp.Data = string(d)
  19. return nil
  20. }
  21. func (s *Server) SetPlatformConfig(ctx context.Context, args *client.Request, reply *client.Reply) error {
  22. var req client.PlatformConfigSet_req
  23. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  24. log.Debug("Server.SetPlatformConfig unmarshal fail %v", err)
  25. return errors.New("unmarshal error")
  26. }
  27. platformconfig.SetConfig(req.Key, req.Value)
  28. return nil
  29. }