domain_service.go 4.4 KB
package domain

// FileTableService 文件表服务(导入模块)
type FileTableService interface {
	// Preview 预览(Excel文件)
	Preview(ctx *Context, fileId int, fields []*Field, where Where) (interface{}, error)
	// Edit 编辑表
	Edit()
	// Flush 保存编辑状态的表元数据
	Flush(ctx *Context, fileId int, table *Table) (interface{}, error)
	// DeleteFiles 批量删除文件
	DeleteFiles(ctx *Context, files ...*File) error
	// GenerateTable 生成主表
	GenerateTable(ctx *Context, fileId int, tableName string) (interface{}, error)
}

// TableService 表服务
type TableService interface {
	// Preview 预览
	Preview(ctx *Context, tableId int, where Where) (interface{}, error)
	// CopyTable 拷贝表
	CopyTable(ctx *Context, tableId int, tableName string) (interface{}, error)
	// DeleteTables 删除表
	DeleteTables(ctx *Context, tables ...*Table) error
	// AppendData 追加表数据
	AppendData(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error)
	// UpdateTableStruct 更新表结构(分表)
	UpdateTableStruct(ctx *Context, tableId int, fields []*Field, name string) (interface{}, error)
	// AddTableStruct 添加表结构(分表)
	AddTableStruct(ctx *Context, parentTableId int, fields []*Field, name string) (interface{}, error)
}

// PreviewDataTableService 具体的表预览服务
type PreviewDataTableService interface {
	// Preview 预览
	Preview(ctx *Context, fileId int, fields []*Field, where Where) (interface{}, error)
	// RePreview 重新预览
	RePreview(ctx *Context, fileId int, fields []*Field, where Where) (interface{}, error)
	// CreateTemporaryFile 创建临时文件(计算集修改的时候,先创建临时文件,保存成功后覆盖原文件)
	CreateTemporaryFile(ctx *Context, fileId int) (*File, error)
	GetFileId() int
}

// EditDataTableService 编辑表数据(副表)
type EditDataTableService interface {
	Edit(ctx *Context, param EditTableRequest) (*DataEditDataTable, error)
}

// FlushDataTableService 保存编辑状态的表
type FlushDataTableService interface {
	Flush(ctx *Context, fileId int, table *Table) (interface{}, error)
}

// DeleteFileService 删除文件服务
type DeleteFileService interface {
	DeleteFiles(ctx *Context, files ...*File) error
}

// GenerateMainTableService 生成主表服务
type GenerateMainTableService interface {
	GenerateTable(ctx *Context, fileId int, tableName string) (interface{}, error)
}

// CopyDataTableService 拷贝表服务
type CopyDataTableService interface {
	CopyTable(ctx *Context, tableId int, tableName string) (interface{}, error)
}

// DeleteDataTableService 删除表服务
type DeleteDataTableService interface {
	DeleteTable(ctx *Context, tableId int) (interface{}, error)
	DeleteTables(ctx *Context, tables ...*Table) error
}

// AppendDataToTableService 追加数据服务
type AppendDataToTableService interface {
	AppendData(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error)
	PreflightCheck(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error)
}

/************************************/

// UpdateTableStructService 更新表结构服务(分表)
type UpdateTableStructService interface {
	UpdateTableStruct(ctx *Context, tableId int, fields []*Field, name string) (interface{}, error)
}

// AddTableStructService 添加表结构服务(分表)
type AddTableStructService interface {
	AddTableStruct(ctx *Context, parentTableId int, fields []*Field, name string) (*Table, error)
}

type EditTableRequest struct {
	FileId            int                    `json:"objectId"`
	Fields            []*Field               `json:"fields"`
	ProcessFieldNames []string               `json:"processFields"`
	ProcessFields     []*Field               `json:"-" `
	Where             Where                  `json:"where"`
	Action            string                 `json:"action"`
	Params            map[string]interface{} `json:"params"`
}

type TableEditDataService interface {
	RowEdit(ctx *Context, request EditDataRequest) (interface{}, error)
	BatchAdd(ctx *Context, request EditDataRequest) (interface{}, error)
}
type EditDataRequest struct {
	TableId         int `json:"tableId"`
	Table           *Table
	UpdateList      []*FieldValues `json:"updateList"`
	RemoveList      []*FieldValues `json:"removeList"`
	AddList         []*FieldValues `json:"addList"`
	Where           Where          `json:"where"`
	IgnoreTableType bool
}