jcbaseGo

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 7 Imported by: 1

README

jcbaseGo

自用开发工具包

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config interface{}

Config 实例化后配置信息将储存在此全局变量中

Functions

func PanicIfError added in v0.6.1

func PanicIfError(err interface{})

PanicIfError 异常处理 如果err不为nil,则直接panic,用于省略if判断

Types

type AttachmentStruct added in v0.6.1

type AttachmentStruct struct {
	Dir        string `json:"dir" default:"attachment"`   // 附件存储目录
	RemoteType string `json:"remoteType" default:"local"` // 附件存储类型 local 本地存储 oss 阿里云存储 cos 腾讯云存储
}

AttachmentStruct 附件配置

type CosStruct added in v0.6.1

type CosStruct struct {
	SecretId  string `json:"secretId" default:""`  // 腾讯云Cos SecretId
	SecretKey string `json:"secretKey" default:""` // 腾讯云Cos SecretKey
	Bucket    string `json:"bucket" default:""`    // 腾讯云Cos Bucket
	Region    string `json:"region" default:""`    // 腾讯云Cos Region
	Url       string `json:"url" default:""`       // 腾讯云Cos Url
}

CosStruct cos配置

type DbStruct added in v0.2.1

type DbStruct struct {
	DriverName    string `json:"driverName" default:"mysql"`   // 驱动类型
	Protocol      string `json:"protocol" default:"tcp"`       // 协议
	Host          string `json:"host" default:"localhost"`     // 数据库地址
	Port          string `json:"port" default:"3306"`          // 数据库端口号
	Dbname        string `json:"dbname" default:"dbname"`      // 表名称
	Username      string `json:"username" default:"root"`      // 用户名
	Password      string `json:"password" default:""`          // 密码
	Charset       string `json:"charset" default:"utf8mb4"`    // 编码
	TablePrefix   string `json:"tablePrefix" default:"jc_"`    // 表前缀
	ParseTime     string `json:"parseTime" default:"False"`    // 是否开启时间解析
	SingularTable string `json:"singularTable" default:"true"` // 使用单数表名
}

DbStruct 数据库配置

type DefaultConfigStruct added in v0.6.1

type DefaultConfigStruct struct {
	Db         DbStruct         `json:"db"`         // 数据库配置信息
	Redis      RedisStruct      `json:"redis"`      // redis配置信息
	Attachment AttachmentStruct `json:"attachment"` // 附件配置信息
	Oss        OssStruct        `json:"oss"`        // oss配置信息
	Cos        CosStruct        `json:"cos"`        // cos配置信息
	Project    ProjectStruct    `json:"project"`    // 项目配置信息
	Repository RepositoryStruct `json:"repository"` // 仓库配置信息
}

DefaultConfigStruct 默认配置信息结构 一般情况下推荐自定义,不想自定义的情况下可以采用默认结构

type MailerStruct added in v0.6.1

type MailerStruct struct {
	Scheme   string `json:"scheme" default:"smtp"`             // 邮箱协议
	Host     string `json:"host" default:"smtp.qq.com"`        // 邮箱地址
	Port     string `json:"port" default:"465"`                // 邮箱端口号
	Username string `json:"username" default:"example@qq.com"` // 邮箱用户名
	Password string `json:"password" default:"123456"`         // 邮箱密码
}

MailerStruct 发送邮箱配置

type MysqlModel added in v0.6.1

type MysqlModel struct {
	Id        uint   `gorm:"column:id;type:INT(11) UNSIGNED;primaryKey;autoIncrement" json:"id"`
	UpdatedAt string `gorm:"column:updated_at;type:DATETIME;default:NULL;comment:更新时间" json:"updated_at"`       // 更新时间
	CreatedAt string `gorm:"column:created_at;type:DATETIME;default:NULL;comment:创建时间" json:"created_at"`       // 创建时间
	DeletedAt string `gorm:"column:deleted_at;type:DATETIME;index;default:NULL;comment:删除时间" json:"deleted_at"` // 删除时间
}

MysqlModel gorm基础模型

type Option added in v0.6.1

type Option struct {
	ConfigFile  string      `json:"config_file" default:"./config/main.json"` // 配置文件路径
	ConfigData  interface{} `json:"config_data"`                              // 配置信息
	RuntimePath string      `json:"runtime_path" default:"/runtime/"`         // 运行缓存目录
}

Option jcbaseGo配置选项

func New added in v0.3.1

func New(opt Option) *Option

New 初始化配置

func (*Option) ConfigToStruct added in v0.6.1

func (opt *Option) ConfigToStruct(configStruct interface{})

ConfigToStruct 将 Option.ConfigData 赋值到自定义结构体中

func (*Option) GetConfig added in v0.6.1

func (opt *Option) GetConfig() *interface{}

GetConfig 获取配置信息

func (*Option) GetConfigOption added in v0.6.1

func (opt *Option) GetConfigOption() Option

GetConfigOption 获取配置选项

type OssStruct added in v0.6.1

type OssStruct struct {
	AccessKeyId     string `json:"AccessKeyId" default:""`     // 阿里云AccessKeyId
	AccessKeySecret string `json:"AccessKeySecret" default:""` // 阿里云AccessKeySecret
	Endpoint        string `json:"endpoint" default:""`        // 阿里云Oss endpoint
	Bucket          string `json:"bucket" default:""`          // 阿里云Oss bucket
}

OssStruct oss配置

type ProjectStruct added in v0.6.1

type ProjectStruct struct {
	Name string `json:"name" default:"jcbaseGo"` // 项目名称
}

ProjectStruct 项目配置

type RedisStruct added in v0.2.1

type RedisStruct struct {
	Host     string `json:"host" default:"localhost"` // redis地址
	Port     string `json:"port" default:"6379"`      // redis端口号
	Password string `json:"password" default:""`      // redis密码
	Db       string `json:"db" default:"0"`           // redis数据库
}

RedisStruct redis配置

type RepositoryStruct added in v0.2.1

type RepositoryStruct struct {
	Dir        string `json:"dir" default:"./project/app/"`                            // 本地仓库目录
	Branch     string `json:"branch" default:"master"`                                 // 远程仓库分支
	RemoteName string `json:"remoteName" default:"origin"`                             // 远程仓库名称
	RemoteURL  string `json:"remoteURL" default:"git@github.com:jcbowen/jcbaseGo.git"` // 远程仓库地址
}

RepositoryStruct 仓库配置

type SQLLiteModel added in v0.6.1

type SQLLiteModel struct {
	Id        uint   `gorm:"column:id;type:INTEGER;primaryKey;autoIncrement" json:"id"`
	UpdatedAt string `gorm:"column:updated_at;type:STRING;default:NULL" json:"updated_at"`       // 更新时间
	CreatedAt string `gorm:"column:created_at;type:STRING;default:NULL" json:"created_at"`       // 创建时间
	DeletedAt string `gorm:"column:deleted_at;type:STRING;index;default:NULL" json:"deleted_at"` // 删除时间
}

SQLLiteModel gorm基础模型

type SSLStruct added in v0.6.1

type SSLStruct struct {
	CertPath string `json:"cert_path" default:""`
	KeyPath  string `json:"key_path" default:""`
}

SSLStruct ssl配置

type SqlLiteStruct added in v0.6.1

type SqlLiteStruct struct {
	DbFile        string `json:"dbFile" default:"./db/jcbaseGo.db"` // 数据库文件
	TablePrefix   string `json:"tablePrefix" default:"jc_"`         // 表前缀
	SingularTable string `json:"singularTable" default:"true"`      // 使用单数表名
}

SqlLiteStruct sqlite配置

Directories

Path Synopsis
example
library

Jump to

Keyboard shortcuts

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