tool

package
v0.0.0-...-8e31122 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//成功Code
	SUCCESS int = 0
	FAIL    int = 1
)
View Source
const CookieName = "cookie_user"
View Source
const CookieTimeLength = 10 * 60

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(data string) ([]byte, error)

func Base64Encode

func Base64Encode(data string) string

func CookieAuth

func CookieAuth(context *gin.Context) (*http.Cookie, error)

func Fail

func Fail(context *gin.Context, v interface{})

请求失败返回内容

func FileServerAddr

func FileServerAddr() string

从配置文件读取文件服务器的ip和端口相关配置

func InitSession

func InitSession(engine *gin.Engine)

初始化session操作

func Md5

func Md5(data string) string

func SessionGet

func SessionGet(context *gin.Context, key interface{}) interface{}

get方法

func SessionSet

func SessionSet(context *gin.Context, key, value interface{}) error

set方法

func Sha256

func Sha256(data string) string

func Success

func Success(context *gin.Context, v interface{})

请求成功返回内容

func UploadFile

func UploadFile(fileName string) string

文件上传到fdfs

Types

type Config

type Config struct {
	AppName  string         `json:"app_name"`
	AppMode  string         `json:"app_mode"`
	AppHost  string         `json:"app_host"`
	AppPort  string         `json:"app_port"`
	Database DatabaseConfig `json:"database"`
	Redis    RedisConfig    `json:"redis"`
}

配置结构体

func GetConfig

func GetConfig() *Config

func ParseConfig

func ParseConfig(path string) (*Config, error)

type DatabaseConfig

type DatabaseConfig struct {
	Driver   string `json:"driver"`
	User     string `json:"user"`
	Password string `json:"password"`
	Host     string `json:"host"`
	Port     string `json:"port"`
	DBName   string `json:"db_name"`
	Charset  string `json:"charset"`
	ShowSql  bool   `json:"show_sql"`
}

数据库配置结构体

type JsonParse

type JsonParse struct {
}

func (*JsonParse) Decode

func (jsonParse *JsonParse) Decode(io io.ReadCloser, v interface{}) error

type Orm

type Orm struct {
	*xorm.Engine
}
var DBEngine *Orm

func OrmEngine

func OrmEngine(cfg *Config) (*Orm, error)

初始化xorm引擎

type RedisConfig

type RedisConfig struct {
	Addr     string `json:"addr"`
	Port     string `json:"port"`
	Password string `json:"password"`
	Db       int    `json:"db"`
}

redis参数配置

type RedisStore

type RedisStore struct {
	// contains filtered or unexported fields
}
var Redis RedisStore

func InitRedis

func InitRedis() *RedisStore

初始化redis参数

Jump to

Keyboard shortcuts

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