Documentation ¶
Overview ¶
Package filetool @author <chengjiang@buffalo-robot.com> @date 2023-06-25 @note
Package filetool @author <chengjiang@buffalo-robot.com> @date 2023-06-28 @note
Package filetool @author <chengjiang@buffalo-robot.com> @date 2023-06-25 @note
Index ¶
- Constants
- func IsDirExist(dirpath string) error
- func JsonFileToJSONData(filePath string) ([]byte, error)
- func JsonMarshalMapToBytes(mapData map[string]interface{}) ([]byte, error)
- func JsonToJSONFile(jsonData []byte, filePath, fileName string) error
- func JsonToYAMLFile(jsonData []byte, filePath string) error
- func JsonUnmarshalBytesToMap(data []byte) (map[string]interface{}, error)
- func ValidFileSize(data []byte) error
- func ValueFn[T int | string | json.Number](t T) T
- func YamlFileToJSONData(filePath string) ([]byte, error)
- type AppConfig
- type AppType
- type ComponentType
- type ConfigItem
- type EnvironmentType
- type FormatAppConfig
- type FormatConfigItem
- type Object
- type OptionItem
Constants ¶
View Source
const ( APP_TYPE_Pubilc = "Public" // 公共配置 APP_TYPE_Private = "Private" // 应用独立配置 )
View Source
const ( ENV_TYPE_BETA = "Beta" ENV_TYPE_DEV = "Dev" ENV_TYPE_PRD = "Prd" )
View Source
const ( COMP_TYPE_Empty ComponentType = "" COMP_TYPE_INPUT = "Input" COMP_TYPE_INPUT_NUMBER = "InputNumber" COMP_TYPE_SELECT = "Select" )
Variables ¶
This section is empty.
Functions ¶
func JsonFileToJSONData ¶
JsonFileToJSONData JSON文件转换为JSON数据
func JsonMarshalMapToBytes ¶
func JsonToJSONFile ¶
JsonToJSONFile JSON转换为JSON文件
func JsonToYAMLFile ¶
JsonToYAMLFile JSON转换为YAML文件
func JsonUnmarshalBytesToMap ¶
func YamlFileToJSONData ¶
YamlFileToJSONData YAML文件转换为JSON数据
Types ¶
type AppConfig ¶
type AppConfig struct { Environment EnvironmentType `json:"environment"` // 环境,beta, dev, prd. AppId string `json:"appId"` AppType AppType `json:"appType"` AppName string `json:"appName"` ConfigItems []*ConfigItem `json:"configItems,omitempty"` }
func StructConfig2Web ¶
func StructConfig2Web(conf *FormatAppConfig) *AppConfig
type ComponentType ¶
type ComponentType string
type ConfigItem ¶
type ConfigItem struct { Field string `json:"field"` // 字段的key Component ComponentType `json:"component"` // 组件类型, input, inputNumber, select. Label string `json:"label"` // 前端界面展示字段名字,这里可以展示 field SubLabel string `json:"subLabel"` // 描述,Description. DefaultValue interface{} `json:"defaultValue"` // 默认值 如果是下拉选项需要对应options value 字段, 类型:数字,字符串,布尔。 CurValue interface{} `json:"curValue"` // 当前值. Options []*OptionItem `json:"options,omitempty"` // 下拉选项, 这里存成json对象数组。 Required bool `json:"required"` // 是否必填. Child [][]*ConfigItem `json:"child,omitempty"` // 聚合。 }
type EnvironmentType ¶
type EnvironmentType string
type FormatAppConfig ¶
type FormatAppConfig struct { Environment EnvironmentType `json:"environment"` // 环境,beta, dev, prd. AppId string `json:"appId"` AppType AppType `json:"appType"` AppName string `json:"appName"` ConfigItems map[string]interface{} `json:"configItems,omitempty"` }
FormatAppConfig 格式化model,过滤掉前端得一些配置:并将过滤之后得model数据传递给各自应用。
func FormatConfig ¶
func FormatConfig(conf *AppConfig) *FormatAppConfig
type FormatConfigItem ¶
type FormatConfigItem struct { //Field string `json:"field"` // 字段的key DefaultValue interface{} `json:"defaultValue,omitempty"` // 默认值 如果是下拉选项需要对应options value 字段, 类型:数字,字符串,布尔。 CurValue interface{} `json:"curValue,omitempty"` // 当前值. Options []*OptionItem `json:"options,omitempty"` // 下拉选项, 这里存成json对象数组。 Child []*FormatConfigItem `json:"child,omitempty"` // key: Field 专门针对,yaml中有数组配置得情况,如job定时任务得配置,需要有数组。 }
type OptionItem ¶
type OptionItem struct { Value interface{} `json:"value"` Label string `json:"label"` }
Click to show internal directories.
Click to hide internal directories.