report

package
v1.11.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

*

  • Copyright 2013 @ 56x.net.
  • name :
  • author : jarryliu
  • date : 2013-02-04 20:13
  • description :
  • history :

*

  • Copyright 2013 @ 56x.net.
  • name :
  • author : jarryliu
  • date : 2013-02-04 20:13
  • description :
  • history :

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckInject added in v1.8.10

func CheckInject(s string) bool

判断是否存在危险的注入操作

func SqlFormat

func SqlFormat(sql string, ht map[string]interface{}) (formatted string)

格式化sql语句

Types

type ColumnMapping

type ColumnMapping struct {
	//列的字段
	Field string
	//列的名称
	Name string
}

列映射

type CsvProvider

type CsvProvider struct {
	// contains filtered or unexported fields
}

func (*CsvProvider) Export

func (c *CsvProvider) Export(rows []map[string]interface{},
	fields []string, names []string, formatter []IExportFormatter) (binary []byte)

type ExcelProvider

type ExcelProvider struct {
	// contains filtered or unexported fields
}

func (*ExcelProvider) Export

func (e *ExcelProvider) Export(rows []map[string]interface{},
	fields []string, names []string, formatter []IExportFormatter) (binary []byte)

type ExportItem

type ExportItem struct {
	PortalKey string
	// contains filtered or unexported fields
}

ExportItem 导出项目

func (*ExportItem) Export

func (e *ExportItem) Export(parameters *ExportParams,
	provider IExportProvider, formatter IExportFormatter) []byte

Export 导出数据

func (*ExportItem) GetColumnMapping

func (e *ExportItem) GetColumnMapping() []ColumnMapping

GetColumnMapping 导出的列名(比如:数据表是因为列,这里我需要列出中文列)

func (*ExportItem) GetExportColumnNames

func (e *ExportItem) GetExportColumnNames(
	exportColumns []string) (names []string)

func (*ExportItem) GetJsonData

func (e *ExportItem) GetJsonData(ht map[string]string) string

GetJsonData 获取要导出的数据Json格式

func (*ExportItem) GetSchemaAndData

func (e *ExportItem) GetSchemaAndData(p Params) ([]map[string]interface{}, int, error)

func (*ExportItem) GetSchemaData added in v1.11.8

func (e *ExportItem) GetSchemaData(p Params) ([]map[string]interface{}, error)

func (*ExportItem) GetTotalCount added in v1.11.8

func (e *ExportItem) GetTotalCount(p Params) (int, error)

func (*ExportItem) GetTotalView

func (e *ExportItem) GetTotalView(ht map[string]string) (row map[string]interface{})

GetTotalView 获取统计数据

type ExportParams

type ExportParams struct {
	//参数
	Params Params
	//要到导出的列的名称集合
	ExportFields []string
}

导出参数

type IDataExportPortal

type IDataExportPortal interface {
	//导出的列名(比如:数据表是因为列,这里我需要列出中文列)
	GetColumnMapping() []ColumnMapping
	// GetTotalCount 查询总条数
	GetTotalCount(p Params) (int, error)
	// GetSchemaData 查询数据
	GetSchemaData(p Params) ([]map[string]interface{}, error)
	// GetSchemaAndData 获取要导出的数据及表结构,仅在第一页时查询分页数据
	GetSchemaAndData(p Params) (rows []map[string]interface{},
		total int, err error)
	//获取要导出的数据Json格式
	GetJsonData(ht map[string]string) string
	//获取统计数据
	GetTotalView(ht map[string]string) (row map[string]interface{})
	//根据导出的列名获取列的索引及对应键
	GetExportColumnNames(exportColumnNames []string) (fields []string)
	//导出数据
	Export(ep *ExportParams, p IExportProvider, f IExportFormatter) []byte
}

数据导出入口

type IDbProvider

type IDbProvider interface {
	//获取数据库连接
	GetDB() *sql.DB
}

数据库提供者

type IExportFormatter

type IExportFormatter interface {
	// 格式化字段
	Format(field, name string, rowNum int, data interface{}) interface{}
}

数据格式化器

type IExportProvider

type IExportProvider interface {
	//导出
	Export(rows []map[string]interface{}, fields []string, names []string,
		formatter []IExportFormatter) (binary []byte)
}

导出

func NewCsvProvider

func NewCsvProvider() IExportProvider

func NewExcelProvider

func NewExcelProvider() IExportProvider

func NewTextProvider

func NewTextProvider() IExportProvider

type ItemConfig

type ItemConfig struct {
	ColumnMapping string
	Query         string
	Total         string
	Import        string
}

导入导出项目配置

type ItemManager

type ItemManager struct {
	// contains filtered or unexported fields
}

ItemManager 导出项工厂

func NewItemManager

func NewItemManager(db IDbProvider, rootPath string, cacheFiles bool) *ItemManager

NewItemManager 新建导出项目管理器

func (*ItemManager) GetExportData

func (f *ItemManager) GetExportData(portal string, p Params, page int,
	rows int) (data []map[string]interface{}, total int, err error)

GetExportData 获取导出数据

func (*ItemManager) GetItem

func (f *ItemManager) GetItem(portalKey string) IDataExportPortal

GetItem 获取导出项

func (*ItemManager) GetWebExportCheckOptions

func (f *ItemManager) GetWebExportCheckOptions(portal string, token string) (string, error)

GetWebExportCheckOptions 获取导出列勾选项

type Params

type Params map[string]interface{}

参数

func ParseParams

func ParseParams(paramMappings string) Params

转换参数

func (Params) Contains added in v1.8.10

func (p Params) Contains(k string) bool

func (Params) Copy

func (p Params) Copy(form map[string]string)

Copy 从Map中拷贝数据

func (Params) CopyForm

func (p Params) CopyForm(form url.Values)

CopyForm 从表单参数中导入数据

func (Params) IsFirstIndex added in v1.11.8

func (p Params) IsFirstIndex() bool

type TextProvider

type TextProvider struct {
	// contains filtered or unexported fields
}

func (*TextProvider) Export

func (t *TextProvider) Export(rows []map[string]interface{},
	fields []string, names []string, formatter []IExportFormatter) (binary []byte)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL