rpc.go 842 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package weeklyhonor
  2. import (
  3. "context"
  4. up "go-common/app/service/main/up/api/v1"
  5. "go-common/library/log"
  6. )
  7. const fromWeeklyHonor = 1
  8. // ChangeUpSwitch change up switch on/off
  9. func (d *Dao) ChangeUpSwitch(c context.Context, mid int64, state uint8) (err error) {
  10. req := up.UpSwitchReq{
  11. Mid: mid,
  12. From: fromWeeklyHonor,
  13. State: state,
  14. }
  15. if _, err = d.upClient.SetUpSwitch(c, &req); err != nil {
  16. log.Error("d.upClient.SetUpSwitch req(%+v),err(%v)", req, err)
  17. }
  18. return
  19. }
  20. // GetUpSwitch get up switch state
  21. func (d *Dao) GetUpSwitch(c context.Context, mid int64) (state uint8, err error) {
  22. req := up.UpSwitchReq{
  23. Mid: mid,
  24. From: fromWeeklyHonor,
  25. }
  26. reply, err := d.upClient.UpSwitch(c, &req)
  27. if err != nil {
  28. log.Error("d.upClient.UpSwitch req(%+v),err(%v)", req, err)
  29. return
  30. }
  31. state = reply.GetState()
  32. return
  33. }