- Removed detailed event routes from the API. - Added new report request routes for creating and fetching report requests. - Introduced new domain models for report requests, including metadata and status handling. - Implemented report request processing logic, including CSV generation for event interval reports. - Enhanced company statistics handling with new domain models and service methods. - Updated repository interfaces and implementations to support new report functionalities. - Added error handling and logging for report file operations and notifications.
45 lines
862 B
Go
45 lines
862 B
Go
package domain
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
|
|
type ReportRequestStatus string
|
|
|
|
var (
|
|
PendingReportRequest ReportRequestStatus = "pending"
|
|
SuccessReportRequest ReportRequestStatus = "success"
|
|
RejectReportRequest ReportRequestStatus = "reject"
|
|
)
|
|
|
|
func (r ReportRequestStatus) IsValid() bool {
|
|
switch r {
|
|
case PendingReportRequest, SuccessReportRequest, RejectReportRequest:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func ParseReportRequestStatus(val string) (ReportRequestStatus, error) {
|
|
r := ReportRequestStatus(val)
|
|
if !r.IsValid() {
|
|
return "", fmt.Errorf("invalid ReportRequestStatus: %q", val)
|
|
}
|
|
return r, nil
|
|
}
|
|
|
|
type ValidReportRequestStatus struct {
|
|
Value ReportRequestStatus
|
|
Valid bool
|
|
}
|
|
|
|
func (v ValidReportRequestStatus) ToPG() pgtype.Text {
|
|
return pgtype.Text{
|
|
String: string(v.Value),
|
|
Valid: v.Valid,
|
|
}
|
|
} |