Documentation
¶
Index ¶
- Constants
- func AddrCheck(addr string) bool
- func CheckImageFileType(header *multipart.FileHeader) (string, bool)
- func CheckPwd(pwd string) bool
- func FileToByteArray(file *multipart.FileHeader) (fileBuf [][]byte, err error)
- func GenerateRedisKeyByStuId(stuId string, sType int64, device string) string
- func GetAvailablePort() (string, error)
- func GetDeviceID(sid int64) (datacenterid, workerid int64)
- func GetEsHost() (string, error)
- func GetGenTime(sid int64) (t string)
- func GetGenTimestamp(sid int64) (timestamp int64)
- func GetImageFileType(fileBytes *[]byte) (string, error)
- func GetMysqlDSN() (string, error)
- func GetTimestamp(sid int64) (timestamp int64)
- func GetTimestampStatus() (state float64)
- func HandleBaseRespWithCookie(baseResp *model.BaseResp) error
- func HrefEncode(rawQuery string) string
- func IsSuccess(baseResp *model.BaseResp) bool
- func JSONEncode(v interface{}) (string, error)
- func LoadCNLocation() *time.Location
- func MD5(str string) string
- func MD5Bytes(str []byte) string
- func ParseCookies(rawData string) []*http.Cookie
- func ParseCookiesToString(cookies []*http.Cookie) []string
- func ParseJwchStuId(id string) (string, error)
- func RetryLogin(stu *jwch.Student) error
- func SHA256(str string) string
- func TimeParse(date string) (time.Time, error)
- func UriEncode(uri string) string
- type Snowflake
Constants ¶
View Source
const ( NanosecondsInAMillisecond = 1_000_000 // 每毫秒的纳秒数 MillisecondsInASecond = 1000 // 每秒的毫秒数 )
View Source
const DefaultFilePermissions = 0o666 // 默认文件权限
View Source
const StuIDLen = 23
Variables ¶
This section is empty.
Functions ¶
func CheckImageFileType ¶
func CheckImageFileType(header *multipart.FileHeader) (string, bool)
CheckImageFileType 检查文件格式是否合规
func FileToByteArray ¶
func FileToByteArray(file *multipart.FileHeader) (fileBuf [][]byte, err error)
FileToByteArray 用于将客户端发来的文件转换为[][]byte格式,用于流式传输
func GenerateRedisKeyByStuId ¶
GenerateRedisKeyByStuId 开屏页通过学号与sType与device生成缓存对应Key
func GetDeviceID ¶
GetDeviceID 获取数据中心ID和机器ID
func GetGenTimestamp ¶
GetGenTimestamp 获取创建ID时的时间戳
func GetImageFileType ¶
GetImageFileType 获得图片格式
func GetTimestampStatus ¶
func GetTimestampStatus() (state float64)
GetTimestampStatus 获取时间戳已使用的占比:范围(0.0 - 1.0)
func HandleBaseRespWithCookie ¶
HandleBaseRespWithCookie 调用jwch库的接口的结果处理, 将 resp.Base 中包含的错误转换成 errno 类型
func HrefEncode ¶
HrefEncode 解析rawQuery以获得未解码的url(hertz会自动解析未解码的url)
func JSONEncode ¶
func ParseCookies ¶
ParseCookies 将cookie字符串解析为 http.Cookie 这里只能解析这样的数组: "Key=Value; Key=Value"
func ParseCookiesToString ¶
ParseCookiesToString 会尝试解析 cookies 到 string 只会返回 "Key=Value; Key=Value"样式的文本数组
func ParseJwchStuId ¶
ParseJwchStuId 用于解析教务处 id 里的学号 如 20241025133150102401339 的后 9 位
Types ¶
Click to show internal directories.
Click to hide internal directories.