版本更新

This commit is contained in:
hahwu 2025-05-06 10:07:31 +08:00
parent 44b4f8fa3c
commit e8c911c20d
11 changed files with 1883 additions and 16 deletions

View File

@ -101,6 +101,9 @@ type NotifyClientData struct {
DeviceModel string `json:"deviceModel"`
OperatingSystem string `json:"operatingSystem"`
UnityVersion string `json:"unityVersion"`
Time string `json:"time"`
AlarmTime string `json:"time"`
DeviceUniqueIdentifier string `json:"deviceUniqueIdentifier"`
Info string `json:"info"`
Id string `json:"id"`
NotifyMsg string `json:"notify_msg"`
}

View File

@ -5,7 +5,7 @@ system:
operation_url: 'https://open.feishu.cn/open-apis/bot/v2/hook/64bad1f3-3a41-4dca-9037-399067ffb252'
operation_chat_id: 'oc_f6e10a55f28f31e2a5677bdcb6aed599'
client_chat_id: 'oc_f6e10a55f28f31e2a5677bdcb6aed599'
ssh: false
ssh: true
mysqls:
- host: '127.0.0.1'
name: 'merge_pet_test'
@ -28,7 +28,7 @@ mysqls:
password: 'GWFj1cHaqjpzvcsHBWTFtLWtm8MUZKROx_wvbV6jPg=='
database: 'merge_pet_london_%d'
idleTimeout: Infinity
- host: '47.254.83.25'
- host: '127.0.0.1'
name: 'merge_pet_online'
port: 3306
user: 'root'

View File

@ -24,6 +24,7 @@ func UserInfo(c *gin.Context) {
func UserList(c *gin.Context) {
var request struct {
Id int `json:"Id"`
Uid int `json:"Uid"`
ServerId int `json:"ServerId"`
PageSize int `json:"pageSize"`
CurrentPage int `json:"currentPage"`
@ -34,7 +35,7 @@ func UserList(c *gin.Context) {
failed(c, err.Error())
return
}
user, total, err := model.GetUserList(request.Id, request.ServerId, request.PageSize, request.CurrentPage)
user, total, err := model.GetUserList(request.Id, request.ServerId, request.PageSize, request.CurrentPage, request.Uid)
if err != nil {
fmt.Print(err)
failed(c, err.Error())

View File

@ -536,13 +536,13 @@ func SendNotifyClientMsg(data *Type.NotifyClientData) error {
"type": "template",
"data": map[string]interface{}{
"template_id": "AAqR0eWBmiN6z",
"template_version_name": "1.0.2",
"template_version_name": "1.0.7",
"template_variable": map[string]interface{}{
"log": data.Log,
"stackTrace": data.StackTrace,
"deviceModel": data.DeviceModel,
"operatingSystem": data.OperatingSystem,
"AlarmTime": data.Time,
"AlarmTime": data.AlarmTime,
"deviceUniqueIdentifier": data.DeviceUniqueIdentifier,
},
},

View File

@ -15,6 +15,7 @@ var handle map[string]func(ctx context.Context, event *callback.CardActionTrigge
func init() {
handle = make(map[string]func(ctx context.Context, event *callback.CardActionTriggerEvent) (*callback.CardActionTriggerResponse, error))
handle["complete_alarm"] = NotifyCard
handle["client"] = NotifyClientCard
}
func Handle(ctx context.Context, event *callback.CardActionTriggerEvent) (*callback.CardActionTriggerResponse, error) {
@ -52,3 +53,33 @@ func NotifyCard(ctx context.Context, event *callback.CardActionTriggerEvent) (*c
},
}, nil
}
func NotifyClientCard(ctx context.Context, event *callback.CardActionTriggerEvent) (*callback.CardActionTriggerResponse, error) {
d := Type.NotifyClientData{
Log: event.Event.Action.Value["Log"].(string),
StackTrace: event.Event.Action.Value["StackTrace"].(string),
DeviceModel: event.Event.Action.Value["DeviceModel"].(string),
OperatingSystem: event.Event.Action.Value["OperatingSystem"].(string),
AlarmTime: event.Event.Action.Value["AlarmTime"].(string),
Info: event.Event.Action.FormValue["notes_input"].(string),
DeviceUniqueIdentifier: event.Event.Action.Value["DeviceUniqueIdentifier"].(string),
Id: event.Event.Operator.OpenID,
}
str := util.ParseTmpl("./template/card_client_notify.tmpl", d)
r := make(map[string]interface{})
err := json.Unmarshal([]byte(str), &r)
if err != nil {
log.Println(str)
log.Printf("notify card %v", err)
}
return &callback.CardActionTriggerResponse{
Toast: &callback.Toast{
Type: "info",
Content: "已收到",
},
Card: &callback.Card{
Type: "raw",
Data: r,
},
}, nil
}

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ import (
"fmt"
)
func GetUserList(AppId, ServerId, PageSize, CurrentPage int) ([]*User, int, error) {
func GetUserList(AppId, ServerId, PageSize, CurrentPage, Uid int) ([]*User, int, error) {
App, err := util.GetAppConfig(AppId)
if err != nil {
return nil, 0, err
@ -17,7 +17,11 @@ func GetUserList(AppId, ServerId, PageSize, CurrentPage int) ([]*User, int, erro
return nil, 0, fmt.Errorf("failed to get MySQL database")
}
users := []*User{}
err = db.Select(&users, "SELECT `dwUin`, `energy`, `star`, `diamond`, `level`, `exp`, `login_time`, `logout_time`, `user_name` FROM t_player_baseinfo Order by login_time desc limit ?, ?", (CurrentPage-1)*PageSize, PageSize)
if Uid != 0 {
err = db.Select(&users, "SELECT `dwUin`, `energy`, `star`, `diamond`, `level`, `exp`, `login_time`, `logout_time`, `user_name` FROM t_player_baseinfo WHERE dwUin = ? ", Uid)
} else {
err = db.Select(&users, "SELECT `dwUin`, `energy`, `star`, `diamond`, `level`, `exp`, `login_time`, `logout_time`, `user_name` FROM t_player_baseinfo Order by login_time desc limit ?, ?", (CurrentPage-1)*PageSize, PageSize)
}
if err != nil {
return nil, 0, fmt.Errorf("failed to get user list: %v", err)
}

View File

@ -63,7 +63,7 @@ func (m *Mail) SendMail() error {
}
Db := util.MPool.GetMysqlDB(AppCfg.ServerName, AppCfg.MysqlName, m.ServerId)
defer Db.Close()
_, err = Db.Exec("INSERT INTO system_mail_info (`title`, `content`, `title_en`, `content_en`, `start_time`, `end_time`, `items`, `register_time`, `mail_type`, `send_type`, `to_uids`, `create_time`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.Title, m.Content, m.TitleEn, m.ContentEn, m.StartTime, m.EndTime, m.Items, m.RegisterTime, m.MailType, m.SendType, m.ToUids, m.CreateTime)
_, err = Db.Exec("INSERT INTO system_mail_info (`title`, `content`, `title_en`, `content_en`, `start_time`, `end_time`, `items`, `register_time`, `mail_type`, `send_type`, `to_uids`, `create_time`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)", m.Title, m.Content, m.TitleEn, m.ContentEn, m.StartTime, m.EndTime, m.Items, m.RegisterTime, m.MailType, m.SendType, m.ToUids, m.CreateTime)
if err != nil {
return fmt.Errorf("failed to insert mail: %v", err)
}

Binary file not shown.

View File

@ -0,0 +1,181 @@
{
"schema": "2.0",
"config": {
"update_multi": true,
"style": {
"text_size": {
"normal_v2": {
"default": "normal",
"pc": "normal",
"mobile": "heading"
}
}
}
},
"body": {
"direction": "vertical",
"padding": "12px",
"elements": [
{
"tag": "column_set",
"horizontal_spacing": "8px",
"horizontal_align": "left",
"columns": [
{
"tag": "column",
"width": "weighted",
"elements": [
{
"tag": "markdown",
"content": "<font color=\"grey\">设备信息</font>\n**{{.DeviceModel}}**",
"text_align": "left",
"text_size": "normal_v2",
"margin": "0px"
}
],
"vertical_spacing": "8px",
"horizontal_align": "left",
"vertical_align": "top",
"weight": 1
},
{
"tag": "column",
"width": "weighted",
"elements": [
{
"tag": "markdown",
"content": "<font color=\"grey\">操作系统</font>\n**{{.OperatingSystem}}**",
"text_align": "left",
"text_size": "normal_v2",
"margin": "0px"
}
],
"vertical_spacing": "8px",
"horizontal_align": "left",
"vertical_align": "top",
"weight": 1
}
],
"margin": "0px"
},
{
"tag": "column_set",
"horizontal_spacing": "8px",
"horizontal_align": "left",
"columns": [
{
"tag": "column",
"width": "weighted",
"elements": [
{
"tag": "markdown",
"content": "<font color=\"grey\">设备号</font>\n**{{.DeviceUniqueIdentifier}}**",
"text_align": "left",
"text_size": "normal_v2",
"margin": "0px"
}
],
"vertical_spacing": "8px",
"horizontal_align": "left",
"vertical_align": "top",
"weight": 1
},
{
"tag": "column",
"width": "weighted",
"elements": [
{
"tag": "markdown",
"content": "<font color=\"grey\">告警时间</font>\n**{{.AlarmTime}}**",
"text_align": "left",
"text_size": "normal_v2",
"margin": "0px"
}
],
"vertical_spacing": "8px",
"horizontal_align": "left",
"vertical_align": "top",
"weight": 1
}
],
"margin": "0px"
},
{
"tag": "markdown",
"content": "<font color=\"grey\">报错信息</font>\n**{{.Log}}**",
"text_align": "left",
"text_size": "normal_v2",
"margin": "0px"
},
{
"tag": "markdown",
"content": "<font color=\"grey\">报错堆栈</font>\n**{{.StackTrace}}**",
"text_align": "left",
"text_size": "normal_v2",
"margin": "0px"
},
{
"tag": "hr",
"margin": "0px"
},
{
"tag": "column_set",
"horizontal_spacing": "8px",
"horizontal_align": "left",
"columns": [
{
"tag": "column",
"width": "weighted",
"elements": [
{
"tag": "markdown",
"content": "<font color=\"grey\">情况说明</font>\n**{{.Info}}**",
"text_align": "left",
"text_size": "normal_v2",
"margin": "0px"
}
],
"vertical_spacing": "8px",
"horizontal_align": "left",
"vertical_align": "top",
"weight": 1
},
{
"tag": "column",
"width": "weighted",
"elements": [
{
"tag": "markdown",
"content": "<font color=\"grey\">处理人</font>\n<at id='{{.Id}}'></at>",
"text_align": "left",
"text_size": "normal_v2",
"margin": "0px"
}
],
"vertical_spacing": "8px",
"horizontal_align": "left",
"vertical_align": "top",
"weight": 1
}
],
"margin": "0px"
}
]
},
"header": {
"title": {
"tag": "plain_text",
"content": "[已处理] 告警通知Client"
},
"subtitle": {
"tag": "plain_text",
"content": ""
},
"template": "green",
"icon": {
"tag": "standard_icon",
"token": "succeed-hollow_filled"
},
"padding": "12px"
}
}

View File

@ -10,14 +10,15 @@ import (
)
func TestXxx1(t *testing.T) {
d := Type.NotifyData{
Host: "Zabbix tencent-test",
AlarmTime: "2025-03-06 19:12:56",
Severity: "High",
EventName: "游戏进程down-test-node-1",
NotifyMsg: "服务器出错请及时处理",
d := Type.NotifyClientData{
Log: "测试",
DeviceModel: "测试",
StackTrace: "测试",
OperatingSystem: "测试",
DeviceUniqueIdentifier: "测试",
AlarmTime: "测试",
}
feishu.SendNotifyMsg(&d)
feishu.SendNotifyClientMsg(&d)
}
func TestXxx(t *testing.T) {
controller.FeishuSendInfo(nil)