base

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

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

Go to latest
Published: Mar 4, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MysqlMaxLifetime = 10 * 60 * 1000
	MysqlMaxOpenConn = 50
	MysqlMaxIdleConn = 1000
)
View Source
const (
	RedisMaxIdle      = 3
	RedisMaxActive    = 5
	RedisMIdleTimeout = 240 * time.Second
)
View Source
const MD5 = "12qw12er34sd"

Variables

View Source
var (
	CodeDataSuccess  = Code{Code: 200, Msg: "success"}
	CodeDataEmpty    = Code{Code: 517, Msg: "empty"}
	CodeDataLoss     = Code{Code: 400, Msg: "data loss"}
	CodeDataError    = Code{Code: 401, Msg: "data error"}
	CodeUserNotLogin = Code{Code: 402, Msg: "user not logged in"}
	CodeUserHas      = Code{Code: 403, Msg: "user has"}
)

--------定义返回码,以及返回信息

View Source
var MysqlUrl string
View Source
var RedisPassword string
View Source
var RedisUrl string

Functions

func Config

func Config()

func GetMd5String

func GetMd5String(s string) string

生成32位md5字串

func Offer

func Offer(pageNum, pageSize string) (int, int)

分页

func Struct2Map

func Struct2Map(obj interface{}) (data map[string]interface{}, err error)

结构体转map

func UniqueId

func UniqueId() string

生成Guid字串

Types

type Code

type Code struct {
	Code int
	Msg  string
}

--------Code返回码结构体

type ReturnMsg

type ReturnMsg struct {
	Code  int         `json:"code"`
	Msg   string      `json:"msg"`
	Total int64       `json:"total"`
	Data  interface{} `json:"data"`
}

--------对需要返回的信息进行封装,方便对数据进行进一步处理

func RetunMsgFunc

func RetunMsgFunc(code Code, total int64, data interface{}) *ReturnMsg

--------对需要返回的信息进行赋值,并以结构体返回

Jump to

Keyboard shortcuts

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