utils

package
v0.0.0-...-c4624cd Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

@Time : 2019-09-02 16:51 @Author : Frank @Email : frank@163.com @File : log.go @Software: GoLand

@Time : 2019-09-12 10:38 @Author : Frank @Email : frank@163.com @File : tools.go @Software: GoLand

Index

Constants

View Source
const (
	RECODE_OK         = "0"
	RECODE_DBERR      = "401"
	RECODE_NODATA     = "402"
	RECODE_DATAEXIST  = "403"
	RECODE_DATAERR    = "404"
	RECODE_SESSIONERR = "411"
	RECODE_LOGINERR   = "412"
	RECODE_PARAMERR   = "413"
	RECODE_USERERR    = "414"
	RECODE_ROLEERR    = "415"
	RECODE_PWDERR     = "416"
	RECODE_SMSERR     = "417"
	RECODE_REQERR     = "421"
	RECODE_IPERR      = "422"
	RECODE_THIRDERR   = "431"
	RECODE_IOERR      = "432"
	RECODE_SERVERERR  = "450"
	RECODE_UNKNOWERR  = "451"
)

Variables

View Source
var MessageTmpls = map[string]string{
	"Required":     "不能为空",
	"Min":          "最小为 %d",
	"Max":          "最大为 %d",
	"Range":        "范围在 %d 至 %d",
	"MinSize":      "最小长度为 %d",
	"MaxSize":      "最大长度为 %d",
	"Length":       "长度必须是 %d",
	"Alpha":        "必须是有效的字母字符",
	"Numeric":      "必须是有效的数字字符",
	"AlphaNumeric": "必须是有效的字母或数字字符",
	"Match":        "必须匹配格式 %s",
	"NoMatch":      "必须不匹配格式 %s",
	"AlphaDash":    "必须是有效的字母或数字或破折号(-_)字符",
	"Email":        "必须是有效的邮件地址",
	"IP":           "必须是有效的IP地址",
	"Base64":       "必须是有效的base64字符",
	"Mobile":       "必须是有效手机号码",
	"Tel":          "必须是有效电话号码",
	"Phone":        "必须是有效的电话号码或者手机号码",
	"ZipCode":      "必须是有效的邮政编码",
}

Functions

func Contain

func Contain(obj interface{}, target interface{}) (bool, error)

判断元素是否在切片或数组内

func ContainsInt

func ContainsInt(s []interface{}, e interface{}) bool

func CopyStruct

func CopyStruct(src, dst interface{})

结构体copy

func FindUserInfoAsyc

func FindUserInfoAsyc(userInfo string, userChan chan<- UserInfoResp)

func GetUserInfo

func GetUserInfo(userList []int) map[int]interface{}

func GetUserInfoAsyc

func GetUserInfoAsyc(userList []int, userChan chan<- map[int]interface{})

func RecodeText

func RecodeText(code string) string

func SetDefaultMessage

func SetDefaultMessage()

func StringToMap

func StringToMap(str string) (m map[string]interface{})

func StringToSliceInt

func StringToSliceInt(str string) []int

func StringToSliceMap

func StringToSliceMap(str string) (sli []map[string]string)

func StringToSliceString

func StringToSliceString(str string) []string

func ToString

func ToString(sli interface{}) string

func TransferToStruct

func TransferToStruct(src, dst interface{}) (err error)

@Title 结构体相同字段值复制

Types

type LoggerConfig

type LoggerConfig struct {
	FileName            string `json:"file_name"`
	Level               int    `json:"level"`    // 日志保存的时候的级别,默认是 Trace 级别
	Maxlines            int    `json:"maxlines"` // 每个文件保存的最大行数,默认值 1000000
	Maxsize             int    `json:"maxsize"`  // 每个文件保存的最大尺寸,默认值是 1 << 28, //256 MB
	Daily               bool   `json:"daily"`    // 是否按照每天 logrotate,默认是 true
	Maxdays             int    `json:"maxdays"`  // 文件最多保存多少天,默认保存 7 天
	Rotate              bool   `json:"rotate"`   // 是否开启 logrotate,默认是 true
	Perm                string `json:"perm"`     // 日志文件权限
	RotatePerm          string `json:"rotateperm"`
	EnableFuncCallDepth bool   `json:"-"` // 输出文件名和行号
	LogFuncCallDepth    int    `json:"-"` // 函数调用层级
	Separate            string `json:"separate"`
}

beego 日志配置结构体

type User

type User struct {
	UserID   int    `json:"user_id"`
	NickName string `json:"nick_name"`
	Email    string `json:"email"`
	Mobile   string `json:"mobile"`
}

type UserInfoResp

type UserInfoResp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data User   `json:"data"`
}

func FindUserInfo

func FindUserInfo(userInfo string) (user UserInfoResp)

type UserListResp

type UserListResp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data []User `json:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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