- 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.
30 lines
746 B
Go
30 lines
746 B
Go
package domain
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
type ReportMetadataJSON struct {
|
|
BranchID *int64 `json:"branch_id,omitempty"`
|
|
Interval *string `json:"interval,omitempty"`
|
|
IntervalStart *string `json:"interval_start,omitempty"`
|
|
IntervalEnd *string `json:"interval_end,omitempty"`
|
|
}
|
|
|
|
func (r ReportMetadataJSON) ToPG() ([]byte, error) {
|
|
metadata, err := json.Marshal(r)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to marshal report request metadata: %w", err)
|
|
}
|
|
return metadata, nil
|
|
}
|
|
|
|
func ParseReportMetadataJSON(jsonData []byte) (ReportMetadataJSON, error) {
|
|
var metadata ReportMetadataJSON
|
|
if err := json.Unmarshal(jsonData, &metadata); err != nil {
|
|
return ReportMetadataJSON{}, err
|
|
}
|
|
return metadata, nil
|
|
}
|