utils

package
v0.0.0-...-ae394c8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceError = iota + 4000
	ParameterError
	AuthError
)

Variables

View Source
var ErrMsg = map[int]string{
	ParameterError: "参数错误",
	AuthError:      "无权操作",
}

Functions

func CheckOnlineDevice

func CheckOnlineDevice(te time.Time, str string) bool

func ConvertToStringSlice

func ConvertToStringSlice(arr []int64) []string

ConvertToStringSlice 将int64类型的切片转换为string类型的切片

func DateTimeToString

func DateTimeToString(t time.Time) string

func EndTime

func EndTime(endTime string) (time.Time, error)

func FR

func FR(c *gin.Context, err error)

FR 失败返回

func FRA

func FRA(c *gin.Context)

FRA 无权操作

func FRC

func FRC(c *gin.Context, err error, data interface{}, code int)

FRC 失败返回(Data&Code)

func FRD

func FRD(c *gin.Context, err error, data interface{})

FRD 失败返回(Data)

func FRP

func FRP(c *gin.Context)

FRP 参数错误

func Float64ToString

func Float64ToString(f float64) string

func Int64ToString

func Int64ToString(i int64) string

Int64ToString Int64转string

func IntToString

func IntToString(i int) string

IntToString int转string

func MD5

func MD5(str string) string

func Now

func Now() string

func NowYYMMDD

func NowYYMMDD() string

func ParseIdCard

func ParseIdCard(idCard string) (time.Time, int32)

func PutFile

func PutFile(req *http.Request, paramName string) (object model.Oss, err error)

PutFile 上传文件通用接口

func PutFileWithBase64

func PutFileWithBase64(req *http.Request, paramName string) (object model.Oss, err error)

PutFileWithBase64 上传base64文件

func PutFileWithBinary

func PutFileWithBinary(req *http.Request) (object model.Oss, err error)

PutFileWithBinary 上传二进制文件

func PutFileWithFile

func PutFileWithFile(req *http.Request, paramName string) (object model.Oss, err error)

PutFileWithFile 上传表单文件

func PutFileWithUrl

func PutFileWithUrl(req *http.Request, paramName string) (object model.Oss, err error)

PutFileWithUrl 上传远程文件

func R

func R(c *gin.Context, data interface{}, err error)

R 快捷返回

func RandomStrByNum

func RandomStrByNum(n int) string

RandomStrByNum 获取指定位数的数字随机数

func RandomStrByTime

func RandomStrByTime(n int) string

RandomStrByTime 获取指定位数的随机数(用当前时间作为随机因子)

func RemoveDuplicates

func RemoveDuplicates(a []string) []string

RemoveDuplicates 去除重复字符串

func SHA1

func SHA1(s string) string

SHA1 SHA1加密

func StartTime

func StartTime(startTime string) (time.Time, error)

func StrToTime

func StrToTime(str string) (time.Time, error)

StrToTime string转time.Time

func StringToDateTime

func StringToDateTime(str string) (time.Time, error)

func StringToFloat64

func StringToFloat64(s string) float64

func StringToInt

func StringToInt(s string) int

StringToInt string转int

func StringToInt64

func StringToInt64(s string) int64

StringToInt64 string装int64

func TenantAccessTokenJWTMiddleware

func TenantAccessTokenJWTMiddleware() func(c *gin.Context)

func TimeToString

func TimeToString(t time.Time) string

TimeToString time.Time转string

func TodayEndTime

func TodayEndTime(time time.Time) (time.Time, error)

func TodayStartTime

func TodayStartTime(time time.Time) (time.Time, error)

func TraceId

func TraceId() func(c *gin.Context)

TraceId trace中间件

func UserAccessTokenJWTMiddleware

func UserAccessTokenJWTMiddleware() func(c *gin.Context)

Types

type BaseResponse

type BaseResponse struct {
	Data         interface{} `json:"data" example:"${响应数据}"`
	Success      bool        `json:"success" example:"false"`
	TraceId      string      `json:"traceId" example:"${请求ID}"`
	ErrorCode    int32       `json:"errorCode" example:"${错误编码}"`
	ErrorMessage string      `json:"errorMessage" example:"${错误信息}"`
}

Jump to

Keyboard shortcuts

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