mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-13 20:53:49 +08:00
发布v2.6.10版本,更新内容请查看:https://github.com/bufanyun/hotgo/blob/v2.0/docs/guide-zh-CN/start-update-log.md
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
// Package auth
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
// IsExceptAuth 是否是不需要验证权限的路由地址
|
||||
func IsExceptAuth(ctx context.Context, path string) bool {
|
||||
var pathList []string
|
||||
|
||||
except := g.Cfg().MustGet(ctx, "router.admin.exceptAuth")
|
||||
pathList = except.Strings()
|
||||
|
||||
for i := 0; i < len(pathList); i++ {
|
||||
if validate.InSliceExistStr(pathList[i], path) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// IsExceptLogin 是否是不需要登录的路由地址
|
||||
func IsExceptLogin(ctx context.Context, path string) bool {
|
||||
var pathList []string
|
||||
|
||||
except := g.Cfg().MustGet(ctx, "router.admin.exceptLogin")
|
||||
pathList = except.Strings()
|
||||
|
||||
for i := 0; i < len(pathList); i++ {
|
||||
if validate.InSliceExistStr(pathList[i], path) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
@@ -3,13 +3,13 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package format
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"math"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// RoundInt64 四舍五入
|
||||
@@ -19,22 +19,19 @@ func RoundInt64(x float64) int64 {
|
||||
|
||||
// Round2String 四舍五入保留小数,默认2位
|
||||
func Round2String(value float64, args ...interface{}) (v string) {
|
||||
var places int32 = 2
|
||||
var places = 2
|
||||
if len(args) > 0 {
|
||||
places = args[0].(int32)
|
||||
places = gconv.Int(args[0])
|
||||
}
|
||||
|
||||
return decimal.NewFromFloat(value).Round(places).String()
|
||||
cDig := strconv.Itoa(places)
|
||||
val := fmt.Sprintf("%0."+cDig+"f", value)
|
||||
return val
|
||||
}
|
||||
|
||||
// Round2Float64 四舍五入保留小数,默认2位
|
||||
func Round2Float64(value float64, args ...interface{}) (v float64) {
|
||||
var places int32 = 2
|
||||
if len(args) > 0 {
|
||||
places = args[0].(int32)
|
||||
}
|
||||
|
||||
return decimal.NewFromFloat(value).Round(places).InexactFloat64()
|
||||
return gconv.Float64(Round2String(value, args...))
|
||||
}
|
||||
|
||||
// FileSize 字节的单位转换 保留两位小数
|
||||
|
||||
Reference in New Issue
Block a user