Commit 0efa5942 authored by 陈子龙's avatar 陈子龙

Merge branch 'dev-czl' into dev

parents 0301cb6e bb51ed47
...@@ -4,7 +4,6 @@ type AddHostManageReq struct { ...@@ -4,7 +4,6 @@ type AddHostManageReq struct {
HostName string `json:"host_name" binding:"required"` // 主机分组名称 HostName string `json:"host_name" binding:"required"` // 主机分组名称
HostFileUrl string `json:"host_file_url"` // 主机文件url HostFileUrl string `json:"host_file_url"` // 主机文件url
Uuid string `json:"uuid"` //临时缓存uuid Uuid string `json:"uuid"` //临时缓存uuid
//HostManageList []HostManageList `json:"host_manage_list"` //主机列表
} }
type HostManageList struct { type HostManageList struct {
...@@ -20,11 +19,10 @@ type EditHostManageReq struct { ...@@ -20,11 +19,10 @@ type EditHostManageReq struct {
Id int `json:"id" binding:"required"` // 主键ID Id int `json:"id" binding:"required"` // 主键ID
HostFileUrl string `json:"host_file_url"` // 主机文件url HostFileUrl string `json:"host_file_url"` // 主机文件url
Uuid string `json:"uuid"` //临时缓存uuid Uuid string `json:"uuid"` //临时缓存uuid
//HostManageList []HostManageList `json:"host_manage_list"` //主机列表
} }
type DelHostManageReq struct { type DelHostManageReq struct {
Id []int `json:"id" vd:"len($)>0;msg:'请输入id'"` // 主键ID Id []int `json:"id" binding:"required"` // 主键ID
} }
type ListHostManageReq struct { type ListHostManageReq struct {
......
package request package request
type AddTaskManageReq struct { type AddTaskManageReq struct {
TaskName string `json:"task_name" vd:"len($)>0;msg:'请输入任务名称'"` // 任务名称 TaskName string `json:"task_name" binding:"required"` // 任务名称
TaskDesc string `json:"task_desc"` // 任务描述 TaskDesc string `json:"task_desc"` // 任务描述
YamlDesc string `json:"yaml_desc"` // yaml内容 YamlDesc string `json:"yaml_desc"` // yaml内容
YamlUrl string `json:"yaml_url"` // yaml文件url YamlUrl string `json:"yaml_url"` // yaml文件url
HostGroupId int `json:"host_group_id" vd:"$>0;msg:'请选择主机分组'"` // 主机分组ID HostGroupId int `json:"host_group_id" binding:"required"` // 主机分组ID
} }
type EditTaskManageReq struct { type EditTaskManageReq struct {
Id int `json:"id" vd:"$>0;msg:'请输入id'"` // 主键ID Id int `json:"id" binding:"required"` // 主键ID
TaskDesc string `json:"task_desc"` // 任务描述 TaskDesc string `json:"task_desc"` // 任务描述
YamlDesc string `json:"yaml_desc"` // yaml内容 YamlDesc string `json:"yaml_desc"` // yaml内容
YamlUrl string `json:"yaml_url"` // yaml文件url YamlUrl string `json:"yaml_url"` // yaml文件url
HostGroupId int `json:"host_group_id" vd:"$>0;msg:'请选择主机分组'"` // 主机分组ID HostGroupId int `json:"host_group_id" binding:"required"` // 主机分组ID
} }
type DelTaskManageReq struct { type DelTaskManageReq struct {
Id []int `json:"id" vd:"len($)>0;msg:'请输入id'"` // 主键ID Id []int `json:"id" binding:"required"` // 主键ID
}
type DetailsTaskManageReq struct {
Id int `json:"id" vd:"$>0;msg:'请输入id'"` // 主键ID
} }
type ListTaskManageReq struct { type ListTaskManageReq struct {
...@@ -33,10 +29,7 @@ type ListTaskManageReq struct { ...@@ -33,10 +29,7 @@ type ListTaskManageReq struct {
} }
type ExecScriptReq struct { type ExecScriptReq struct {
TaskId int `form:"task_id" binding:"required"` //任务id TaskId int `form:"task_id" binding:"required"` //任务id
//HostGroupId int `form:"host_group_id" binding:"required"` //主机分组id Type int `form:"type"` //脚本额外变量类型1yaml 2json
Type int `form:"type"` //脚本额外变量类型1yaml 2json Value string `form:"value"` //脚本额外变量值
Value string `form:"value"` //脚本额外变量值
//Script string `form:"script"` //执行脚本
//YmlFileName string `form:"yml_file_name"` //执行脚本url
} }
...@@ -10,53 +10,8 @@ import ( ...@@ -10,53 +10,8 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/router/middleware/header" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/router/middleware/header"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/service" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/service"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
) )
// ParsingHostFiles 解析主机文件
func ParsingHostFiles(c *gin.Context) (hostManageList []request.HostManageList, err error) {
//获取文件流
metaData, _, err := c.Request.FormFile("host_file")
if err != nil {
err = resp.GetFileStreamError.WithError(err)
return
}
xlsxData, err := excelize.OpenReader(metaData)
if err != nil {
err = resp.ReadFileError.WithError(err)
return
}
//读取工作簿
rows := xlsxData.GetRows("Sheet1")
if len(rows) > 1001 {
err = resp.FailedToParseFile.WithError(errors.New("ip数量不可超过1000"))
return
}
for i := 0; i < len(rows); i++ {
//默认跳过第一行
if i < 1 {
continue
}
var voucherType int
if rows[i][2] == "密码验证" {
voucherType = 0
} else {
voucherType = 1
}
hostManageList = append(hostManageList, request.HostManageList{
Ip: rows[i][0],
Port: rows[i][1],
VoucherType: voucherType,
UserName: rows[i][3],
Password: rows[i][4],
})
}
return
}
// GetMinioFiles 解析minio中xlsx类型文件 // GetMinioFiles 解析minio中xlsx类型文件
func GetMinioFiles(fileName string) (hostManageList []request.HostManageList, err error) { func GetMinioFiles(fileName string) (hostManageList []request.HostManageList, err error) {
...@@ -110,7 +65,7 @@ func AddHostManage(c *gin.Context) { ...@@ -110,7 +65,7 @@ func AddHostManage(c *gin.Context) {
err error err error
) )
if err = c.ShouldBindJSON(&req); err != nil { if err = c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -119,20 +74,6 @@ func AddHostManage(c *gin.Context) { ...@@ -119,20 +74,6 @@ func AddHostManage(c *gin.Context) {
SendJsonResponse(c, resp.InvalidParam.WithError(errors.New("主机分组名称为空")), nil) SendJsonResponse(c, resp.InvalidParam.WithError(errors.New("主机分组名称为空")), nil)
return return
} }
//if len(req.HostManageList) == 0 {
// SendJsonResponse(c, resp.InvalidParam.WithError(errors.New("主机分组数量为0")), nil)
// return
//}
//for _, v := range req.HostManageList {
// if v.Ip == "" || v.UserName == "" {
// SendJsonResponse(c, resp.InvalidParam.WithError(errors.New("ip或用户名为空")), nil)
// return
// }
// if v.VoucherType == 0 && v.Password == "" {
// SendJsonResponse(c, resp.InvalidParam.WithError(errors.New("密码为空")), nil)
// return
// }
//}
hostManageSvc := service.HostManageSvc{User: header.GetUser(c)} hostManageSvc := service.HostManageSvc{User: header.GetUser(c)}
err = hostManageSvc.AddHostManage(req) err = hostManageSvc.AddHostManage(req)
...@@ -150,26 +91,10 @@ func EditHostManage(c *gin.Context) { ...@@ -150,26 +91,10 @@ func EditHostManage(c *gin.Context) {
err error err error
) )
if err = c.ShouldBind(&req); err != nil { if err = c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
//参数校验
//if len(req.HostManageList) == 0 {
// SendJsonResponse(c, resp.InvalidParam.WithError(errors.New("主机分组数量为0")), nil)
// return
//}
//for _, v := range req.HostManageList {
// if v.Ip == "" || v.UserName == "" {
// SendJsonResponse(c, resp.InvalidParam.WithError(errors.New("ip或用户名为空")), nil)
// return
// }
// if v.VoucherType == 0 && v.Password == "" {
// SendJsonResponse(c, resp.InvalidParam.WithError(errors.New("密码为空")), nil)
// return
// }
//}
hostManageSvc := service.HostManageSvc{User: header.GetUser(c)} hostManageSvc := service.HostManageSvc{User: header.GetUser(c)}
err = hostManageSvc.EditHostManage(req) err = hostManageSvc.EditHostManage(req)
if err != nil { if err != nil {
...@@ -183,12 +108,7 @@ func EditHostManage(c *gin.Context) { ...@@ -183,12 +108,7 @@ func EditHostManage(c *gin.Context) {
func DelHostManage(c *gin.Context) { func DelHostManage(c *gin.Context) {
var req request.DelHostManageReq var req request.DelHostManageReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return
}
//参数校验
if err := util.ValidateSimple(req, "Id"); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil)
return return
} }
...@@ -229,7 +149,7 @@ func DetailsHostManage(c *gin.Context) { ...@@ -229,7 +149,7 @@ func DetailsHostManage(c *gin.Context) {
func PageListHostManage(c *gin.Context) { func PageListHostManage(c *gin.Context) {
var req request.ListHostManageReq var req request.ListHostManageReq
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -249,7 +169,7 @@ func StateHostManage(c *gin.Context) { ...@@ -249,7 +169,7 @@ func StateHostManage(c *gin.Context) {
err error err error
) )
if err = c.ShouldBind(&req); err != nil { if err = c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -283,9 +203,7 @@ func StateHostManage(c *gin.Context) { ...@@ -283,9 +203,7 @@ func StateHostManage(c *gin.Context) {
} }
case 3: case 3:
//解析主机文件 //解析主机文件
//hostManageList, err = ParsingHostFiles(c)
hostManageList, err = GetMinioFiles(req.FileName) hostManageList, err = GetMinioFiles(req.FileName)
if err != nil { if err != nil {
SendJsonResponse(c, resp.ReadFileError.WithError(errors.New("解析主机文件失败")), nil) SendJsonResponse(c, resp.ReadFileError.WithError(errors.New("解析主机文件失败")), nil)
return return
...@@ -325,7 +243,7 @@ func StateHostManage(c *gin.Context) { ...@@ -325,7 +243,7 @@ func StateHostManage(c *gin.Context) {
func HostIpExceptionList(c *gin.Context) { func HostIpExceptionList(c *gin.Context) {
var req request.HostIpExceptionListReq var req request.HostIpExceptionListReq
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -361,7 +279,7 @@ func HostIpExceptionList(c *gin.Context) { ...@@ -361,7 +279,7 @@ func HostIpExceptionList(c *gin.Context) {
} }
} }
// 导出 // ExportIp 导出
func ExportIp(c *gin.Context) { func ExportIp(c *gin.Context) {
detectionType := c.Query("detection_type") detectionType := c.Query("detection_type")
id := c.Query("id") id := c.Query("id")
......
...@@ -13,7 +13,7 @@ import ( ...@@ -13,7 +13,7 @@ import (
func TaskHistoryList(c *gin.Context) { func TaskHistoryList(c *gin.Context) {
var req request.TaskHistoryReq var req request.TaskHistoryReq
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -30,7 +30,7 @@ func TaskHistoryList(c *gin.Context) { ...@@ -30,7 +30,7 @@ func TaskHistoryList(c *gin.Context) {
func TaskInfoList(c *gin.Context) { func TaskInfoList(c *gin.Context) {
var req request.TaskInfoListReq var req request.TaskInfoListReq
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
......
...@@ -14,7 +14,6 @@ import ( ...@@ -14,7 +14,6 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/router/middleware/header" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/router/middleware/header"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/service" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/service"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
"io" "io"
"strings" "strings"
) )
...@@ -23,12 +22,7 @@ import ( ...@@ -23,12 +22,7 @@ import (
func AddTaskManage(c *gin.Context) { func AddTaskManage(c *gin.Context) {
var req request.AddTaskManageReq var req request.AddTaskManageReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return
}
//参数校验
if err := util.ValidateSimple(req, "TaskName,HostGroupId"); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil)
return return
} }
...@@ -45,12 +39,7 @@ func AddTaskManage(c *gin.Context) { ...@@ -45,12 +39,7 @@ func AddTaskManage(c *gin.Context) {
func EditTaskManage(c *gin.Context) { func EditTaskManage(c *gin.Context) {
var req request.EditTaskManageReq var req request.EditTaskManageReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return
}
//参数校验
if err := util.ValidateSimple(req, "Id,HostGroupId"); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil)
return return
} }
...@@ -67,12 +56,7 @@ func EditTaskManage(c *gin.Context) { ...@@ -67,12 +56,7 @@ func EditTaskManage(c *gin.Context) {
func DelTaskManage(c *gin.Context) { func DelTaskManage(c *gin.Context) {
var req request.DelTaskManageReq var req request.DelTaskManageReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return
}
//参数校验
if err := util.ValidateSimple(req, "Id"); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil)
return return
} }
...@@ -113,7 +97,7 @@ func DetailsTaskManage(c *gin.Context) { ...@@ -113,7 +97,7 @@ func DetailsTaskManage(c *gin.Context) {
func ListTaskManage(c *gin.Context) { func ListTaskManage(c *gin.Context) {
var req request.ListTaskManageReq var req request.ListTaskManageReq
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -132,7 +116,7 @@ func ExecScript(c *gin.Context) { ...@@ -132,7 +116,7 @@ func ExecScript(c *gin.Context) {
err error err error
) )
if err = c.ShouldBind(&req); err != nil { if err = c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
......
...@@ -15,7 +15,7 @@ import ( ...@@ -15,7 +15,7 @@ import (
func AddWorkOrderManage(c *gin.Context) { func AddWorkOrderManage(c *gin.Context) {
var req request.AddWorkOrderReq var req request.AddWorkOrderReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -32,7 +32,7 @@ func AddWorkOrderManage(c *gin.Context) { ...@@ -32,7 +32,7 @@ func AddWorkOrderManage(c *gin.Context) {
func EditWorkOrderManage(c *gin.Context) { func EditWorkOrderManage(c *gin.Context) {
var req request.EditWorkOrderReq var req request.EditWorkOrderReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
//参数校验 //参数校验
...@@ -54,7 +54,7 @@ func EditWorkOrderManage(c *gin.Context) { ...@@ -54,7 +54,7 @@ func EditWorkOrderManage(c *gin.Context) {
func StateWorkOrderManage(c *gin.Context) { func StateWorkOrderManage(c *gin.Context) {
var req request.StateWorkOrderReq var req request.StateWorkOrderReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
//参数校验 //参数校验
...@@ -76,7 +76,7 @@ func StateWorkOrderManage(c *gin.Context) { ...@@ -76,7 +76,7 @@ func StateWorkOrderManage(c *gin.Context) {
func DelWorkOrderManage(c *gin.Context) { func DelWorkOrderManage(c *gin.Context) {
var req request.DelWorkOrderReq var req request.DelWorkOrderReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
//参数校验 //参数校验
...@@ -122,7 +122,7 @@ func DetailsWorkOrderManage(c *gin.Context) { ...@@ -122,7 +122,7 @@ func DetailsWorkOrderManage(c *gin.Context) {
func ListWorkOrderManage(c *gin.Context) { func ListWorkOrderManage(c *gin.Context) {
var req request.ListWorkOrderManageReq var req request.ListWorkOrderManageReq
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -139,7 +139,7 @@ func ListWorkOrderManage(c *gin.Context) { ...@@ -139,7 +139,7 @@ func ListWorkOrderManage(c *gin.Context) {
func PushWorkOrderManage(c *gin.Context) { func PushWorkOrderManage(c *gin.Context) {
var req request.PushWorkOrderReq var req request.PushWorkOrderReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -156,7 +156,7 @@ func PushWorkOrderManage(c *gin.Context) { ...@@ -156,7 +156,7 @@ func PushWorkOrderManage(c *gin.Context) {
func CloseWorkOrderIssuance(c *gin.Context) { func CloseWorkOrderIssuance(c *gin.Context) {
var req request.CloseWorkOrderReq var req request.CloseWorkOrderReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -173,7 +173,7 @@ func CloseWorkOrderIssuance(c *gin.Context) { ...@@ -173,7 +173,7 @@ func CloseWorkOrderIssuance(c *gin.Context) {
func ListWorkOrderIssuance(c *gin.Context) { func ListWorkOrderIssuance(c *gin.Context) {
var req request.ListWorkOrderReq var req request.ListWorkOrderReq
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -214,7 +214,7 @@ func DetailsWorkOrderIssuance(c *gin.Context) { ...@@ -214,7 +214,7 @@ func DetailsWorkOrderIssuance(c *gin.Context) {
func FeedbackWorkOrderMe(c *gin.Context) { func FeedbackWorkOrderMe(c *gin.Context) {
var req request.FeedbackWorkOrderReq var req request.FeedbackWorkOrderReq
if err := c.ShouldBindJSON(&req); err != nil { if err := c.ShouldBindJSON(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -231,7 +231,7 @@ func FeedbackWorkOrderMe(c *gin.Context) { ...@@ -231,7 +231,7 @@ func FeedbackWorkOrderMe(c *gin.Context) {
func ListWorkOrderMe(c *gin.Context) { func ListWorkOrderMe(c *gin.Context) {
var req request.ListWorkOrderReq var req request.ListWorkOrderReq
if err := c.ShouldBind(&req); err != nil { if err := c.ShouldBind(&req); err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), nil) SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil)
return return
} }
...@@ -244,7 +244,7 @@ func ListWorkOrderMe(c *gin.Context) { ...@@ -244,7 +244,7 @@ func ListWorkOrderMe(c *gin.Context) {
SendJsonPageResponse(c, resp.OK, list, total) SendJsonPageResponse(c, resp.OK, list, total)
} }
// WorkOrderPushNoteMsg 我的业务工单列表 // WorkOrderPushNoteMsg 推送短信
func WorkOrderPushNoteMsg(c *gin.Context) { func WorkOrderPushNoteMsg(c *gin.Context) {
phone := c.Query("phone") phone := c.Query("phone")
......
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
func InitWorkOrderRouter(e *gin.Engine) { func InitWorkOrderRouter(e *gin.Engine) {
so := e.Group(fmt.Sprintf("%s/work_order", conf.Options.Prefix)) so := e.Group(fmt.Sprintf("%s/work_order", conf.Options.Prefix))
//预警工单管理 //预警工单管理
alert := so.Group("/alert") alert := so.Group("/alert", header.SetContext)
{ {
alert.GET("", controller.DetailAlertList) // 详情 alert.GET("", controller.DetailAlertList) // 详情
alert.GET("/list", controller.ListAlertList) // 列表 alert.GET("/list", controller.ListAlertList) // 列表
......
...@@ -381,7 +381,7 @@ func (h *HostManageSvc) PageListHostManage(req request.ListHostManageReq) (total ...@@ -381,7 +381,7 @@ func (h *HostManageSvc) PageListHostManage(req request.ListHostManageReq) (total
"task_manage tm WHERE tm.is_delete = 0 AND tm.host_group_id = hm.ID) AS task_cnt,(SELECT COUNT(*) FROM "+ "task_manage tm WHERE tm.is_delete = 0 AND tm.host_group_id = hm.ID) AS task_cnt,(SELECT COUNT(*) FROM "+
"host_manage_list hml WHERE hml.is_delete = 0 AND hml.conn_status = 1 AND hml.host_group_id = hm.ID) AS "+ "host_manage_list hml WHERE hml.is_delete = 0 AND hml.conn_status = 1 AND hml.host_group_id = hm.ID) AS "+
"ip_cnt_err,(SELECT COUNT(*) FROM host_manage_list hml WHERE hml.is_delete = 0 AND hml.host_group_id = hm.ID) AS ip_cnt"). "ip_cnt_err,(SELECT COUNT(*) FROM host_manage_list hml WHERE hml.is_delete = 0 AND hml.host_group_id = hm.ID) AS ip_cnt").
Limit(req.PageSize, (req.Page-1)*req.PageSize).FindAndCount(&hostManageListRes) OrderBy("hm.create_time desc").Limit(req.PageSize, (req.Page-1)*req.PageSize).FindAndCount(&hostManageListRes)
if err != nil { if err != nil {
err = resp.DbSelectError.WithError(err) err = resp.DbSelectError.WithError(err)
return return
......
...@@ -38,7 +38,7 @@ func (t *TaskHistorySvc) TaskHistoryList(req request.TaskHistoryReq) (total int6 ...@@ -38,7 +38,7 @@ func (t *TaskHistorySvc) TaskHistoryList(req request.TaskHistoryReq) (total int6
} }
//查询任务历史 //查询任务历史
total, err = finder.Select("t2.state,t2.task_id,t1.task_name,t2.exec_start_time,t2.exec_end_time,t2.create_user"). total, err = finder.Select("t2.state,t2.task_id,t1.task_name,t2.exec_start_time,t2.exec_end_time,t2.create_user").
Limit(req.PageSize, (req.Page-1)*req.PageSize).FindAndCount(&taskHistoryListRes) OrderBy("t2.exec_start_time desc").Limit(req.PageSize, (req.Page-1)*req.PageSize).FindAndCount(&taskHistoryListRes)
if err != nil { if err != nil {
err = resp.DbSelectError.WithError(err) err = resp.DbSelectError.WithError(err)
return return
......
...@@ -133,11 +133,6 @@ func (t *TaskManageSvc) DetailsTaskManage(id int) (taskManageRes response.TaskMa ...@@ -133,11 +133,6 @@ func (t *TaskManageSvc) DetailsTaskManage(id int) (taskManageRes response.TaskMa
return return
} }
//err = db.Table("host_manage_list").Where("is_delete = 0 AND host_group_id = ?", id).Find(&hostList)
//if err != nil {
// err = resp.DbSelectError.WithError(err)
// return
//}
for _, v := range hostList { for _, v := range hostList {
if v.HostFileUrl != "" { if v.HostFileUrl != "" {
taskManageRes.HostFileUrl = v.HostFileUrl taskManageRes.HostFileUrl = v.HostFileUrl
...@@ -174,7 +169,7 @@ func (t *TaskManageSvc) ListTaskManage(req request.ListTaskManageReq) (total int ...@@ -174,7 +169,7 @@ func (t *TaskManageSvc) ListTaskManage(req request.ListTaskManageReq) (total int
finder.OrderBy("tm.id") finder.OrderBy("tm.id")
//查询任务 //查询任务
total, err = finder.Select("tm.id,tm.task_name,tm.task_desc,(select count(*) from task_history th "+ total, err = finder.Select("tm.id,tm.task_name,tm.task_desc,(select count(*) from task_history th "+
"where th.task_id = tm.id) as exec_cnt,tm.create_user,tm.create_time"). "where th.task_id = tm.id) as exec_cnt,tm.create_user,tm.create_time").OrderBy("tm.create_time desc").
Limit(req.PageSize, (req.Page-1)*req.PageSize).FindAndCount(&taskManageListRes) Limit(req.PageSize, (req.Page-1)*req.PageSize).FindAndCount(&taskManageListRes)
if err != nil { if err != nil {
err = resp.DbSelectError.WithError(err) err = resp.DbSelectError.WithError(err)
...@@ -245,7 +240,6 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq, script string) (id ...@@ -245,7 +240,6 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq, script string) (id
} }
defer hostsGroup.Close() defer hostsGroup.Close()
//_, err = hostsGroup.Write([]byte(hostsIp))
_, err = hostsGroup.Write([]byte(strings.Join(hosts, "\n"))) _, err = hostsGroup.Write([]byte(strings.Join(hosts, "\n")))
if err != nil { if err != nil {
err = resp.FileExecError.WithError(err) err = resp.FileExecError.WithError(err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment