57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package services
|
|
|
|
import (
|
|
"learnsteam/cslms-api/internal/models"
|
|
"learnsteam/cslms-api/internal/repositories"
|
|
)
|
|
|
|
type quizPaperService struct {
|
|
repository repositories.QuizPaperRepository
|
|
}
|
|
|
|
type QuizPaperService interface {
|
|
List(string, string, int, int) (*[]models.QuizPaper, error)
|
|
Total(string, string) (int64, error)
|
|
|
|
Find(int64) (*models.QuizPaper, error)
|
|
Create(*models.QuizPaper) (*models.QuizPaper, error)
|
|
Update(*models.QuizPaper) (*models.QuizPaper, error)
|
|
Delete(string) error
|
|
}
|
|
|
|
func NewQuizPaperService(repository repositories.QuizPaperRepository) QuizPaperService {
|
|
return &quizPaperService{
|
|
repository: repository,
|
|
}
|
|
}
|
|
|
|
func (s *quizPaperService) List(q string, tag string, page int, limit int) (*[]models.QuizPaper, error) {
|
|
return s.repository.List(q, tag, page, limit)
|
|
}
|
|
|
|
func (s *quizPaperService) Total(q string, tag string) (int64, error) {
|
|
return s.repository.Total(q, tag)
|
|
}
|
|
|
|
func (s *quizPaperService) Find(id int64) (*models.QuizPaper, error) {
|
|
return s.repository.Find(id)
|
|
}
|
|
|
|
func (s *quizPaperService) Create(quizPaper *models.QuizPaper) (*models.QuizPaper, error) {
|
|
result, err := s.repository.Create(quizPaper)
|
|
|
|
return result, err
|
|
}
|
|
|
|
func (s *quizPaperService) Update(quizPaper *models.QuizPaper) (*models.QuizPaper, error) {
|
|
result, err := s.repository.Update(quizPaper)
|
|
|
|
return result, err
|
|
}
|
|
|
|
func (s *quizPaperService) Delete(id string) error {
|
|
err := s.repository.Delete(id)
|
|
|
|
return err
|
|
}
|