diff --git a/models/send_tasks_logs.go b/models/send_tasks_logs.go index 8ac7028..31c267a 100644 --- a/models/send_tasks_logs.go +++ b/models/send_tasks_logs.go @@ -6,10 +6,11 @@ import ( ) type SendTasksLogs struct { - ID int `gorm:"primary_key" json:"id" ` - TaskID string `json:"task_id" gorm:"type:varchar(12) comment '任务id';default:'';index:task_id"` - Log string `json:"log" gorm:"type:text comment '日志';"` - Status int `json:"status" gorm:"type:int comment '状态';default:0;"` + ID int `gorm:"primary_key" json:"id" ` + TaskID string `json:"task_id" gorm:"type:varchar(12) comment '任务id';default:'';index:task_id"` + Log string `json:"log" gorm:"type:text comment '日志';"` + 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;"` ModifiedOn util.Time `json:"modified_on" gorm:"type:timestamp comment '更新时间';"` @@ -32,6 +33,7 @@ type LogsResult struct { ModifiedOn util.Time `json:"modified_on"` TaskName string `json:"task_name"` Status int `json:"status"` + CallerIp string `json:"caller_ip"` } // GetSendLogs 获取所有日志记录 diff --git a/routers/api/v1/send_message.go b/routers/api/v1/send_message.go index 1c03408..33e3a33 100644 --- a/routers/api/v1/send_message.go +++ b/routers/api/v1/send_message.go @@ -36,6 +36,7 @@ func DoSendMassage(c *gin.Context) { Text: req.Text, HTML: req.HTML, MarkDown: req.MarkDown, + CallerIp: c.ClientIP(), } if req.Mode == "sync" { // 同步发送 diff --git a/service/send_message_service/send_message.go b/service/send_message_service/send_message.go index b965761..679d673 100644 --- a/service/send_message_service/send_message.go +++ b/service/send_message_service/send_message.go @@ -32,6 +32,7 @@ type SendMessageService struct { Text string HTML string MarkDown string + CallerIp string Status int LogOutput []string @@ -190,9 +191,10 @@ func (sm *SendMessageService) RecordSendLog() { return } log := models.SendTasksLogs{ - Log: strings.Join(sm.LogOutput, "\n"), - TaskID: sm.TaskID, - Status: sm.Status, + Log: strings.Join(sm.LogOutput, "\n"), + TaskID: sm.TaskID, + Status: sm.Status, + CallerIp: sm.CallerIp, } err := log.Add() if err != nil { diff --git a/web/src/views/tabsTools/sendLogs/sendLogs.vue b/web/src/views/tabsTools/sendLogs/sendLogs.vue index c9d6bb6..855d62a 100644 --- a/web/src/views/tabsTools/sendLogs/sendLogs.vue +++ b/web/src/views/tabsTools/sendLogs/sendLogs.vue @@ -22,7 +22,7 @@