Apply .gitignore rules
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package intUtil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ShuffleIntDigits 打乱整数的各个数字位置并返回新的整数
|
||||
func ShuffleIntDigits(num int64) (int64, error) {
|
||||
if num < 0 {
|
||||
return 0, fmt.Errorf("number must be non-negative")
|
||||
}
|
||||
|
||||
var digits []int64
|
||||
for num > 0 {
|
||||
digits = append(digits, num%10)
|
||||
num /= 10
|
||||
}
|
||||
|
||||
// 如果原始数字是0,直接返回
|
||||
if len(digits) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// 反转切片以保持原来的数字顺序
|
||||
for i, j := 0, len(digits)-1; i < j; i, j = i+1, j-1 {
|
||||
digits[i], digits[j] = digits[j], digits[i]
|
||||
}
|
||||
|
||||
// 打乱数字切片
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
rand.Shuffle(len(digits), func(i, j int) {
|
||||
digits[i], digits[j] = digits[j], digits[i]
|
||||
})
|
||||
|
||||
// 重新组合为新的整数
|
||||
result := int64(0)
|
||||
for _, digit := range digits {
|
||||
result = result*10 + digit
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package qcloud
|
||||
|
||||
// 发送模板短信字段
|
||||
type tmplSmsField struct {
|
||||
// 签名 (前缀)
|
||||
Sign string `json:"sign,omitempty"`
|
||||
// 模板id
|
||||
Tpl_id int `json:"tpl_id,omitempty"`
|
||||
// 模板参数
|
||||
Params []string `json:"params,omitempty"`
|
||||
}
|
||||
|
||||
func newTmplSmsField(sign string, id int, params []string) *tmplSmsField {
|
||||
return &tmplSmsField{
|
||||
Sign: sign,
|
||||
Tpl_id: id,
|
||||
Params: params,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package monitorNewMgr
|
||||
|
||||
// 监控信息传输对象
|
||||
type MonitorModel struct {
|
||||
//状态码 0 是心跳,非零为错误信息
|
||||
Code int `json:"Code"`
|
||||
|
||||
//组Id
|
||||
GroupId string `json:"GroupId"`
|
||||
|
||||
//组密钥
|
||||
ProjectId string `json:"ProjectId"`
|
||||
|
||||
//项目Id
|
||||
ServerIp string `json:"ServerIp"`
|
||||
|
||||
// 监控使用的服务器IP
|
||||
ServerName string `json:"ServerName"`
|
||||
|
||||
// 监控使用的服务器名称
|
||||
Content string `json:"Content"`
|
||||
|
||||
// 消息产生时的时间戳
|
||||
Timestamp int64 `json:"Timestamp"`
|
||||
|
||||
// 签名
|
||||
Sign string `json:"Sign"`
|
||||
}
|
||||
|
||||
func newMonitorModel(code int, groupId, projectId, serverIp, serverName, content string, timestamp int64, sign string) *MonitorModel {
|
||||
return &MonitorModel{
|
||||
Code: code,
|
||||
GroupId: groupId,
|
||||
ProjectId: projectId,
|
||||
ServerIp: serverIp,
|
||||
ServerName: serverName,
|
||||
Content: content,
|
||||
Timestamp: timestamp,
|
||||
Sign: sign,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"common/connection"
|
||||
"sync"
|
||||
|
||||
_ "common/resultStatus"
|
||||
"common/webServer"
|
||||
_ "logincenter/internal/user"
|
||||
)
|
||||
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 设置WaitGroup需要等待的数量,只要有一个服务器出现错误都停止服务器
|
||||
wg.Add(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
//加载配置
|
||||
loadConfig()
|
||||
|
||||
// 启动webserver
|
||||
go webServer.Start(&wg)
|
||||
|
||||
// 阻塞等待,以免main线程退出
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
// loadConfig 用于加载配置信息。
|
||||
// 该函数会读取配置文件或环境变量中的设置,并根据这些设置初始化程序所需的配置。
|
||||
// 目前函数的实现为空,需要根据实际的配置加载逻辑进行填充。
|
||||
func loadConfig() {
|
||||
|
||||
//设置数据类型
|
||||
connection.SetModelDB(connection.GetUserDB())
|
||||
|
||||
//构建数据库
|
||||
connection.BuildDB()
|
||||
}
|
||||
Reference in New Issue
Block a user