chroe: add send message caller ip
This commit is contained in:
@@ -6,10 +6,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SendTasksLogs struct {
|
type SendTasksLogs struct {
|
||||||
ID int `gorm:"primary_key" json:"id" `
|
ID int `gorm:"primary_key" json:"id" `
|
||||||
TaskID string `json:"task_id" gorm:"type:varchar(12) comment '任务id';default:'';index:task_id"`
|
TaskID string `json:"task_id" gorm:"type:varchar(12) comment '任务id';default:'';index:task_id"`
|
||||||
Log string `json:"log" gorm:"type:text comment '日志';"`
|
Log string `json:"log" gorm:"type:text comment '日志';"`
|
||||||
Status int `json:"status" gorm:"type:int comment '状态';default:0;"`
|
Status int `json:"status" gorm:"type:int comment '状态';default:0;"`
|
||||||
|
CallerIp string `json:"caller_ip" gorm:"type:varchar(256) comment '发送者的ip';default:'';"`
|
||||||
|
|
||||||
CreatedOn util.Time `json:"created_on" gorm:"type:timestamp comment '创建时间';default:current_timestamp;"`
|
CreatedOn util.Time `json:"created_on" gorm:"type:timestamp comment '创建时间';default:current_timestamp;"`
|
||||||
ModifiedOn util.Time `json:"modified_on" gorm:"type:timestamp comment '更新时间';"`
|
ModifiedOn util.Time `json:"modified_on" gorm:"type:timestamp comment '更新时间';"`
|
||||||
@@ -32,6 +33,7 @@ type LogsResult struct {
|
|||||||
ModifiedOn util.Time `json:"modified_on"`
|
ModifiedOn util.Time `json:"modified_on"`
|
||||||
TaskName string `json:"task_name"`
|
TaskName string `json:"task_name"`
|
||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
|
CallerIp string `json:"caller_ip"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSendLogs 获取所有日志记录
|
// GetSendLogs 获取所有日志记录
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ func DoSendMassage(c *gin.Context) {
|
|||||||
Text: req.Text,
|
Text: req.Text,
|
||||||
HTML: req.HTML,
|
HTML: req.HTML,
|
||||||
MarkDown: req.MarkDown,
|
MarkDown: req.MarkDown,
|
||||||
|
CallerIp: c.ClientIP(),
|
||||||
}
|
}
|
||||||
if req.Mode == "sync" {
|
if req.Mode == "sync" {
|
||||||
// 同步发送
|
// 同步发送
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ type SendMessageService struct {
|
|||||||
Text string
|
Text string
|
||||||
HTML string
|
HTML string
|
||||||
MarkDown string
|
MarkDown string
|
||||||
|
CallerIp string
|
||||||
|
|
||||||
Status int
|
Status int
|
||||||
LogOutput []string
|
LogOutput []string
|
||||||
@@ -190,9 +191,10 @@ func (sm *SendMessageService) RecordSendLog() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log := models.SendTasksLogs{
|
log := models.SendTasksLogs{
|
||||||
Log: strings.Join(sm.LogOutput, "\n"),
|
Log: strings.Join(sm.LogOutput, "\n"),
|
||||||
TaskID: sm.TaskID,
|
TaskID: sm.TaskID,
|
||||||
Status: sm.Status,
|
Status: sm.Status,
|
||||||
|
CallerIp: sm.CallerIp,
|
||||||
}
|
}
|
||||||
err := log.Add()
|
err := log.Add()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tooltip enterable placement="top">
|
<el-tooltip enterable placement="top">
|
||||||
<template #content>
|
<template #content>
|
||||||
<div v-html="TransHtml(scope.row.log)"></div>
|
<div v-html="formatLogDisplayHtml(scope)"></div>
|
||||||
</template>
|
</template>
|
||||||
<span class="log-overflow">{{ scope.row.log }}</span>
|
<span class="log-overflow">{{ scope.row.log }}</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<el-table-column label="详情/状态" prop="status" width="120px" fixed="right">
|
<el-table-column label="详情/状态" prop="status" width="120px" fixed="right">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link size="small" style="margin-right: 10px;" type="primary"
|
<el-button link size="small" style="margin-right: 10px;" type="primary"
|
||||||
@click="drawer = true; logText = scope.row.log">日志</el-button>
|
@click="drawer = true; logText = formatLogDisplayHtml(scope)">日志</el-button>
|
||||||
<el-tag v-if="scope.row.status == 0" type="danger">失败</el-tag>
|
<el-tag v-if="scope.row.status == 0" type="danger">失败</el-tag>
|
||||||
<el-tag v-if="scope.row.status == 1" type="success">成功</el-tag>
|
<el-tag v-if="scope.row.status == 1" type="success">成功</el-tag>
|
||||||
</template>
|
</template>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-drawer v-model="drawer" :with-header="false">
|
<el-drawer v-model="drawer" :with-header="false">
|
||||||
<el-text v-html="TransHtml(logText)" size="small"></el-text>
|
<el-text v-html="logText" size="small"></el-text>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
|
|
||||||
<div class="pagination-block">
|
<div class="pagination-block">
|
||||||
@@ -97,6 +97,15 @@ export default {
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatLogDisplayHtml = (scope) => {
|
||||||
|
let log = TransHtml(scope.row.log);
|
||||||
|
log += '<br />\n';
|
||||||
|
if (scope.row.caller_ip) {
|
||||||
|
log += `调用来源IP:${scope.row.caller_ip}`;
|
||||||
|
};
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
const handPageChange = async (pageNum) => {
|
const handPageChange = async (pageNum) => {
|
||||||
state.currPage = pageNum;
|
state.currPage = pageNum;
|
||||||
await queryListData(pageNum, state.pageSize);
|
await queryListData(pageNum, state.pageSize);
|
||||||
@@ -145,7 +154,7 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...toRefs(state), handleDelete, TransHtml, clickFreshSwitch,
|
...toRefs(state), handleDelete, TransHtml, clickFreshSwitch,
|
||||||
rowStyle, handPageChange, filterFunc, copyToClipboard
|
rowStyle, handPageChange, filterFunc, copyToClipboard, formatLogDisplayHtml
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user