filetool

package
v1.0.56 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 4 Imported by: 0

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

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 IsDirExist

func IsDirExist(dirpath string) error

IsDirExist 判断指定的目录是否存在,不存在则创建

func JsonFileToJSONData

func JsonFileToJSONData(filePath string) ([]byte, error)

JsonFileToJSONData JSON文件转换为JSON数据

func JsonMarshalMapToBytes

func JsonMarshalMapToBytes(mapData map[string]interface{}) ([]byte, error)

func JsonToJSONFile

func JsonToJSONFile(jsonData []byte, filePath, fileName string) error

JsonToJSONFile JSON转换为JSON文件

func JsonToYAMLFile

func JsonToYAMLFile(jsonData []byte, filePath string) error

JsonToYAMLFile JSON转换为YAML文件

func JsonUnmarshalBytesToMap

func JsonUnmarshalBytesToMap(data []byte) (map[string]interface{}, error)

func ValidFileSize

func ValidFileSize(data []byte) error

ValidFileSize 验证文件大小。

func ValueFn

func ValueFn[T int | string | json.Number](t T) T

func YamlFileToJSONData

func YamlFileToJSONData(filePath string) ([]byte, error)

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 AppType

type AppType string

AppType 应用类型

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 Object

type Object interface{} // number, string, array, bool, Object, []Object.

type OptionItem

type OptionItem struct {
	Value interface{} `json:"value"`
	Label string      `json:"label"`
}

Jump to

Keyboard shortcuts

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