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
0efa5942
Commit
0efa5942
authored
Jul 12, 2023
by
陈子龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-czl' into dev
parents
0301cb6e
bb51ed47
Changes
10
Show 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 @
0efa5942
...
@@ -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
{
...
...
src/bean/vo/request/task_manage.go
View file @
0efa5942
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
{
...
@@ -34,9 +30,6 @@ type ListTaskManageReq struct {
...
@@ -34,9 +30,6 @@ 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
}
}
src/controller/host_manage.go
View file @
0efa5942
...
@@ -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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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"
)
...
...
src/controller/task_history.go
View file @
0efa5942
...
@@ -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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
return
}
}
...
...
src/controller/task_manage.go
View file @
0efa5942
...
@@ -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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
err
),
nil
)
return
return
}
}
...
...
src/controller/work_order_manage.go
View file @
0efa5942
...
@@ -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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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
.
With
Error
(
err
),
nil
)
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
Translate
Error
(
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"
)
...
...
src/router/workorderrouter.go
View file @
0efa5942
...
@@ -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
)
// 列表
...
...
src/service/host_manage.go
View file @
0efa5942
...
@@ -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
...
...
src/service/task_history.go
View file @
0efa5942
...
@@ -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
...
...
src/service/task_manage.go
View file @
0efa5942
...
@@ -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
)
...
...
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