collect

package
v0.0.0-...-035e5cb Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "service"

Variables

This section is empty.

Functions

func CallPluginFunc

func CallPluginFunc(pluginLoader interface{}, plugin Plugin, t *Template, args ...interface{}) *common.Result

func CastTemplate

func CastTemplate(fileData string) (*text_template.Template, error)

func GetServiceName

func GetServiceName(params map[string]interface{}) string

* 获取服务名称

func LoadTemplatePlugins

func LoadTemplatePlugins(pluginLoader interface{}, plugins []Plugin, t *Template, routerAll *RouterAll)

* 加载模板级别的插件

func NewTemplateService

func NewTemplateService(params map[string]interface{}) *common.Result

* * 根据参数转模板服务

func SetLocalRouter

func SetLocalRouter(routerAll RouterAll)

func ToTpl

func ToTpl(tplContent string, toField string, target interface{}) error

Types

type BasicAuth

type BasicAuth struct {
	Username    string
	Password    string
	UsernameTpl *text_template.Template
	PasswordTpl *text_template.Template
}

type DataJsonConfig

type DataJsonConfig struct {
	Connect  map[string]interface{}
	Finish   HandlerParam   //结束
	Services []HandlerParam // 服务
}

type ExcelConfig

type ExcelConfig struct {
	Name   string   // 名称
	Sheets []Sheets // sheet 页
}

type HandlerParam

type HandlerParam struct {
	Key                 string                  // 服务
	Enable              string                  // 是否启用
	EnableTpl           *text_template.Template // 是否启用模板
	Name                string                  //名称
	Field               string                  // 字段
	LeftField           string                  `yaml:"left_field"json:"left_field"`               // 字段
	RightField          string                  `yaml:"right_field"json:"right_field"`             // 字段
	LeftValueField      string                  `yaml:"left_value_field"json:"left_value_field"`   // 字段
	RightValueField     string                  `yaml:"right_value_field"json:"right_value_field"` // 字段
	AppendParam         bool                    `yaml:"append_param"json:"append_param"`           // 是否添加参数
	NoneFillRight       bool                    `yaml:"none_fill_right"json:"none_fill_right"`     // 是否添加右边参数
	AppendItemParam     bool                    `yaml:"append_item_param"json:"append_item_param"` // 是否添加参数
	SaveOriginal        bool                    `yaml:"save_original"json:"save_original"`         // 是否添加参数
	Foreach             string                  //循环数组
	Item                string                  // for 循环里面的item
	Fields              []SubField              // 子字段
	Service             map[string]interface{}  // 服务
	Template            string                  // 检查模板
	TemplateTpl         *text_template.Template //
	ErrMsg              string                  `yaml:"err_msg"json:"err_msg"` /// 错误校验
	ErrMsgTpl           *text_template.Template //
	FromList            string                  `yaml:"from_list"json:"from_list"`     // 来源数组
	FromItem            string                  `yaml:"from_item"json:"from_item"`     // 来源数组子项
	IfTemplate          string                  `yaml:"if_template"json:"if_template"` // 判断2个数组是否相等
	IfTemplateTpl       *text_template.Template //
	Value               string                  // 取值
	ValueTpl            *text_template.Template //
	File                string                  // 文件取值字段
	DataJson            string                  `yaml:"data_json"json:"data_json"`     // 来源json 数据地址
	ResultName          string                  `yaml:"result_name"json:"result_name"` // 结果参数
	SaveField           string                  `yaml:"save_field"json:"save_field"`   // 保存字段
	Path                string                  // 保存路径
	Params              string
	NodeNext            string                  `yaml:"node_next"json:"node_next"` // 流程流转用户
	NodeNextTpl         *text_template.Template //
	NodeKey             string                  `yaml:"node_key"json:"node_key"` // 保存字段
	IgnoreError         bool                    `yaml:"ignore_error"json:"ignore_error"`
	NodeType            string                  `yaml:"node_type"json:"node_type"` // 保存字段
	NodeFail            string                  `yaml:"node_fail"json:"node_fail"` // 失败流转
	NodeFailTpl         *text_template.Template //
	Rule                string
	Right               string
	Left                string
	Operation           string
	TargetTransferKey   string   `yaml:"target_transfer_key"json:"target_transfer_key"`     // 失败流转
	TargetTransferValue string   `yaml:"target_transfer_value"json:"target_transfer_value"` // 失败流转
	ValueListField      string   `yaml:"value_list_field"json:"value_list_field"`           // 失败流转
	AppendRightFields   []string `yaml:"append_right_fields"json:"append_right_fields"`     // 失败流转
	AppendLeftFields    []string `yaml:"append_left_fields"json:"append_left_fields"`       // 失败流转
	WithAddRemove       bool     `yaml:"with_add_remove"json:"with_add_remove"`             // 比较修改记录的
	Method              string
	Room                string
	Second              int64
	Children            string //children
	Pid                 string //parent_id
	Id                  string //id
}

type HttpConfig

type HttpConfig struct {
	Url         string // 名称
	UrlTpl      *text_template.Template
	Method      string
	AppendParam bool  `json:"append_param"`
	ResultJson  *bool `json:"result_json"`
	Header      map[string]string
	HeaderTpl   map[string]*text_template.Template
	BasicAuth   BasicAuth `json:"basic_auth"`
	Data        interface{}
	DataTpl     *text_template.Template
}

type ModifyConfig

type ModifyConfig struct {
	Desc            string            // 备注
	OpFieldTransfer map[string]string `yaml:"op_field_transfer"json:"op_field_transfer"` // 字段冲突转换一下
	Fields          []HandlerParam
}

type ParamConfig

type ParamConfig struct {
	Name        string                  // 名称
	Template    string                  // 渲染模板
	Exec        bool                    //是否执行
	TemplateTpl *text_template.Template // 模板内容
	Type        string                  // 转换类型
	Check       SubField                //检查
	Default     interface{}             //默认值
}

type Plugin

type Plugin struct {
	Key       string                  // 关键字
	Type      string                  // 类型
	Name      string                  // 名称
	Path      string                  // 路径
	Method    string                  // 方法
	Reg       string                  // 正则表达式
	Fields    []SubField              // 字段信息
	Enable    string                  // 是否启用
	EnableTpl *text_template.Template //启用模板
}

* 插件

type PluginLoader

type PluginLoader struct {
}

* * 定义一个空结构体,所有插件的方法,基于Plugin 进行添加 *

func (*PluginLoader) LoadCacheConfig

func (t *PluginLoader) LoadCacheConfig(config Plugin, template *Template, routerAll *RouterAll)

* 加载data_file 文件内容,处理require 文件的引用 * 将服务的文件路径转换成文件内容

func (*PluginLoader) LoadDataFile

func (t *PluginLoader) LoadDataFile(config Plugin, template *Template, routerAll *RouterAll)

* 加载data_file 文件内容,处理require 文件的引用 * 将服务的文件路径转换成文件内容

func (*PluginLoader) LoadDataFileTpl

func (t *PluginLoader) LoadDataFileTpl(config Plugin, template *Template, routerAll *RouterAll)

* 加载data_file 文件内容, * 在启动的时候,就转换好模板,避免在运行的时候,转换模板,减少cpu 使用

func (*PluginLoader) LoadDataJson

func (t *PluginLoader) LoadDataJson(config Plugin, template *Template, routerAll *RouterAll)

* 加载data_json 文件内容,

func (*PluginLoader) LoadExcelConfig

func (t *PluginLoader) LoadExcelConfig(config Plugin, template *Template, routerAll *RouterAll)

* 加载data_file 文件内容,处理require 文件的引用 * 将服务的文件路径转换成文件内容

func (*PluginLoader) LoadHttpJson

func (t *PluginLoader) LoadHttpJson(config Plugin, template *Template, routerAll *RouterAll)

* 加载http_json 文件内容,处理require 文件的引用 * 将服务的文件路径转换成文件内容

func (*PluginLoader) LoadModifyConfig

func (t *PluginLoader) LoadModifyConfig(config Plugin, template *Template, routerAll *RouterAll)

* 加载data_file 文件内容,处理require 文件的引用 * 将服务的文件路径转换成文件内容

func (*PluginLoader) LoadPreventDuplicationConfig

func (t *PluginLoader) LoadPreventDuplicationConfig(config Plugin, template *Template, routerAll *RouterAll)

* 加载data_file 文件内容,处理require 文件的引用 * 将服务的文件路径转换成文件内容

func (*PluginLoader) LoadRouterAllEnable

func (t *PluginLoader) LoadRouterAllEnable(config Plugin, template *Template, routerAll *RouterAll)

func (*PluginLoader) LoadSchedule

func (t *PluginLoader) LoadSchedule(config Plugin, template *Template, routerAll *RouterAll)

* 加载定时任务是否启动

type ProjectLink struct {
	Service    []ProjectLinkInfo // 项目路由
	CurrentDir string            // 当前路径目录
	Path       string            // 当前路径
}

* 项目关联服务

type ProjectLinkInfo

type ProjectLinkInfo struct {
	CurrentDir string // 当前路径目录
	Path       string // 当前路径
}

** 文件目录

type RouterAll

type RouterAll struct {
	Services   []RouterProject // 项目路由
	CurrentDir string          // 当前路径目录
	Path       string          // 当前路径

	//moduleRegisterDict map[string]module_result.ModuleResult //服务注册对象
	//registerList       []module_result.ModuleResult          // 设置注册列表
	LoadStartupPlugin []Plugin `yaml:"load_startup_plugin"` // 加载启动插件
	FileContentPlugin []Plugin `yaml:"file_content_plugin"` // 文件内容处理插件
	ModuleHandler     []Plugin `yaml:"module_handler"`      // 文件内容处理插件
	DataHandler       []Plugin `yaml:"data_handler"`        // 文件内容处理插件
	BeforePlugin      []Plugin `yaml:"before_plugin"`       // 文件内容处理插件
	AfterPlugin       []Plugin `yaml:"after_plugin"`        // 文件内容处理插件
	// contains filtered or unexported fields
}
type ModuleResult interface {
	Result(template *template.Template) (*common.Result, error)
}

* * 项目总路由

func GetLocalRouter

func GetLocalRouter() *RouterAll

func (*RouterAll) AddProject

func (t *RouterAll) AddProject(project string)

* * 添加项目

func (*RouterAll) AddProjectService

func (t *RouterAll) AddProjectService(project string, service *ServiceConfig)

* 添加项目服务

func (*RouterAll) GetProjectService

func (t *RouterAll) GetProjectService(service string) (ServiceConfig, bool, string)

func (*RouterAll) GetRegisterServices

func (t *RouterAll) GetRegisterServices() []*ServiceConfig

* * 获取已经注册的服务

type RouterProject

type RouterProject struct {
	Key        string // 路由前缀
	CurrentDir string // 当前路径目录
	Path       string // 当前路径

}

* * 具体项目

type Schedule

type Schedule struct {
	Enable       string                  // 是否启用
	EnableTpl    *text_template.Template // 是否启用模板
	ScheduleSpec string                  `yaml:"schedule_spec"json:"schedule_spec"`
}

type ServiceConfig

type ServiceConfig struct {
	Project             string // 项目
	Name                string
	Key                 string                  // 服务
	Service             string                  // 服务全称
	Params              map[string]ParamConfig  // 参数配置定义
	Schedule            Schedule                // 定时任务
	Cache               HandlerParam            // 缓存设置
	PreventDuplication  HandlerParam            `yaml:"prevent_duplication"` // 重复请求处理
	Module              string                  // 模块
	Table               string                  // 表名
	Http                bool                    //  是否支持http 访问
	Options             string                  // 可以选择字段
	MustLogin           *bool                   `yaml:"must_login"`  // 是否必须登录
	DataFile            string                  `yaml:"data_file"`   // 文件路径
	DataSource          string                  `yaml:"data_source"` // 数据源
	RunStartup          bool                    `yaml:"run_startup"` // 启动是否运行
	FileData            string                  // 文件内容
	Pagination          string                  //分页字段
	FileDataTpl         *text_template.Template // 文件内容的模板
	Count               string
	CountFile           string                  `yaml:"count_file"` // count文件路径
	CountFileData       string                  // count文件内容
	CountFileDataTpl    *text_template.Template // count文件内容模板
	CurrentDir          string                  // 当前路径目录
	Path                string                  // 当前路径
	IgnoreFields        []string                `yaml:"ignore_fields"` //忽略字段
	UpdateFields        []string                `yaml:"update_fields"` // 更新路径
	Log                 bool                    // 是否写日志
	HandlerParams       []HandlerParam          `yaml:"handler_params"` //运行模块前处理参数
	ResultHandler       []HandlerParam          `yaml:"result_handler"` //运行模块完成结果处理参数
	Filter              map[string]interface{}  //过滤条件
	ModelField          string                  `yaml:"model_field"`
	ExcelConfig         string                  `yaml:"excel_config"` // 保存路径
	ExcelConfigContent  string
	ExcelConfigData     *ExcelConfig //
	ModifyConfig        string       `yaml:"modify_config"` // 保存路径
	ModifyConfigContent string
	ModifyConfigData    *ModifyConfig //
	HttpJson            string        `yaml:"http_json"` // http路径
	HttpJsonContent     string
	DataJson            string `yaml:"data_json"` // data_json
	DataJsonContent     string
	DataJsonConfig      *DataJsonConfig // data_json 配置
	HttpConfigData      *HttpConfig     //
	Success             string
	SuccessTpl          *text_template.Template // http 请求验证模板
	Batch               HandlerParam            //批量处理参数
}

* * 服务

type ServiceList

type ServiceList struct {
	Service    []ServiceConfig // 服务列表
	CurrentDir string          // 当前路径目录
	Path       string          // 当前路径
}

type Sheets

type Sheets struct {
	TitleHeight  float64 `json:"title_height"`
	Data         string
	Title        string
	TitleTpl     *text_template.Template // 是否启用模板
	Fields       []SubField              // 字段信息
	TitleStyle   excelize.Style          `json:"title_style"`   // 标题样式
	NameStyle    excelize.Style          `json:"name_style"`    // 标题样式
	ContentStyle excelize.Style          `json:"content_style"` // 标题样式
}

type SubField

type SubField struct {
	Key         string                  // 关键字
	From        string                  // 来源
	FromTpl     *text_template.Template // 来源模板
	To          string                  // 目标
	Name        string                  // 名称
	Template    string                  // 渲染模板
	Type        string                  //类型
	TemplateTpl *text_template.Template // 检查内容模板
	ErrMsg      string                  `yaml:"err_msg"json:"err_msg"` // 错误提示
	ErrMsgTpl   *text_template.Template // 错误提示模板
	Field       string                  // 字段
	FieldTpl    *text_template.Template // 字段模板
	Fields      []ThirdField            // 二级字段列表
	ThirdField  string                  `yaml:"third_field"`
	ThirdFields []ThirdField            `yaml:"third_fields"` // 三级字段列表

	ThirdArrayField  string       `yaml:"third_array_field"`
	ThirdArrayFields []ThirdField `yaml:"third_array_fields"` // 三级字段列表

	Rule      string // 规则
	Width     float64
	SaveField string `yaml:"save_field"json:"save_field"`
}

type Template

type Template struct {
	Service string // 服务名称
	OpUser  string // 操作用户
	EventId string // 事件ID

	ServiceConfig
	RouterAllConfig *RouterAll // 总服务路由
	// contains filtered or unexported fields
}

func (*Template) AddParam

func (t *Template) AddParam(name string, data interface{})

func (*Template) GetAfterPlugins

func (t *Template) GetAfterPlugins() []Plugin

GetAfterPlugins 处理执行后参数

func (*Template) GetAppKey

func (t *Template) GetAppKey(key string) string

* ** 获取应用的key

func (*Template) GetBeforePlugins

func (t *Template) GetBeforePlugins() []Plugin

GetBeforePlugins 处理执行前参数

func (*Template) GetCount

func (t *Template) GetCount() int64

GetCount 获取模板的count

func (*Template) GetEventId

func (t *Template) GetEventId() string

获取事件ID

func (*Template) GetFileData

func (t *Template) GetFileData() string

获取文件内容

func (*Template) GetOpUser

func (t *Template) GetOpUser() string

获取操作用户

func (*Template) GetParam

func (t *Template) GetParam(key string) interface{}

func (*Template) GetParams

func (t *Template) GetParams() map[string]interface{}

获取参数

func (*Template) GetResult

func (t *Template) GetResult() *common.Result

GetResult 获取导出结果

func (*Template) GetService

func (t *Template) GetService() string

获取服务名称

func (*Template) HasParam

func (t *Template) HasParam(key string) bool

func (*Template) HasResult

func (t *Template) HasResult() bool

func (*Template) LogData

func (t *Template) LogData(data interface{})

func (*Template) LogErr

func (t *Template) LogErr(data interface{})

func (*Template) ParseRouterAll

func (t *Template) ParseRouterAll(filePath string) (RouterAll, bool)

* * ParseRouterAll 转换总路由

func (*Template) ParseYaml

func (t *Template) ParseYaml(filePath string, out interface{}) (interface{}, bool)

* 转换yaml 文件 *

func (*Template) ReadFileBytes

func (t *Template) ReadFileBytes(filePath string) ([]byte, bool)

* ** 获取应用的key

func (*Template) Result

func (t *Template) Result()

* * 获取结果

func (*Template) SetCount

func (t *Template) SetCount(count int64)

SetCount 设置模板的计算count

func (*Template) SetEventId

func (t *Template) SetEventId(eventId string) Template

func (*Template) SetFileData

func (t *Template) SetFileData(fileData string) Template

设置文件内容

func (*Template) SetOpUser

func (t *Template) SetOpUser(opUser string) Template

func (*Template) SetParam

func (t *Template) SetParam(key string, value interface{})

func (*Template) SetParams

func (t *Template) SetParams(params map[string]interface{}) Template

设置参数

func (*Template) SetResult

func (t *Template) SetResult(result *common.Result)

SetResult 设置模板的结果

func (*Template) SetService

func (t *Template) SetService(serviceName string) Template

func (*Template) ToString

func (t *Template) ToString() string

type ThirdField

type ThirdField struct {
	From  string // 来源
	To    string // 目标
	Name  string // 名称
	Field string
}

Jump to

Keyboard shortcuts

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