Helper

package
v0.0.0-...-1a1764e Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const SYS_CONFIG_PATH = "/application.yaml" //全局配置文件

Variables

View Source
var (
	DBTypeMap = map[string]string{
		"string":    "varchar,char,text,tinytext,mediumtext",
		"int":       "int,tinyint,smallint,mediumint,integer,year,boolean",
		"int64":     "bigint,datetime,timestamp",
		"bool":      "bit",
		"float":     "float,double,decimal",
		"[]byte":    "blob,longblob,mediumblob",
		"time.Time": "date,time",
	}
)
View Source
var WorkDir string

Functions

func CamelCase

func CamelCase(s string) string

驼峰模式

func DBMap

func DBMap(columns []string, rows *sql.Rows) ([]interface{}, error)

把数据结构 映射成 map切片

func Gzip

func Gzip(str string) string

func IsFileExist

func IsFileExist(filepath string) bool

判断api文件是否存在

func LoadResource

func LoadResource(dir string) map[string]string

遍历文件夹,把静态文件读取出来 map["SERVICE_TPL"]=文件里面的内容

func MapDBType

func MapDBType(t string) string

func NewTplFunction

func NewTplFunction() template.FuncMap

给模板使用的函数集

func ReadFile

func ReadFile(f string) []byte

func RemoveTablePrefix

func RemoveTablePrefix(s string) string

func SnakeCase

func SnakeCase(s string) string

下划线模式

func Ucfirst

func Ucfirst(str string) string

首字母大写

func UnGzip

func UnGzip(str string) string

Types

type DBModel

type DBModel struct {
	TableName string
	Data      []interface{} //map切片
}

type MyDB

type MyDB struct {
	*gorm.DB
}

func NewDB

func NewDB(driver string, dsn string) *MyDB

func (*MyDB) DescTable

func (this *MyDB) DescTable(tableName string) (*DBModel, error)

获取表结构

func (*MyDB) GetTable

func (this *MyDB) GetTable() ([]interface{}, error)

type SysConfig

type SysConfig struct {
	DB struct {
		Driver string
		DSN    string
		Prefix string
		Path   string
	}
}

加载yaml 配置文件

func LoadConfig

func LoadConfig() (*SysConfig, error)

Jump to

Keyboard shortcuts

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