core/rpc_service/mail_notify.go

41 lines
983 B
Go
Raw Normal View History

2024-04-03 15:32:05 +00:00
package rpc_service
import (
"context"
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal"
2024-06-12 13:27:42 +00:00
"penahub.gitlab.yandexcloud.net/backend/quiz/core/proto/notifyer"
2024-04-03 15:32:05 +00:00
)
type MailNotify struct {
notifyer.UnimplementedQuizServiceServer
dal *dal.DAL
}
func NewMailNotify(dal *dal.DAL) *MailNotify {
return &MailNotify{
dal: dal,
}
}
func (m *MailNotify) GetQuizzes(ctx context.Context, in *notifyer.GetQuizzesRequest) (*notifyer.GetQuizzesResponse, error) {
2024-04-03 16:18:40 +00:00
ids, err := m.dal.QuizRepo.GetAllQuizzesID(ctx, in.AccountId)
if err != nil {
return nil, err
}
2024-04-03 16:46:10 +00:00
resp := &notifyer.GetQuizzesResponse{
QuizIds: ids,
}
return resp, nil
2024-04-03 15:32:05 +00:00
}
func (m *MailNotify) GetStartedQuizzes(ctx context.Context, in *notifyer.GetStartedQuizzesRequest) (*notifyer.GetStartedQuizzesResponse, error) {
2024-04-03 16:46:10 +00:00
ids, err := m.dal.QuizRepo.GetStartedQuizzesID(ctx, in.AccountId)
if err != nil {
return nil, err
}
resp := &notifyer.GetStartedQuizzesResponse{
QuizIds: ids,
}
return resp, nil
2024-04-03 15:32:05 +00:00
}