setting.go 770 B

12345678910111213141516171819202122232425262728
  1. package service
  2. import (
  3. "context"
  4. pb "go-common/app/service/main/push/api/grpc/v1"
  5. "go-common/library/log"
  6. )
  7. // Setting gets user notify setting.
  8. func (s *Service) Setting(ctx context.Context, mid int64) (st map[int32]int32, err error) {
  9. arg := &pb.SettingRequest{Mid: mid}
  10. reply, err := s.pushRPC.Setting(ctx, arg)
  11. if err != nil {
  12. log.Error("s.pushRPC.Setting(%+v) error(%v)", arg, err)
  13. return
  14. }
  15. return reply.Settings, nil
  16. }
  17. // SetSetting saves setting.
  18. func (s *Service) SetSetting(ctx context.Context, mid int64, typ, val int) (err error) {
  19. arg := &pb.SetSettingRequest{Mid: mid, Type: int32(typ), Value: int32(val)}
  20. if _, err = s.pushRPC.SetSetting(ctx, arg); err != nil {
  21. log.Error("s.pushRPC.SetSetting(%+v) error(%v)", arg, err)
  22. }
  23. return
  24. }