package service import ( "time" "github.com/rovina/zsp-backend/internal/model" "github.com/rovina/zsp-backend/internal/repository" ) type ContractBatchService interface { List(folderID *uint) ([]model.ContractBatch, error) GetByID(id uint) (*model.ContractBatch, error) Create(folderID uint, batchName, remark string, files []model.ContractBatchFile) (*model.ContractBatch, error) Delete(id uint) error } type contractBatchService struct { repo repository.ContractBatchRepository } func NewContractBatchService(repo repository.ContractBatchRepository) ContractBatchService { return &contractBatchService{repo: repo} } func (s *contractBatchService) List(folderID *uint) ([]model.ContractBatch, error) { return s.repo.List(folderID) } func (s *contractBatchService) GetByID(id uint) (*model.ContractBatch, error) { return s.repo.GetByID(id) } func (s *contractBatchService) Create(folderID uint, batchName, remark string, files []model.ContractBatchFile) (*model.ContractBatch, error) { b := &model.ContractBatch{ FolderID: folderID, BatchName: batchName, Remark: remark, CreateTime: time.Now(), UpdateTime: time.Now(), } if err := s.repo.Create(b, files); err != nil { return nil, err } return s.repo.GetByID(b.ID) } func (s *contractBatchService) Delete(id uint) error { return s.repo.Delete(id) }