2024-10-25 15:26:03 +00:00
|
|
|
package rpc_controllers
|
2024-04-03 15:32:05 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2025-02-24 17:06:12 +00:00
|
|
|
"gitea.pena/SQuiz/common/dal"
|
|
|
|
notifyer2 "gitea.pena/SQuiz/core/internal/proto/notifyer"
|
2024-04-03 15:32:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type MailNotify struct {
|
2024-10-25 15:26:03 +00:00
|
|
|
notifyer2.UnimplementedQuizServiceServer
|
2024-04-03 15:32:05 +00:00
|
|
|
dal *dal.DAL
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMailNotify(dal *dal.DAL) *MailNotify {
|
|
|
|
return &MailNotify{
|
|
|
|
dal: dal,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-25 15:26:03 +00:00
|
|
|
func (m *MailNotify) GetQuizzes(ctx context.Context, in *notifyer2.GetQuizzesRequest) (*notifyer2.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-10-25 15:26:03 +00:00
|
|
|
resp := ¬ifyer2.GetQuizzesResponse{
|
2024-04-03 16:46:10 +00:00
|
|
|
QuizIds: ids,
|
|
|
|
}
|
|
|
|
return resp, nil
|
2024-04-03 15:32:05 +00:00
|
|
|
}
|
|
|
|
|
2024-10-25 15:26:03 +00:00
|
|
|
func (m *MailNotify) GetStartedQuizzes(ctx context.Context, in *notifyer2.GetStartedQuizzesRequest) (*notifyer2.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
|
|
|
|
}
|
2024-10-25 15:26:03 +00:00
|
|
|
resp := ¬ifyer2.GetStartedQuizzesResponse{
|
2024-04-03 16:46:10 +00:00
|
|
|
QuizIds: ids,
|
|
|
|
}
|
|
|
|
return resp, nil
|
2024-04-03 15:32:05 +00:00
|
|
|
}
|