Documentation ¶
Index ¶
- Constants
- func CallPluginFunc(pluginLoader interface{}, plugin Plugin, t *Template, args ...interface{}) *common.Result
- func CastTemplate(fileData string) (*text_template.Template, error)
- func GetServiceName(params map[string]interface{}) string
- func LoadTemplatePlugins(pluginLoader interface{}, plugins []Plugin, t *Template, routerAll *RouterAll)
- func NewTemplateService(params map[string]interface{}) *common.Result
- func SetLocalRouter(routerAll RouterAll)
- func ToTpl(tplContent string, toField string, target interface{}) error
- type BasicAuth
- type DataJsonConfig
- type ExcelConfig
- type HandlerParam
- type HttpConfig
- type ModifyConfig
- type ParamConfig
- type Plugin
- type PluginLoader
- func (t *PluginLoader) LoadCacheConfig(config Plugin, template *Template, routerAll *RouterAll)
- func (t *PluginLoader) LoadDataFile(config Plugin, template *Template, routerAll *RouterAll)
- func (t *PluginLoader) LoadDataFileTpl(config Plugin, template *Template, routerAll *RouterAll)
- func (t *PluginLoader) LoadDataJson(config Plugin, template *Template, routerAll *RouterAll)
- func (t *PluginLoader) LoadExcelConfig(config Plugin, template *Template, routerAll *RouterAll)
- func (t *PluginLoader) LoadHttpJson(config Plugin, template *Template, routerAll *RouterAll)
- func (t *PluginLoader) LoadModifyConfig(config Plugin, template *Template, routerAll *RouterAll)
- func (t *PluginLoader) LoadPreventDuplicationConfig(config Plugin, template *Template, routerAll *RouterAll)
- func (t *PluginLoader) LoadRouterAllEnable(config Plugin, template *Template, routerAll *RouterAll)
- func (t *PluginLoader) LoadSchedule(config Plugin, template *Template, routerAll *RouterAll)
- type ProjectLink
- type ProjectLinkInfo
- type RouterAll
- type RouterProject
- type Schedule
- type ServiceConfig
- type ServiceList
- type Sheets
- type SubField
- type Template
- func (t *Template) AddParam(name string, data interface{})
- func (t *Template) GetAfterPlugins() []Plugin
- func (t *Template) GetAppKey(key string) string
- func (t *Template) GetBeforePlugins() []Plugin
- func (t *Template) GetCount() int64
- func (t *Template) GetEventId() string
- func (t *Template) GetFileData() string
- func (t *Template) GetOpUser() string
- func (t *Template) GetParam(key string) interface{}
- func (t *Template) GetParams() map[string]interface{}
- func (t *Template) GetResult() *common.Result
- func (t *Template) GetService() string
- func (t *Template) HasParam(key string) bool
- func (t *Template) HasResult() bool
- func (t *Template) LogData(data interface{})
- func (t *Template) LogErr(data interface{})
- func (t *Template) ParseRouterAll(filePath string) (RouterAll, bool)
- func (t *Template) ParseYaml(filePath string, out interface{}) (interface{}, bool)
- func (t *Template) ReadFileBytes(filePath string) ([]byte, bool)
- func (t *Template) Result()
- func (t *Template) SetCount(count int64)
- func (t *Template) SetEventId(eventId string) Template
- func (t *Template) SetFileData(fileData string) Template
- func (t *Template) SetOpUser(opUser string) Template
- func (t *Template) SetParam(key string, value interface{})
- func (t *Template) SetParams(params map[string]interface{}) Template
- func (t *Template) SetResult(result *common.Result)
- func (t *Template) SetService(serviceName string) Template
- func (t *Template) ToString() string
- type ThirdField
Constants ¶
View Source
const ServiceName = "service"
Variables ¶
This section is empty.
Functions ¶
func CallPluginFunc ¶
func CastTemplate ¶
func CastTemplate(fileData string) (*text_template.Template, error)
func LoadTemplatePlugins ¶
func LoadTemplatePlugins(pluginLoader interface{}, plugins []Plugin, t *Template, routerAll *RouterAll)
* 加载模板级别的插件
func NewTemplateService ¶
* * 根据参数转模板服务
func SetLocalRouter ¶
func SetLocalRouter(routerAll RouterAll)
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 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 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 ¶
type ProjectLink struct { Service []ProjectLinkInfo // 项目路由 CurrentDir string // 当前路径目录 Path string // 当前路径 }
* 项目关联服务
type ProjectLinkInfo ¶
** 文件目录
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) 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 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) GetAfterPlugins ¶
GetAfterPlugins 处理执行后参数
func (*Template) GetBeforePlugins ¶
GetBeforePlugins 处理执行前参数
func (*Template) ParseRouterAll ¶
* * ParseRouterAll 转换总路由
func (*Template) ReadFileBytes ¶
* ** 获取应用的key
func (*Template) SetEventId ¶
func (*Template) SetService ¶
Click to show internal directories.
Click to hide internal directories.