41 lines
929 B
Go
41 lines
929 B
Go
package rpc_controllers
|
|
|
|
import (
|
|
"context"
|
|
"gitea.pena/SQuiz/common/dal"
|
|
"gitea.pena/SQuiz/core/proto/notifyer"
|
|
)
|
|
|
|
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) {
|
|
ids, err := m.dal.QuizRepo.GetAllQuizzesID(ctx, in.AccountId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resp := ¬ifyer.GetQuizzesResponse{
|
|
QuizIds: ids,
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
func (m *MailNotify) GetStartedQuizzes(ctx context.Context, in *notifyer.GetStartedQuizzesRequest) (*notifyer.GetStartedQuizzesResponse, error) {
|
|
ids, err := m.dal.QuizRepo.GetStartedQuizzesID(ctx, in.AccountId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resp := ¬ifyer.GetStartedQuizzesResponse{
|
|
QuizIds: ids,
|
|
}
|
|
return resp, nil
|
|
}
|