package admin

import "server/dao"

type FileService struct{}

func (fs *FileService) QueryFileGenre() ([]dao.FileGenre, error) {
	genres, err := dao.QueryFileGenre()
	if err != nil {
		return nil, err
	}
	for i, genre := range genres {
		documents, err := dao.QueryNecessaryDocumentByGenreId(int(genre.ID))
		if err != nil {
			return nil, err
		}
		genres[i].NecessaryDocument = documents
	}
	return genres, err
}

func (fs *FileService) QueryFileGenreById(id int) (dao.FileGenre, error) {
	return dao.QueryFileGenreById(id)
}

func (fs *FileService) QueryNecessaryDocuments() ([]dao.NecessaryDocument, error) {
	return dao.QueryNecessaryDocuments()
}

func (fs *FileService) QueryNecessaryDocumentByGenreId(id int) ([]dao.NecessaryDocument, error) {
	return dao.QueryNecessaryDocumentByGenreId(id)
}

func (fs *FileService) CreateFileGenre(fileGenre dao.FileGenre) error {
	return fileGenre.CreateFileGenre()
}

func (fs *FileService) CreateNecessaryDocument(document dao.NecessaryDocument) error {
	return document.CreateNecessaryDocument()
}

func (fs *FileService) UpdateFileGenre(fileGenre dao.FileGenre) error {
	return fileGenre.UpdateFileGenre()
}

func (fs *FileService) UpdateNecessaryDocument(document dao.NecessaryDocument) error {
	return document.UpdateNecessaryDocument()
}

func (fs *FileService) DeleteFileGenre(fileGenre dao.FileGenre) error {

	return fileGenre.DeleteFileGenre()
}

func (fs *FileService) DeleteNecessaryDocument(document dao.NecessaryDocument) error {
	return document.DeleteNecessaryDocument()
}
