utils

package
v2.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DateTimeFormat = "2006-01-02 15:04:05"

DateTimeFormat 时间转换格式

Variables

View Source
var ErrorCode = errorCode{
	SUCCESS:      0,
	ERROR:        1,
	NotFound:     404,
	LoginError:   1000,
	LoginTimeout: 1001,
	InActive:     1002,
}

ErrorCode �错误码

View Source
var LOC, _ = time.LoadLocation("Local")

Functions

func AvoidXSS

func AvoidXSS(theHTML string) string

AvoidXSS 避免XSS

func DeepFields

func DeepFields(ifaceType reflect.Type) []reflect.StructField

func GetFileMsg

func GetFileMsg(file *multipart.FileHeader) (string, []byte, error)

GetFileMsg ...

func GetIntFromEnv

func GetIntFromEnv(key string, v int) int

func GetInterfaceType

func GetInterfaceType(value interface{}) string

func GetStringFromEnv

func GetStringFromEnv(key string, v string) string

func GetTodayTime

func GetTodayTime() time.Time

GetTodayTime 返回今天零点的time

func GetTodayYM

func GetTodayYM(sep string) string

GetTodayYM 得到以sep为分隔符的年、月字符串(今天所属于的月份)

func GetTodayYMD

func GetTodayYMD(sep string) string

GetTodayYMD 得到以sep为分隔符的年、月、日字符串(今天)

func GetTomorrowYMD

func GetTomorrowYMD(sep string) string

GetTomorrowYMD 得到以sep为分隔符的年、月、日字符串(明天)

func GetYesterdayTime

func GetYesterdayTime() time.Time

GetYesterdayTime 返回昨天零点的time

func GetYesterdayYMD

func GetYesterdayYMD(sep string) string

GetYesterdayYMD 得到以sep为分隔符的年、月、日字符串(昨天)

func GormBatchInsert

func GormBatchInsert(db *gorm.DB, values interface{}, validColList []string, invalidList map[string]interface{}) error

批量插入数据 values 参数必须为 数组, validColList 为想插入的字段

func Interface2String

func Interface2String(value interface{}) string

func LuosimaoVerify

func LuosimaoVerify(reqURL, apiKey, response string) error

LuosimaoVerify 对前端的验证码进行验证

func Paginator

func Paginator(page, prepage int, nums int64) map[string]interface{}

Paginator 分页工具

func RelativeURLToAbsoluteURL

func RelativeURLToAbsoluteURL(curURL string, baseURL string) (string, error)

RelativeURLToAbsoluteURL 相对URL转绝对URL

func SaveFile

func SaveFile(filePath string, content []byte) error

SaveFile ...

func SendErrJSON

func SendErrJSON(msg string, args ...interface{})

SendErrJSON 有错误发生时,发送错误JSON

func SetStructByJSON

func SetStructByJSON(obj interface{}, mapData map[string]interface{}) error

SetStructByJSON 由json对象生成 struct

func StrToIntMonth

func StrToIntMonth(month string) int

StrToIntMonth 字符串月份转整数月份

func String2Interface

func String2Interface(value string, vtype string) (interface{}, error)

func StructCopy

func StructCopy(DstStructPtr interface{}, SrcStructPtr interface{})

func VarsOption

func VarsOption(vars map[string]interface{}) client.Option

Types

type JSON

type JSON []byte

func (JSON) Equals

func (j JSON) Equals(j1 JSON) bool

func (JSON) IsNull

func (j JSON) IsNull() bool

func (JSON) MarshalJSON

func (m JSON) MarshalJSON() ([]byte, error)

func (*JSON) Scan

func (j *JSON) Scan(value interface{}) error

func (*JSON) UnmarshalJSON

func (m *JSON) UnmarshalJSON(data []byte) error

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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