You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
1.8 KiB
89 lines
1.8 KiB
package internal
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
"wss-pool/pkg/model"
|
|
)
|
|
|
|
// Analysis of spot parameters
|
|
func StrParamStr(c *gin.Context) (*model.SpotsModel, error) {
|
|
var paramModel model.SpotsModel
|
|
err := c.BindJSON(¶mModel)
|
|
if err != nil {
|
|
return ¶mModel, err
|
|
}
|
|
return ¶mModel, err
|
|
}
|
|
|
|
// Contract parameter analysis
|
|
func ContractStr(c *gin.Context) (*model.ContractModel, error) {
|
|
var paramModel model.ContractModel
|
|
err := c.BindJSON(¶mModel)
|
|
if err != nil {
|
|
return ¶mModel, err
|
|
}
|
|
return ¶mModel, err
|
|
}
|
|
|
|
// Empty character replacement
|
|
func ReplaceStr(value string) string {
|
|
return strings.Replace(value, " ", "", 1)
|
|
}
|
|
|
|
// Integer conversion
|
|
func IntegerInit(value string) int {
|
|
in, err := strconv.Atoi(value)
|
|
if err != nil {
|
|
return 0
|
|
}
|
|
return in
|
|
}
|
|
|
|
// TimeMaoSendToString int64 - string
|
|
func TimeMaoSendToString(i int64) string {
|
|
layout := "2006-01-02 15:04:05.000"
|
|
t := time.Unix(0, i*int64(time.Microsecond))
|
|
|
|
return t.Format(layout)
|
|
}
|
|
|
|
// TimeDateToMaoSend time - int64
|
|
func TimeDateToMaoSend(t time.Time) int64 {
|
|
now := time.Now()
|
|
fmt.Println(now)
|
|
return now.UnixMicro()
|
|
}
|
|
|
|
// TimeStringToTime string - time
|
|
func TimeStringToTime(t string) time.Time {
|
|
timeLayout := "2006-01-02 15:04:05"
|
|
loc, err := time.LoadLocation("Local")
|
|
if err != nil {
|
|
return time.Time{}
|
|
}
|
|
theTime, err := time.ParseInLocation(timeLayout, t, loc)
|
|
if err != nil {
|
|
return time.Time{}
|
|
}
|
|
|
|
return theTime
|
|
}
|
|
|
|
// TimeStringToIn64 string - int64
|
|
func TimeStringToIn64(t string) int64 {
|
|
timeLayout := "2006-01-02 15:04:05"
|
|
loc, err := time.LoadLocation("Local")
|
|
if err != nil {
|
|
return int64(0)
|
|
}
|
|
theTime, err := time.ParseInLocation(timeLayout, t, loc)
|
|
if err != nil {
|
|
return int64(0)
|
|
}
|
|
|
|
return theTime.UnixMicro()
|
|
}
|
|
|