utils

package
v0.0.0-...-5a7003e Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: LGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//成功
	SuccessCode = 200
	//错误
	ErrorCode = 400
	//授权失败
	AuthFailCode = 401
	//参数校验失败
	ParamsErrorCode = 402
	//权限不足
	PermissionDeniedCode = 403
	//数据为空
	NullDataCode = 404
	//图片验证码为空
	ImgCodeNull = 500
	//图片验证码错误
	ImgCodeFailCode = 501
	//询问
	ConfirmCode = 700
)
View Source
const (
	GetParsFailResult   = "获取参数失败"
	ParsFailResult      = "参数校验失败"
	GetDataNullResult   = "数据不存在"
	GetDataFailResult   = "获取数据失败"
	AddSuccessResult    = "添加成功"
	UpdateSuccessResult = "修改成功"
	DeleteSuccessResult = "删除成功"
	AddFailResult       = "添加失败"
	UpdateFailResult    = "修改失败"
	DeleteFailResult    = "删除失败"
	GetFailResult       = "获取失败"
)
View Source
const PageSize = 10

Variables

This section is empty.

Functions

func Alert

func Alert(c echo.Context, tip string) error

func AuthFail

func AuthFail(c echo.Context, msg string) error

func AuthFailNull

func AuthFailNull(c echo.Context) error

func AuthFailOrgNull

func AuthFailOrgNull(c echo.Context) error

func CheckEmail

func CheckEmail(value interface{}) bool

检查email

func CheckFloat64Range

func CheckFloat64Range(value interface{}, min, max float64) bool

检查float数据的区间(开区间)

func CheckIPv4

func CheckIPv4(value interface{}) bool

合法的IPV4

func CheckIntRange

func CheckIntRange(value interface{}, min, max int) bool

检查int数据的区间(开区间)

func CheckLen

func CheckLen(value interface{}, length int) bool

检查传入的值的长度,仅支持string、slice或者map 计算String的时候,以正则实现,中文字符算长度1

func CheckMobile

func CheckMobile(value interface{}) bool

检查手机

func CheckRealNumber

func CheckRealNumber(value interface{}) bool

检查传入值是否是实数(包括表示实数的字符串)

func CheckRegexp

func CheckRegexp(value interface{}, rex string) bool

根据正则检查字符串,如果传入的不是string类型,则使用Sprintf处理成字符串再校验。

func CheckType

func CheckType(value interface{}, expectType string) bool

检查数据类型(基于字符串)

func Confirm

func Confirm(c echo.Context, msg string, data interface{}) error

func ConfirmNUll

func ConfirmNUll(c echo.Context, msg string) error

func Contains

func Contains(strs []string, str string) bool

func ContainsInt64

func ContainsInt64(strs []int64, str int64) bool

func CreateFile

func CreateFile(path string) (*os.File, error)

func CurrentDate

func CurrentDate() string

func CurrentDateByPlace

func CurrentDateByPlace(place string) string

func CurrentDirectory

func CurrentDirectory() string

当前目录

func CurrentTime

func CurrentTime() string

func Error

func Error(c echo.Context, msg string, data interface{}) error

func ErrorNull

func ErrorNull(c echo.Context, msg string) error

func FormatMonth

func FormatMonth(t time.Time) string

func FormatMonthChinese

func FormatMonthChinese(t time.Time) string

func FormatTime

func FormatTime(t time.Time) string

func GetFuncName

func GetFuncName() string

func GetPageIndex

func GetPageIndex(pi string) int

func GetPageNumber

func GetPageNumber(count, pageSize int) int

func GetPageSize

func GetPageSize(ps string) int

func GetRand

func GetRand() string

随机数

func ID

func ID() int64

func IDString

func IDString() string

func ImgCodeFail

func ImgCodeFail(c echo.Context) error

func ImgCodeNUll

func ImgCodeNUll(c echo.Context) error

func IsArray

func IsArray(value interface{}) bool

传入参数是否一个数组或者切片

func IsDir

func IsDir(path string) bool

判断是否是文件夹

func IsFile

func IsFile(path string) bool

判断是否是文件

func IsMobile

func IsMobile(s string) bool

func IsUrl

func IsUrl(url string) bool

func IsValidBoolean

func IsValidBoolean(s string) bool

检查字符串是否代表一个合法的bool值 注意返回值仅表示是不是布尔值,并不表示布尔值本身的含义

func IsValidDate

func IsValidDate(s string) bool

func IsValidNumber

func IsValidNumber(s string) bool

检查字符串是不是一个合法的数字

func IsValidTime

func IsValidTime(s string) bool

func IsWechatBrowser

func IsWechatBrowser(userAgent string) bool

func JsonParentPath

func JsonParentPath(params ...string) string

func JsonPath

func JsonPath(params ...string) string

func MkdirAll

func MkdirAll(path string) error

创建多级文件夹

func MobileReplaceRepl

func MobileReplaceRepl(str string) string

func NullData

func NullData(c echo.Context) error

func ParamsError

func ParamsError(c echo.Context, data interface{}) error

func ParseDate

func ParseDate(date string) (time.Time, error)

func ParseExcelDate

func ParseExcelDate(date string) (d *time.Time, err error)

转换excel中日期字符串(有可能为数字格式的字符串)

func ParseTime

func ParseTime(date string) (time.Time, error)

func PathExists

func PathExists(path string) (bool, error)

func PermissionDenied

func PermissionDenied(c echo.Context) error

func Read

func Read(path string) string

func ReadByte

func ReadByte(path string) []byte

func Redirect

func Redirect(c echo.Context, url string) error

func RedirectAndAlert

func RedirectAndAlert(c echo.Context, tip, url string) error

func Result

func Result(c echo.Context, ret int64, msg string, data interface{}) error

func ResultApi

func ResultApi(c echo.Context, data interface{}) error

func ResultHtml

func ResultHtml(c echo.Context, html string) error

func ResultString

func ResultString(c echo.Context, str string) error

func Separator

func Separator() string

系统分隔符

func SubStrByByte

func SubStrByByte(str string, length int) string

func SubStrByByteInChar

func SubStrByByteInChar(str string, length int) string

func Substr

func Substr(s string, pos, length int) string

func Success

func Success(c echo.Context, msg string, data interface{}) error

func SuccessNull

func SuccessNull(c echo.Context, msg string) error

func SuccessNullMsg

func SuccessNullMsg(c echo.Context, data interface{}) error

func SuccessRespone

func SuccessRespone(c echo.Context, data string) error

func Trim

func Trim(str string) string

去除前后所有空格、空字符串、制表符

func TrimHtml

func TrimHtml(src string) string

Types

type Count

type Count struct {
	// contains filtered or unexported fields
}

type CustomBinder

type CustomBinder struct{}

func (*CustomBinder) Bind

func (b *CustomBinder) Bind(i interface{}, c echo.Context) (err error)

Bind implements the `Binder#Bind` function.

type PageData

type PageData struct {
	PageIndex  int         `json:"pageNo"`
	PageSize   int         `json:"pageSize"`
	PageNumber int         `json:"pageNum"`
	Count      int         `json:"totalCount"`
	Data       interface{} `json:"data"`
}

func QueryPage

func QueryPage(db *gorm.DB, page *PageTable, data interface{}, args ...interface{}) (*PageData, error)

func QueryPageMaps

func QueryPageMaps(db *gorm.DB, page *PageTable, args ...interface{}) (*PageData, error)

type PageTable

type PageTable struct {
	Fields    string
	Table     string
	Where     string
	PageIndex int
	PageSize  int
	Order     string
	GroupBy   string
}

type RandID

type RandID struct {
	// contains filtered or unexported fields
}

func NewRandID

func NewRandID() *RandID

func (*RandID) NextId

func (id *RandID) NextId() int64

type Random

type Random struct{}

Random random

func NewRandom

func NewRandom() *Random

NewRandom new random

func (Random) Number

func (rd Random) Number(length float64) int

Number random number

func (Random) NumberByInt

func (rd Random) NumberByInt(start, end int) int

func (Random) String

func (rd Random) String(length int) string

String random string

type ResultParam

type ResultParam struct {
	Ret  int64       `json:"ret"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func ToResultParam

func ToResultParam(b []byte) ResultParam

Directories

Path Synopsis
filetype

Jump to

Keyboard shortcuts

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