Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop

This commit is contained in:
eson
2023-06-05 17:57:55 +08:00
25 changed files with 1493 additions and 20 deletions

View File

@@ -58,13 +58,13 @@ func CheckAuth(r *http.Request) UserInfo {
token = r.Header.Get("Auth-Key")
}
if token == "" {
logx.Debug("token is empty")
logx.Error("token is empty")
return UserInfo{}
}
//解析token
userInfo, err := ParseJwtToken(token)
if err != nil {
logx.Debug(err)
logx.Error(err)
return UserInfo{}
}
return userInfo

13
utils/format/price.go Normal file
View File

@@ -0,0 +1,13 @@
package format
import (
"fmt"
"strconv"
)
// 美分转美元
func CentoDollar(price int64) float64 {
str := fmt.Sprintf("%.2f", float64(price)/float64(100))
dollar, _ := strconv.ParseFloat(str, 64)
return dollar
}

View File

@@ -0,0 +1,21 @@
package format
import (
"strconv"
)
// 字符串切片转int切片
func StrSlicToIntSlice(input []string) ([]int, error) {
priceSlic := make([]int, 0, len(input))
for _, p := range input {
if p == "" {
continue
}
price, err := strconv.Atoi(p)
if err != nil {
return nil, err
}
priceSlic = append(priceSlic, price)
}
return priceSlic, nil
}