init repo

This commit is contained in:
liuyuanchuang
2025-12-10 18:33:37 +08:00
commit 48e63894eb
2408 changed files with 1053045 additions and 0 deletions

30
pkg/utils/sms.go Normal file
View File

@@ -0,0 +1,30 @@
package utils
import "strings"
// 校验手机号
// 规则:
// 1. 长度必须为11位
// 2. 必须以1开头
// 3. 第二位必须是3,4,5,6,7,8,9
// 4. 其余必须都是数字
func ValidatePhone(phone string) bool {
if len(phone) != 11 || !strings.HasPrefix(phone, "1") {
return false
}
// 检查第二位
secondDigit := phone[1]
if secondDigit < '3' || secondDigit > '9' {
return false
}
// 检查剩余数字
for i := 2; i < len(phone); i++ {
if phone[i] < '0' || phone[i] > '9' {
return false
}
}
return true
}