user_switch.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package gatesink
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "bet24.com/log"
  6. userservices "bet24.com/servers/micros/userservices/proto"
  7. )
  8. // 设置开关(旁观、跟踪)
  9. func (this *user) setSwitchInfo(msg, data string) {
  10. usr := userservices.GetUserInfo(this.getUserId())
  11. if usr == nil {
  12. log.Release("user.setSwitchInfo fail to query user info")
  13. this.WriteMsg(msg, "user not found")
  14. return
  15. }
  16. var req userservices.Request_Switch
  17. err := json.Unmarshal([]byte(data), &req)
  18. if err != nil {
  19. retData := fmt.Sprintf("setSwitchInfo Unmarshal data failed %v", data)
  20. log.Release(retData)
  21. this.WriteMsg(msg, retData)
  22. return
  23. }
  24. userservices.ChangeSwitchStatus(this.getUserId(), req.SwitchInfo)
  25. this.WriteMsg(msg, "ok")
  26. }
  27. // 获取(个人)开关信息
  28. func (this *user) getSwitchInfo(msg, data string) {
  29. usr := userservices.GetUserInfo(this.getUserId())
  30. if usr == nil {
  31. log.Release("user.getSwitchInfo fail to query user info")
  32. this.WriteMsg(msg, "user not found")
  33. return
  34. }
  35. d, _ := json.Marshal(usr.Switches)
  36. this.WriteMsg(msg, string(d))
  37. }
  38. // 获取开关等级配置
  39. func (this *user) getSwitchLevelConf(msg, data string) {
  40. conf := userservices.GetSwitchLevelInfo()
  41. d, _ := json.Marshal(conf)
  42. this.WriteMsg(msg, string(d))
  43. }