Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
so-operation-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
smart-operation
so-operation-api
Commits
bb51ed47
Commit
bb51ed47
authored
Jul 12, 2023
by
陈子龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
参数验证中文输出
parent
51189fea
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
44 additions
and
157 deletions
+44
-157
src/bean/vo/request/host_manage.go
src/bean/vo/request/host_manage.go
+1
-3
src/bean/vo/request/task_manage.go
src/bean/vo/request/task_manage.go
+14
-21
src/controller/host_manage.go
src/controller/host_manage.go
+7
-89
src/controller/task_history.go
src/controller/task_history.go
+2
-2
src/controller/task_manage.go
src/controller/task_manage.go
+5
-21
src/controller/work_order_manage.go
src/controller/work_order_manage.go
+11
-11
src/router/workorderrouter.go
src/router/workorderrouter.go
+1
-1
src/service/host_manage.go
src/service/host_manage.go
+1
-1
src/service/task_history.go
src/service/task_history.go
+1
-1
src/service/task_manage.go
src/service/task_manage.go
+1
-7
No files found.
src/bean/vo/request/host_manage.go
View file @
bb51ed47
...
...
@@ -4,7 +4,6 @@ type AddHostManageReq struct {
HostName
string
`json:"host_name" binding:"required"`
// 主机分组名称
HostFileUrl
string
`json:"host_file_url"`
// 主机文件url
Uuid
string
`json:"uuid"`
//临时缓存uuid
//HostManageList []HostManageList `json:"host_manage_list"` //主机列表
}
type
HostManageList
struct
{
...
...
@@ -20,11 +19,10 @@ type EditHostManageReq struct {
Id
int
`json:"id" binding:"required"`
// 主键ID
HostFileUrl
string
`json:"host_file_url"`
// 主机文件url
Uuid
string
`json:"uuid"`
//临时缓存uuid
//HostManageList []HostManageList `json:"host_manage_list"` //主机列表
}
type
DelHostManageReq
struct
{
Id
[]
int
`json:"id"
vd:"len($)>0;msg:'请输入id'
"`
// 主键ID
Id
[]
int
`json:"id"
binding:"required
"`
// 主键ID
}
type
ListHostManageReq
struct
{
...
...
src/bean/vo/request/task_manage.go
View file @
bb51ed47
package
request
type
AddTaskManageReq
struct
{
TaskName
string
`json:"task_name"
vd:"len($)>0;msg:'请输入任务名称'"`
// 任务名称
TaskDesc
string
`json:"task_desc"`
// 任务描述
YamlDesc
string
`json:"yaml_desc"`
// yaml内容
YamlUrl
string
`json:"yaml_url"`
// yaml文件url
HostGroupId
int
`json:"host_group_id"
vd:"$>0;msg:'请选择主机分组'"`
// 主机分组ID
TaskName
string
`json:"task_name"
binding:"required"`
// 任务名称
TaskDesc
string
`json:"task_desc"`
// 任务描述
YamlDesc
string
`json:"yaml_desc"`
// yaml内容
YamlUrl
string
`json:"yaml_url"`
// yaml文件url
HostGroupId
int
`json:"host_group_id"
binding:"required"`
// 主机分组ID
}
type
EditTaskManageReq
struct
{
Id
int
`json:"id"
vd:"$>0;msg:'请输入id'"`
// 主键ID
TaskDesc
string
`json:"task_desc"`
// 任务描述
YamlDesc
string
`json:"yaml_desc"`
// yaml内容
YamlUrl
string
`json:"yaml_url"`
// yaml文件url
HostGroupId
int
`json:"host_group_id"
vd:"$>0;msg:'请选择主机分组'
"`
// 主机分组ID
Id
int
`json:"id"
binding:"required"`
// 主键ID
TaskDesc
string
`json:"task_desc"`
// 任务描述
YamlDesc
string
`json:"yaml_desc"`
// yaml内容
YamlUrl
string
`json:"yaml_url"`
// yaml文件url
HostGroupId
int
`json:"host_group_id"
binding:"required
"`
// 主机分组ID
}
type
DelTaskManageReq
struct
{
Id
[]
int
`json:"id" vd:"len($)>0;msg:'请输入id'"`
// 主键ID
}
type
DetailsTaskManageReq
struct
{
Id
int
`json:"id" vd:"$>0;msg:'请输入id'"`
// 主键ID
Id
[]
int
`json:"id" binding:"required"`
// 主键ID
}
type
ListTaskManageReq
struct
{
...
...
@@ -33,10 +29,7 @@ type ListTaskManageReq struct {
}
type
ExecScriptReq
struct
{
TaskId
int
`form:"task_id" binding:"required"`
//任务id
//HostGroupId int `form:"host_group_id" binding:"required"` //主机分组id
Type
int
`form:"type"`
//脚本额外变量类型1yaml 2json
Value
string
`form:"value"`
//脚本额外变量值
//Script string `form:"script"` //执行脚本
//YmlFileName string `form:"yml_file_name"` //执行脚本url
TaskId
int
`form:"task_id" binding:"required"`
//任务id
Type
int
`form:"type"`
//脚本额外变量类型1yaml 2json
Value
string
`form:"value"`
//脚本额外变量值
}
src/controller/host_manage.go
View file @
bb51ed47
...
...
@@ -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/router/middleware/header"
"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类型文件
func
GetMinioFiles
(
fileName
string
)
(
hostManageList
[]
request
.
HostManageList
,
err
error
)
{
...
...
@@ -110,7 +65,7 @@ func AddHostManage(c *gin.Context) {
err
error
)
if
err
=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -119,20 +74,6 @@ func AddHostManage(c *gin.Context) {
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
errors
.
New
(
"主机分组名称为空"
)),
nil
)
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
)}
err
=
hostManageSvc
.
AddHostManage
(
req
)
...
...
@@ -150,26 +91,10 @@ func EditHostManage(c *gin.Context) {
err
error
)
if
err
=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
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
)}
err
=
hostManageSvc
.
EditHostManage
(
req
)
if
err
!=
nil
{
...
...
@@ -183,12 +108,7 @@ func EditHostManage(c *gin.Context) {
func
DelHostManage
(
c
*
gin
.
Context
)
{
var
req
request
.
DelHostManageReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
return
}
//参数校验
if
err
:=
util
.
ValidateSimple
(
req
,
"Id"
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
TranslateError
(
err
),
nil
)
return
}
...
...
@@ -229,7 +149,7 @@ func DetailsHostManage(c *gin.Context) {
func
PageListHostManage
(
c
*
gin
.
Context
)
{
var
req
request
.
ListHostManageReq
if
err
:=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -249,7 +169,7 @@ func StateHostManage(c *gin.Context) {
err
error
)
if
err
=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -283,9 +203,7 @@ func StateHostManage(c *gin.Context) {
}
case
3
:
//解析主机文件
//hostManageList, err = ParsingHostFiles(c)
hostManageList
,
err
=
GetMinioFiles
(
req
.
FileName
)
if
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
ReadFileError
.
WithError
(
errors
.
New
(
"解析主机文件失败"
)),
nil
)
return
...
...
@@ -325,7 +243,7 @@ func StateHostManage(c *gin.Context) {
func
HostIpExceptionList
(
c
*
gin
.
Context
)
{
var
req
request
.
HostIpExceptionListReq
if
err
:=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -361,7 +279,7 @@ func HostIpExceptionList(c *gin.Context) {
}
}
// 导出
//
ExportIp
导出
func
ExportIp
(
c
*
gin
.
Context
)
{
detectionType
:=
c
.
Query
(
"detection_type"
)
id
:=
c
.
Query
(
"id"
)
...
...
src/controller/task_history.go
View file @
bb51ed47
...
...
@@ -13,7 +13,7 @@ import (
func
TaskHistoryList
(
c
*
gin
.
Context
)
{
var
req
request
.
TaskHistoryReq
if
err
:=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -30,7 +30,7 @@ func TaskHistoryList(c *gin.Context) {
func
TaskInfoList
(
c
*
gin
.
Context
)
{
var
req
request
.
TaskInfoListReq
if
err
:=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
src/controller/task_manage.go
View file @
bb51ed47
...
...
@@ -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/router/middleware/header"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/service"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
"io"
"strings"
)
...
...
@@ -23,12 +22,7 @@ import (
func
AddTaskManage
(
c
*
gin
.
Context
)
{
var
req
request
.
AddTaskManageReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
return
}
//参数校验
if
err
:=
util
.
ValidateSimple
(
req
,
"TaskName,HostGroupId"
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
TranslateError
(
err
),
nil
)
return
}
...
...
@@ -45,12 +39,7 @@ func AddTaskManage(c *gin.Context) {
func
EditTaskManage
(
c
*
gin
.
Context
)
{
var
req
request
.
EditTaskManageReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
return
}
//参数校验
if
err
:=
util
.
ValidateSimple
(
req
,
"Id,HostGroupId"
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
TranslateError
(
err
),
nil
)
return
}
...
...
@@ -67,12 +56,7 @@ func EditTaskManage(c *gin.Context) {
func
DelTaskManage
(
c
*
gin
.
Context
)
{
var
req
request
.
DelTaskManageReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
return
}
//参数校验
if
err
:=
util
.
ValidateSimple
(
req
,
"Id"
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
TranslateError
(
err
),
nil
)
return
}
...
...
@@ -113,7 +97,7 @@ func DetailsTaskManage(c *gin.Context) {
func
ListTaskManage
(
c
*
gin
.
Context
)
{
var
req
request
.
ListTaskManageReq
if
err
:=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -132,7 +116,7 @@ func ExecScript(c *gin.Context) {
err
error
)
if
err
=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
src/controller/work_order_manage.go
View file @
bb51ed47
...
...
@@ -15,7 +15,7 @@ import (
func
AddWorkOrderManage
(
c
*
gin
.
Context
)
{
var
req
request
.
AddWorkOrderReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -32,7 +32,7 @@ func AddWorkOrderManage(c *gin.Context) {
func
EditWorkOrderManage
(
c
*
gin
.
Context
)
{
var
req
request
.
EditWorkOrderReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
//参数校验
...
...
@@ -54,7 +54,7 @@ func EditWorkOrderManage(c *gin.Context) {
func
StateWorkOrderManage
(
c
*
gin
.
Context
)
{
var
req
request
.
StateWorkOrderReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
//参数校验
...
...
@@ -76,7 +76,7 @@ func StateWorkOrderManage(c *gin.Context) {
func
DelWorkOrderManage
(
c
*
gin
.
Context
)
{
var
req
request
.
DelWorkOrderReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
//参数校验
...
...
@@ -122,7 +122,7 @@ func DetailsWorkOrderManage(c *gin.Context) {
func
ListWorkOrderManage
(
c
*
gin
.
Context
)
{
var
req
request
.
ListWorkOrderManageReq
if
err
:=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -139,7 +139,7 @@ func ListWorkOrderManage(c *gin.Context) {
func
PushWorkOrderManage
(
c
*
gin
.
Context
)
{
var
req
request
.
PushWorkOrderReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -156,7 +156,7 @@ func PushWorkOrderManage(c *gin.Context) {
func
CloseWorkOrderIssuance
(
c
*
gin
.
Context
)
{
var
req
request
.
CloseWorkOrderReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -173,7 +173,7 @@ func CloseWorkOrderIssuance(c *gin.Context) {
func
ListWorkOrderIssuance
(
c
*
gin
.
Context
)
{
var
req
request
.
ListWorkOrderReq
if
err
:=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -214,7 +214,7 @@ func DetailsWorkOrderIssuance(c *gin.Context) {
func
FeedbackWorkOrderMe
(
c
*
gin
.
Context
)
{
var
req
request
.
FeedbackWorkOrderReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -231,7 +231,7 @@ func FeedbackWorkOrderMe(c *gin.Context) {
func
ListWorkOrderMe
(
c
*
gin
.
Context
)
{
var
req
request
.
ListWorkOrderReq
if
err
:=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
}
...
...
@@ -244,7 +244,7 @@ func ListWorkOrderMe(c *gin.Context) {
SendJsonPageResponse
(
c
,
resp
.
OK
,
list
,
total
)
}
// WorkOrderPushNoteMsg
我的业务工单列表
// WorkOrderPushNoteMsg
推送短信
func
WorkOrderPushNoteMsg
(
c
*
gin
.
Context
)
{
phone
:=
c
.
Query
(
"phone"
)
...
...
src/router/workorderrouter.go
View file @
bb51ed47
...
...
@@ -12,7 +12,7 @@ import (
func
InitWorkOrderRouter
(
e
*
gin
.
Engine
)
{
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
(
"/list"
,
controller
.
ListAlertList
)
// 列表
...
...
src/service/host_manage.go
View file @
bb51ed47
...
...
@@ -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 "
+
"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"
)
.
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
{
err
=
resp
.
DbSelectError
.
WithError
(
err
)
return
...
...
src/service/task_history.go
View file @
bb51ed47
...
...
@@ -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"
)
.
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
{
err
=
resp
.
DbSelectError
.
WithError
(
err
)
return
...
...
src/service/task_manage.go
View file @
bb51ed47
...
...
@@ -133,11 +133,6 @@ func (t *TaskManageSvc) DetailsTaskManage(id int) (taskManageRes response.TaskMa
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
{
if
v
.
HostFileUrl
!=
""
{
taskManageRes
.
HostFileUrl
=
v
.
HostFileUrl
...
...
@@ -174,7 +169,7 @@ func (t *TaskManageSvc) ListTaskManage(req request.ListTaskManageReq) (total int
finder
.
OrderBy
(
"tm.id"
)
//查询任务
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
)
if
err
!=
nil
{
err
=
resp
.
DbSelectError
.
WithError
(
err
)
...
...
@@ -245,7 +240,6 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq, script string) (id
}
defer
hostsGroup
.
Close
()
//_, err = hostsGroup.Write([]byte(hostsIp))
_
,
err
=
hostsGroup
.
Write
([]
byte
(
strings
.
Join
(
hosts
,
"
\n
"
)))
if
err
!=
nil
{
err
=
resp
.
FileExecError
.
WithError
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment