33 lines
1.5 KiB
Go
33 lines
1.5 KiB
Go
package biz
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type ExportCondition struct{ From, Column, Operator string }
|
|
type ExportJoin struct{ Join, Table, On string }
|
|
type ExportTemplate struct {
|
|
ID uint
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DBName, Name, TableName, TemplateID, TemplateInfo, SQL, ImportSQL string
|
|
Limit *int
|
|
Order string
|
|
Conditions []ExportCondition
|
|
Joins []ExportJoin
|
|
}
|
|
type ExportRepo interface {
|
|
CreateExportTemplate(context.Context, *ExportTemplate) error
|
|
UpdateExportTemplate(context.Context, *ExportTemplate) error
|
|
DeleteExportTemplates(context.Context, []uint) error
|
|
FindExportTemplate(context.Context, uint, string) (*ExportTemplate, error)
|
|
ListExportTemplates(context.Context, int, int, *ExportTemplate) ([]*ExportTemplate, int64, error)
|
|
QueryExport(context.Context, *ExportTemplate, map[string]string) ([]map[string]any, string, error)
|
|
ImportExportRows(context.Context, *ExportTemplate, []map[string]any) error
|
|
}
|
|
type ExportUsecase struct{ repo ExportRepo }
|
|
|
|
func NewExportUsecase(repo ExportRepo) *ExportUsecase { return &ExportUsecase{repo: repo} }
|
|
func (uc *ExportUsecase) Repo() ExportRepo { return uc.repo }
|