mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-26 16:46:14 +08:00
发布v2.3.5版本,本次为优化版本。更新内容请查看:https://github.com/bufanyun/hotgo/blob/v2.0/docs/guide-zh-CN/start-update-log.md
This commit is contained in:
@@ -10,6 +10,10 @@ import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Filter 通用过滤器
|
||||
|
||||
// Filter 预处理和数据过滤接口,目前主要用于input层的输入过滤和内部效验。
|
||||
// 你可以在任意地方使用它,只要实现了Filter接口即可
|
||||
type Filter interface {
|
||||
// Filter gf效验规则 https://goframe.org/pages/viewpage.action?pageId=1114367
|
||||
Filter(ctx context.Context) error
|
||||
|
@@ -9,22 +9,9 @@ package validate
|
||||
import (
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// InSameDay 是否为同一天
|
||||
func InSameDay(t1, t2 int64) bool {
|
||||
y1, m1, d1 := time.Unix(t1, 0).Date()
|
||||
y2, m2, d2 := time.Unix(t2, 0).Date()
|
||||
return y1 == y2 && m1 == m2 && d1 == d2
|
||||
}
|
||||
|
||||
// InSameMinute 是否为同一分钟
|
||||
func InSameMinute(t1, t2 int64) bool {
|
||||
d1 := time.Unix(t1, 0).Format("2006-01-02 15:04")
|
||||
d2 := time.Unix(t2, 0).Format("2006-01-02 15:04")
|
||||
return d1 == d2
|
||||
}
|
||||
// 是否包含判断
|
||||
|
||||
// InSliceExistStr 判断字符或切片字符是否存在指定字符
|
||||
func InSliceExistStr(elems interface{}, search string) bool {
|
||||
|
@@ -14,14 +14,19 @@ import (
|
||||
"net"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 是否判断
|
||||
|
||||
// IsDNSName 是否是域名地址
|
||||
func IsDNSName(s string) bool {
|
||||
DNSName := `^([a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*[\._]?$`
|
||||
rxDNSName := regexp.MustCompile(DNSName)
|
||||
return s != "" && rxDNSName.MatchString(s)
|
||||
}
|
||||
|
||||
// IsHTTPS 是否是https请求
|
||||
func IsHTTPS(ctx context.Context) bool {
|
||||
r := ghttp.RequestFromCtx(ctx)
|
||||
if r == nil {
|
||||
@@ -130,3 +135,17 @@ func IsIDCard(idCard string) bool {
|
||||
m := sum % 11
|
||||
return validate[m] == idCard[sz-1]
|
||||
}
|
||||
|
||||
// IsSameDay 是否为同一天
|
||||
func IsSameDay(t1, t2 int64) bool {
|
||||
y1, m1, d1 := time.Unix(t1, 0).Date()
|
||||
y2, m2, d2 := time.Unix(t2, 0).Date()
|
||||
return y1 == y2 && m1 == m2 && d1 == d2
|
||||
}
|
||||
|
||||
// IsSameMinute 是否为同一分钟
|
||||
func IsSameMinute(t1, t2 int64) bool {
|
||||
d1 := time.Unix(t1, 0).Format("2006-01-02 15:04")
|
||||
d2 := time.Unix(t2, 0).Format("2006-01-02 15:04")
|
||||
return d1 == d2
|
||||
}
|
||||
|
Reference in New Issue
Block a user