Documentation
¶
Index ¶
- Constants
- Variables
- func AggregateEntities(root, dest string) error
- func CopyEntities(path, destPath string) (entities []string)
- func CreateConfig(optsArr ...ConfigOptions) (*viper.Viper, error)
- func GenerateFileExistsHandler(output string, tmpl string, params map[string]string, override bool) error
- func GenerateFromTemplate(templatePath string, outPath string, params map[string]string) error
- func GenerateFromTemplateFile(templateContent, outPath string, params map[string]string) error
- func GenerateUUID() string
- func GetLevelPriority(level zapcore.Level) zap.LevelEnablerFunc
- func MarshalForFiber(v any) ([]byte, error)
- func NewApp() *fiber.App
- func NewGormMysql(cnf configs.MysqlConfig, opts ...gorm.Option) (*gorm.DB, error)
- func NewI18n(config ...configs.I18nConfig) fiber.Handler
- func NewLogger(config configs.LogConfig) (logger *zap.Logger)
- func NewRedis(cnf configs.RedisConfig) (*redis.Client, error)
- func ReadEntities(path string) (entities []string, node *ast.File, err error)
- func SetMode(mode ENV_MODE)
- func StartApp(app *fiber.App)
- func UnmarshalForFiber(data []byte, v any) error
- func ValidatorSetup()
- type Apifox
- type BaseEntity
- type BaseEntityWithID
- type BaseEntityWithUuid
- func (e *BaseEntityWithUuid) BeforeCreate(tx *gorm.DB) error
- func (v BaseEntityWithUuid) MarshalEasyJSON(w *jwriter.Writer)
- func (v BaseEntityWithUuid) MarshalJSON() ([]byte, error)
- func (v *BaseEntityWithUuid) UnmarshalEasyJSON(l *jlexer.Lexer)
- func (v *BaseEntityWithUuid) UnmarshalJSON(data []byte) error
- type Config
- type ConfigInterface
- type ConfigOptions
- type ENV_MODE
- type ImportDTO
- type ImportOptions
- type Logger
- func (f *Logger) CusTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func (f *Logger) GetEncoder() zapcore.Encoder
- func (f *Logger) GetEncoderCore(l zapcore.Level, level zap.LevelEnablerFunc) zapcore.Core
- func (f *Logger) GetWriteSyncer(level string) zapcore.WriteSyncer
- func (f *Logger) GetZapCores() []zapcore.Core
Constants ¶
const ENV_MODE_KEY = "JSON_ENV_MODE"
Variables ¶
var (
ImportPath = "/projects/{projectId}/import-openapi"
)
var (
Validator *validator.Validate
)
Functions ¶
func AggregateEntities ¶
func CopyEntities ¶
func CreateConfig ¶
func CreateConfig(optsArr ...ConfigOptions) (*viper.Viper, error)
func GenerateFromTemplate ¶
func GenerateUUID ¶
func GenerateUUID() string
func GetLevelPriority ¶
func GetLevelPriority(level zapcore.Level) zap.LevelEnablerFunc
GetLevelPriority 根据 zapcore.Level 获取 zap.LevelEnablerFunc
func MarshalForFiber ¶
func NewGormMysql ¶
func UnmarshalForFiber ¶
func ValidatorSetup ¶
func ValidatorSetup()
Types ¶
type BaseEntity ¶
type BaseEntity struct {
CreatedAt time.Time `json:"createdAt" gorm:"index"` // 创建时间
UpdatedAt time.Time `json:"updatedAt" gorm:"index"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"index" json:"-,intern" swaggerignore:"true"` // 删除时间
CreatedBy string `json:"createdBy"` // 创建人
UpdatedBy string `json:"updatedBy"` // 更新人
DeletedBy string `json:"deletedBy,intern" swaggerignore:"true"` // 删除人
}
@Description 核心基础实体
func (BaseEntity) MarshalEasyJSON ¶
func (v BaseEntity) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (BaseEntity) MarshalJSON ¶
func (v BaseEntity) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*BaseEntity) UnmarshalEasyJSON ¶
func (v *BaseEntity) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*BaseEntity) UnmarshalJSON ¶
func (v *BaseEntity) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type BaseEntityWithID ¶
type BaseEntityWithID struct {
ID uint `json:"id" gorm:"primarykey"` // 主键ID
BaseEntity
}
@Description 核心基础实体,带 ID
func (BaseEntityWithID) MarshalEasyJSON ¶
func (v BaseEntityWithID) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (BaseEntityWithID) MarshalJSON ¶
func (v BaseEntityWithID) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*BaseEntityWithID) UnmarshalEasyJSON ¶
func (v *BaseEntityWithID) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*BaseEntityWithID) UnmarshalJSON ¶
func (v *BaseEntityWithID) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type BaseEntityWithUuid ¶
type BaseEntityWithUuid struct {
ID string `json:"id" gorm:"primarykey;type:char(20)"` // 主键ID
BaseEntity
}
@Description 核心基础实体,带 UUID
func (*BaseEntityWithUuid) BeforeCreate ¶
func (e *BaseEntityWithUuid) BeforeCreate(tx *gorm.DB) error
func (BaseEntityWithUuid) MarshalEasyJSON ¶
func (v BaseEntityWithUuid) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (BaseEntityWithUuid) MarshalJSON ¶
func (v BaseEntityWithUuid) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*BaseEntityWithUuid) UnmarshalEasyJSON ¶
func (v *BaseEntityWithUuid) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*BaseEntityWithUuid) UnmarshalJSON ¶
func (v *BaseEntityWithUuid) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func NewConfig ¶
func NewConfig(optsArr ...ConfigOptions) (*Config, error)
type ConfigInterface ¶
type ConfigOptions ¶
type ConfigOptions struct {
BasePath string
FileName string
FileType string
WatchAble bool
OnChange func(e fsnotify.Event)
}
func DefaultConfigOptions ¶
func DefaultConfigOptions() ConfigOptions
type ImportDTO ¶
type ImportDTO struct {
Input string `json:"input"`
Options ImportOptions `json:"options"`
}
type ImportOptions ¶
type ImportOptions struct {
TargetEndpointFolderId string `json:"targetEndpointFolderId"`
TargetSchemaFolderId string `json:"targetSchemaFolderId"`
EndpointOverwriteBehavior string `json:"endpointOverwriteBehavior"`
SchemaOverwriteBehavior string `json:"schemaOverwriteBehavior"`
UpdateFolderOfChangedEndpoint bool `json:"updateFolderOfChangedEndpoint"`
PrependBasePath bool `json:"prependBasePath"`
}
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewLoggerConfig ¶
func (*Logger) CusTimeEncoder ¶
func (f *Logger) CusTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
CustomTimeEncoder 自定义日志输出时间格式
func (*Logger) GetEncoder ¶
GetEncoder 获取 zapcore.Encoder
func (*Logger) GetEncoderCore ¶
GetEncoderCore 获取Encoder的 zapcore.Core
func (*Logger) GetWriteSyncer ¶
func (f *Logger) GetWriteSyncer(level string) zapcore.WriteSyncer
GetWriteSyncer 获取 zapcore.WriteSyncer
func (*Logger) GetZapCores ¶
GetZapCores 根据配置文件的Level获取 []zapcore.Core