mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +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"
|
||||
)
|
||||
|
||||
type Client interface {
|
||||
Create(calendarId, name, description string, from, to time.Time) error
|
||||
}
|
||||
|
||||
type GoogleClient struct {
|
||||
calIds map[string]struct{}
|
||||
*calendar.Service
|
||||
|
|
|
|||
|
|
@ -11,11 +11,6 @@ import (
|
|||
"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 {
|
||||
path string
|
||||
invoiceId string
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/rjNemo/rentease/internal/config"
|
||||
"github.com/rjNemo/rentease/internal/driver/calendar"
|
||||
"github.com/rjNemo/rentease/internal/driver/pdf"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
Parse(rawContent string) (*Booking, error)
|
||||
}
|
||||
|
|
@ -33,11 +40,11 @@ type parserClient interface {
|
|||
type Service struct {
|
||||
store Store
|
||||
parser parserClient
|
||||
calendar calendar.Client
|
||||
pdf pdf.Client
|
||||
calendar CalendarClient
|
||||
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{
|
||||
store: store,
|
||||
parser: parser,
|
||||
|
|
|
|||
Loading…
Reference in a new issue