mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
refactor: move the driver interfaces to the service layer
This commit is contained in:
parent
49c49f4098
commit
cb6677ca60
3 changed files with 12 additions and 14 deletions
|
|
@ -16,10 +16,6 @@ import (
|
||||||
"google.golang.org/api/option"
|
"google.golang.org/api/option"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client interface {
|
|
||||||
Create(calendarId, name, description string, from, to time.Time) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type GoogleClient struct {
|
type GoogleClient struct {
|
||||||
calIds map[string]struct{}
|
calIds map[string]struct{}
|
||||||
*calendar.Service
|
*calendar.Service
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,6 @@ import (
|
||||||
"github.com/labstack/gommon/log"
|
"github.com/labstack/gommon/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client interface {
|
|
||||||
BuildInvoice(context map[string]any) error
|
|
||||||
BuildReport(context map[string]any, period string, month, year int) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type PdfClient struct {
|
type PdfClient struct {
|
||||||
path string
|
path string
|
||||||
invoiceId string
|
invoiceId string
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rjNemo/rentease/internal/config"
|
"github.com/rjNemo/rentease/internal/config"
|
||||||
"github.com/rjNemo/rentease/internal/driver/calendar"
|
|
||||||
"github.com/rjNemo/rentease/internal/driver/pdf"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Store interface {
|
type Store interface {
|
||||||
|
|
@ -26,6 +24,15 @@ type Store interface {
|
||||||
UpdateItem(id int, item string, paymentMethod string, paymentStatus string, qty int, price float64) (*Item, error)
|
UpdateItem(id int, item string, paymentMethod string, paymentStatus string, qty int, price float64) (*Item, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PdfClient interface {
|
||||||
|
BuildInvoice(context map[string]any) error
|
||||||
|
BuildReport(context map[string]any, period string, month, year int) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type CalendarClient interface {
|
||||||
|
Create(calendarId, name, description string, from, to time.Time) error
|
||||||
|
}
|
||||||
|
|
||||||
type parserClient interface {
|
type parserClient interface {
|
||||||
Parse(rawContent string) (*Booking, error)
|
Parse(rawContent string) (*Booking, error)
|
||||||
}
|
}
|
||||||
|
|
@ -33,11 +40,11 @@ type parserClient interface {
|
||||||
type Service struct {
|
type Service struct {
|
||||||
store Store
|
store Store
|
||||||
parser parserClient
|
parser parserClient
|
||||||
calendar calendar.Client
|
calendar CalendarClient
|
||||||
pdf pdf.Client
|
pdf PdfClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewService(store Store, parser parserClient, calendar calendar.Client, pdf pdf.Client) (*Service, error) {
|
func NewService(store Store, parser parserClient, calendar CalendarClient, pdf PdfClient) (*Service, error) {
|
||||||
return &Service{
|
return &Service{
|
||||||
store: store,
|
store: store,
|
||||||
parser: parser,
|
parser: parser,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue