core/internal/controllers/rpc_controllers/mail_notify.go

41 lines
955 B
Go

package rpc_controllers
import (
"context"
"gitea.pena/SQuiz/common/dal"
notifyer2 "gitea.pena/SQuiz/core/internal/proto/notifyer"
)
type MailNotify struct {
notifyer2.UnimplementedQuizServiceServer
dal *dal.DAL
}
func NewMailNotify(dal *dal.DAL) *MailNotify {
return &MailNotify{
dal: dal,
}
}
func (m *MailNotify) GetQuizzes(ctx context.Context, in *notifyer2.GetQuizzesRequest) (*notifyer2.GetQuizzesResponse, error) {
ids, err := m.dal.QuizRepo.GetAllQuizzesID(ctx, in.AccountId)
if err != nil {
return nil, err
}
resp := &notifyer2.GetQuizzesResponse{
QuizIds: ids,
}
return resp, nil
}
func (m *MailNotify) GetStartedQuizzes(ctx context.Context, in *notifyer2.GetStartedQuizzesRequest) (*notifyer2.GetStartedQuizzesResponse, error) {
ids, err := m.dal.QuizRepo.GetStartedQuizzesID(ctx, in.AccountId)
if err != nil {
return nil, err
}
resp := &notifyer2.GetStartedQuizzesResponse{
QuizIds: ids,
}
return resp, nil
}