新增任务失败邮件提醒
任务异常提醒软件
This commit is contained in:
@@ -285,6 +285,42 @@ func serverListByGroupId(groupId int) []string {
|
||||
return servers
|
||||
}
|
||||
|
||||
type adminInfo struct {
|
||||
Id int
|
||||
Email string
|
||||
Phone string
|
||||
RealName string
|
||||
}
|
||||
|
||||
func AllAdminInfo(adminIds string) []*adminInfo {
|
||||
Filters := make([]interface{}, 0)
|
||||
Filters = append(Filters, "status", 1)
|
||||
//Filters = append(Filters, "id__gt", 1)
|
||||
var notifyUserIds []int
|
||||
if adminIds != "0" && adminIds != "" {
|
||||
notifyUserIdsStr := strings.Split(adminIds, ",")
|
||||
for _, v := range notifyUserIdsStr {
|
||||
i, _ := strconv.Atoi(v)
|
||||
notifyUserIds = append(notifyUserIds, i)
|
||||
}
|
||||
Filters = append(Filters, "id__in", notifyUserIds)
|
||||
}
|
||||
Result, _ := models.AdminGetList(1, 1000, Filters...)
|
||||
|
||||
adminInfos := make([]*adminInfo, 0)
|
||||
for _, v := range Result {
|
||||
ai := adminInfo{
|
||||
Id: v.Id,
|
||||
Email: v.Email,
|
||||
Phone: v.Phone,
|
||||
RealName: v.RealName,
|
||||
}
|
||||
adminInfos = append(adminInfos, &ai)
|
||||
}
|
||||
|
||||
return adminInfos
|
||||
}
|
||||
|
||||
type serverList struct {
|
||||
GroupId int
|
||||
GroupName string
|
||||
|
||||
@@ -46,7 +46,6 @@ func (self *RoleController) Edit() {
|
||||
row["id"] = role.Id
|
||||
row["role_name"] = role.RoleName
|
||||
row["detail"] = role.Detail
|
||||
row["detail"] = role.Detail
|
||||
row["task_group_ids"] = role.TaskGroupIds
|
||||
row["server_group_ids"] = role.ServerGroupIds
|
||||
self.Data["role"] = row
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"fmt"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/george518/PPGo_Job/jobs"
|
||||
"github.com/george518/PPGo_Job/models"
|
||||
@@ -38,6 +39,9 @@ func (self *TaskController) Add() {
|
||||
self.Data["taskGroup"] = taskGroupLists(self.taskGroups, self.userId)
|
||||
self.Data["serverGroup"] = serverLists(self.serverGroups, self.userId)
|
||||
self.Data["isAdmin"] = self.userId
|
||||
self.Data["adminInfo"] = AllAdminInfo("")
|
||||
|
||||
fmt.Println(self.Data["adminInfo"])
|
||||
self.display()
|
||||
}
|
||||
|
||||
@@ -55,15 +59,28 @@ func (self *TaskController) Edit() {
|
||||
}
|
||||
self.Data["task"] = task
|
||||
|
||||
self.Data["adminInfo"] = AllAdminInfo("")
|
||||
|
||||
// 分组列表
|
||||
self.Data["taskGroup"] = taskGroupLists(self.taskGroups, self.userId)
|
||||
self.Data["serverGroup"] = serverLists(self.serverGroups, self.userId)
|
||||
self.Data["isAdmin"] = self.userId
|
||||
var notifyUserIds []int
|
||||
if task.NotifyUserIds != "0" {
|
||||
notifyUserIdsStr := strings.Split(task.NotifyUserIds, ",")
|
||||
for _, v := range notifyUserIdsStr {
|
||||
i, _ := strconv.Atoi(v)
|
||||
notifyUserIds = append(notifyUserIds, i)
|
||||
}
|
||||
}
|
||||
|
||||
self.Data["notify_user_ids"] = notifyUserIds
|
||||
self.display()
|
||||
}
|
||||
|
||||
func (self *TaskController) Copy() {
|
||||
self.Data["pageTitle"] = "复制任务"
|
||||
self.Data["adminInfo"] = AllAdminInfo("")
|
||||
|
||||
id, _ := self.GetInt("id")
|
||||
task, err := models.TaskGetById(id)
|
||||
@@ -75,6 +92,15 @@ func (self *TaskController) Copy() {
|
||||
// 分组列表
|
||||
self.Data["taskGroup"] = taskGroupLists(self.taskGroups, self.userId)
|
||||
self.Data["serverGroup"] = serverLists(self.serverGroups, self.userId)
|
||||
var notifyUserIds []int
|
||||
if task.NotifyUserIds != "0" {
|
||||
notifyUserIdsStr := strings.Split(task.NotifyUserIds, ",")
|
||||
for _, v := range notifyUserIdsStr {
|
||||
i, _ := strconv.Atoi(v)
|
||||
notifyUserIds = append(notifyUserIds, i)
|
||||
}
|
||||
}
|
||||
self.Data["notify_user_ids"] = notifyUserIds
|
||||
self.display()
|
||||
}
|
||||
|
||||
@@ -138,6 +164,13 @@ func (self *TaskController) Detail() {
|
||||
updateName = admin.RealName
|
||||
}
|
||||
}
|
||||
|
||||
//是否出错通知
|
||||
self.Data["adminInfo"] = []int{0}
|
||||
fmt.Println(task.NotifyUserIds)
|
||||
if task.NotifyUserIds != "0" && task.NotifyUserIds != "" {
|
||||
self.Data["adminInfo"] = AllAdminInfo(task.NotifyUserIds)
|
||||
}
|
||||
self.Data["CreateName"] = createName
|
||||
self.Data["UpdateName"] = updateName
|
||||
self.Data["serverName"] = serverName
|
||||
@@ -157,6 +190,9 @@ func (self *TaskController) AjaxSave() {
|
||||
task.CronSpec = strings.TrimSpace(self.GetString("cron_spec"))
|
||||
task.Command = strings.TrimSpace(self.GetString("command"))
|
||||
task.Timeout, _ = self.GetInt("timeout")
|
||||
task.IsNotify, _ = self.GetInt("is_notify")
|
||||
task.NotifyType, _ = self.GetInt("notify_type")
|
||||
task.NotifyUserIds = strings.TrimSpace(self.GetString("notify_user_ids"))
|
||||
|
||||
msg, isBan := checkCommand(task.Command)
|
||||
if !isBan {
|
||||
@@ -194,6 +230,9 @@ func (self *TaskController) AjaxSave() {
|
||||
task.CronSpec = strings.TrimSpace(self.GetString("cron_spec"))
|
||||
task.Command = strings.TrimSpace(self.GetString("command"))
|
||||
task.Timeout, _ = self.GetInt("timeout")
|
||||
task.IsNotify, _ = self.GetInt("is_notify")
|
||||
task.NotifyType, _ = self.GetInt("notify_type")
|
||||
task.NotifyUserIds = strings.TrimSpace(self.GetString("notify_user_ids"))
|
||||
task.UpdateId = self.userId
|
||||
task.Status = 2 //审核中,超级管理员不需要
|
||||
if self.userId == 1 {
|
||||
|
||||
Reference in New Issue
Block a user