package service

import (
	"bpmsapi/dto"
	"bpmsapi/entity"
	"bpmsapi/repository"
)

type Reportusecase interface {
	GetOrderSummary(input entity.OrderSummaryInput) entity.CustomResponse
	GetTechOrderSummary(input entity.TechOrderSummaryInput) entity.CustomResponse
}

type ReportService struct {
	reportRepository *repository.ReportRepository
}

func ReportServiceInit(reportRepository *repository.ReportRepository) *ReportService {
	return &ReportService{
		reportRepository: reportRepository,
	}
}

func (reportServ *ReportService) GetOrderSummary(input entity.OrderSummaryInput) (response entity.CustomResponse) {
	resp, err := reportServ.reportRepository.FetchOrderSummary(input)
	if err != nil {
		response.Resultcode = 1
		response.Message = dto.ErrorOrderSummary + err.Error()
	} else {

		response.Resultcode = 0
		response.Message = dto.SuccessOrderSummary
		response.Payload = resp

	}

	return response
}

func (reportServ *ReportService) GetTechOrderSummary(input entity.TechOrderSummaryInput) (response entity.CustomResponse) {
	resp, err := reportServ.reportRepository.TechOrderSummary(input)
	if err != nil {
		response.Resultcode = 1
		response.Message = dto.ErrorTechOrderSummary + err.Error()
	} else {

		response.Resultcode = 0
		response.Message = dto.SuccessTechOrderSummary
		response.Payload = resp

	}

	return response
}
