44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
|
package services
|
||
|
|
||
|
import (
|
||
|
"learnsteam/cslms-api/internal/models"
|
||
|
"learnsteam/cslms-api/internal/repositories"
|
||
|
)
|
||
|
|
||
|
type paperQuizService struct {
|
||
|
repository repositories.PaperQuizRepository
|
||
|
quizRepository repositories.QuizRepository
|
||
|
}
|
||
|
|
||
|
type PaperQuizService interface {
|
||
|
List(int64, int, int) (*[]models.PaperQuiz, error)
|
||
|
Total(int64) (int64, error)
|
||
|
|
||
|
Find(int64) (*models.PaperQuiz, error)
|
||
|
Update(*models.PaperQuiz) (*models.PaperQuiz, error)
|
||
|
}
|
||
|
|
||
|
func NewPaperQuizService(repository repositories.PaperQuizRepository) PaperQuizService {
|
||
|
return &paperQuizService{
|
||
|
repository: repository,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (s *paperQuizService) List(user_quiz_paper_id int64, page int, limit int) (*[]models.PaperQuiz, error) {
|
||
|
return s.repository.List(user_quiz_paper_id, page, limit)
|
||
|
}
|
||
|
|
||
|
func (s *paperQuizService) Total(user_quiz_paper_id int64) (int64, error) {
|
||
|
return s.repository.Total(user_quiz_paper_id)
|
||
|
}
|
||
|
|
||
|
func (s *paperQuizService) Find(id int64) (*models.PaperQuiz, error) {
|
||
|
return s.repository.Find(id)
|
||
|
}
|
||
|
|
||
|
func (s *paperQuizService) Update(quiz *models.PaperQuiz) (*models.PaperQuiz, error) {
|
||
|
result, err := s.repository.Update(quiz)
|
||
|
|
||
|
return result, err
|
||
|
}
|