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
7f25cae8
Commit
7f25cae8
authored
Jul 04, 2023
by
魏灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
556691ac
88c08d60
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
196 additions
and
7 deletions
+196
-7
src/bean/entity/work_order.go
src/bean/entity/work_order.go
+19
-0
src/bean/vo/request/task_history.go
src/bean/vo/request/task_history.go
+7
-1
src/controller/task_history.go
src/controller/task_history.go
+2
-2
src/controller/work_order_manage.go
src/controller/work_order_manage.go
+114
-0
src/router/router.go
src/router/router.go
+1
-1
src/router/workorderrouter.go
src/router/workorderrouter.go
+45
-0
src/service/task_history.go
src/service/task_history.go
+8
-3
No files found.
src/bean/entity/work_order.go
0 → 100644
View file @
7f25cae8
package
entity
import
"time"
type
WorkOrder
struct
{
Id
int
`json:"id" xorm:"pk autoincr" `
// id
OrderName
string
`json:"order_name" xorm:"order_name"`
// 工单名称
OrderLevel
int
`json:"order_level" xorm:"order_level"`
// 工单等级(1紧急任务 2重要任务 3一般任务)
OrderDesc
string
`json:"order_desc" xorm:"order_desc"`
// 工单描述
OrderCnt
int
`json:"order_cnt" xorm:"order_cnt"`
// 实例工单数
PushObj
string
`json:"push_obj" xorm:"push_obj"`
// 推送对象
TimingType
int
`json:"timing_type" xorm:"timing_type"`
// 定时类型(1手动下发 2按周 3自定义时间)
TimingRule
string
`json:"timing_rule" xorm:"timing_rule"`
// 定时规则
TimingState
int
`json:"timing_state" xorm:"timing_state"`
// 定时状态(0禁用 1启用)
CreateUser
string
`json:"create_user" xorm:"create_user" `
// 创建人
CreateTime
time
.
Time
`json:"create_time" xorm:"create_time" `
// 创建时间
UpdateUser
string
`json:"update_user" xorm:"update_user"`
// 修改人
UpdateTime
time
.
Time
`json:"update_time" xorm:"update_time" `
// 修改时间
}
src/bean/vo/request/task_history.go
View file @
7f25cae8
package
request
package
request
type
TaskHistoryReq
struct
{
type
TaskHistoryReq
struct
{
Search
string
`json:"search" form:"search"`
// 关键词
Pagination
}
type
TaskInfoListReq
struct
{
TaskId
int
`json:"task_id" form:"task_id" binding:"required"`
// 主键ID
TaskId
int
`json:"task_id" form:"task_id" binding:"required"`
// 主键ID
Search
string
`json:"search" form:"search"`
// 关键词
Pagination
Pagination
}
}
src/controller/task_history.go
View file @
7f25cae8
...
@@ -11,7 +11,7 @@ import (
...
@@ -11,7 +11,7 @@ import (
// TaskHistoryList 任务历史列表
// TaskHistoryList 任务历史列表
func
TaskHistoryList
(
c
*
gin
.
Context
)
{
func
TaskHistoryList
(
c
*
gin
.
Context
)
{
var
req
request
.
Pagination
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
.
WithError
(
err
),
nil
)
return
return
...
@@ -28,7 +28,7 @@ func TaskHistoryList(c *gin.Context) {
...
@@ -28,7 +28,7 @@ func TaskHistoryList(c *gin.Context) {
// TaskInfoList 任务历史详情列表
// TaskInfoList 任务历史详情列表
func
TaskInfoList
(
c
*
gin
.
Context
)
{
func
TaskInfoList
(
c
*
gin
.
Context
)
{
var
req
request
.
Task
History
Req
var
req
request
.
Task
InfoList
Req
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
.
WithError
(
err
),
nil
)
return
return
...
...
src/controller/work_order_manage.go
0 → 100644
View file @
7f25cae8
package
controller
import
(
"github.com/gin-gonic/gin"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
)
// AddWorkOrderManage 新增业务工单管理
func
AddWorkOrderManage
(
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)
// return
//}
//
//taskManageSvc := service.TaskManageSvc{}
//err := taskManageSvc.AddTaskManage(req)
//if err != nil {
// SendJsonResponse(c, err, nil)
// return
//}
SendJsonResponse
(
c
,
resp
.
OK
,
nil
)
}
//
//// EditTaskManage 编辑任务
//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)
// return
// }
//
// taskManageSvc := service.TaskManageSvc{}
// err := taskManageSvc.EditTaskManage(req)
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// SendJsonResponse(c, resp.OK, nil)
//}
//
//// DelTaskManage 删除任务
//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)
// return
// }
//
// taskManageSvc := service.TaskManageSvc{}
// err := taskManageSvc.DelTaskManage(req)
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// SendJsonResponse(c, resp.OK, nil)
//}
//
//// DetailsTaskManage 任务详情
//func DetailsTaskManage(c *gin.Context) {
// var (
// err error
// id string
// )
//
// if id = c.Query("id"); id == "" {
// id = c.Param("id")
// }
// if id == "" {
// SendJsonResponse(c, resp.InvalidParam.WithError(errors.New("id为空")), nil)
// return
// }
//
// taskManageSvc := service.TaskManageSvc{}
// data, err := taskManageSvc.DetailsTaskManage(cast.ToInt(id))
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// SendJsonResponse(c, resp.OK, data)
//}
//
//// ListTaskManage 任务列表
//func ListTaskManage(c *gin.Context) {
// var req request.ListTaskManageReq
// if err := c.ShouldBind(&req); err != nil {
// SendJsonResponse(c, resp.InvalidParam.WithError(err), nil)
// return
// }
//
// taskManageSvc := service.TaskManageSvc{}
// total, list, err := taskManageSvc.ListTaskManage(req)
// if err != nil {
// SendJsonPageResponse(c, err, nil, 0)
// return
// }
// SendJsonPageResponse(c, resp.OK, list, total)
//}
src/router/router.go
View file @
7f25cae8
...
@@ -50,5 +50,5 @@ func Load(r *gin.Engine, middleware ...gin.HandlerFunc) {
...
@@ -50,5 +50,5 @@ func Load(r *gin.Engine, middleware ...gin.HandlerFunc) {
// 初始化prometheus路由
// 初始化prometheus路由
InitPrometheusRouter
(
r
)
InitPrometheusRouter
(
r
)
// 初始化工单管理路由
// 初始化工单管理路由
//InitAutomatedMainten
Router(r)
InitWorkOrder
Router
(
r
)
}
}
src/router/workorderrouter.go
0 → 100644
View file @
7f25cae8
package
router
import
(
"fmt"
"github.com/gin-gonic/gin"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/conf"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/controller"
)
// InitWorkOrderRouter 初始化工单路由
func
InitWorkOrderRouter
(
e
*
gin
.
Engine
)
{
so
:=
e
.
Group
(
fmt
.
Sprintf
(
"%s/work_order"
,
conf
.
Options
.
Prefix
))
//业务工单管理
manage
:=
so
.
Group
(
"/work_order_manage"
)
{
manage
.
POST
(
"/add"
,
controller
.
AddWorkOrderManage
)
// 新增
//manage.PUT("/edit", controller.EditTaskManage) // 编辑
//manage.DELETE("/del", controller.DelTaskManage) // 删除
//manage.GET("/details", controller.DetailsTaskManage) // 详情
//manage.GET("/list", controller.ListTaskManage) // 列表
//manage.POST("/exec/script", controller.ExecScript) // 立即执行
}
////任务历史
//taskHistory := so.Group("/task_history")
//{
// taskHistory.GET("/list", controller.TaskHistoryList) // 任务历史列表
// taskHistory.GET("/task_info_list", controller.TaskInfoList) // 任务历史详情列表
// taskHistory.GET("/task_exec_log", controller.TaskExecLog) // 任务执行日志
//}
//
////主机管理
//host := so.Group("/host_manage")
//{
// host.POST("/add", controller.AddHostManage) // 新增
// host.PUT("/edit", controller.EditHostManage) // 编辑
// host.DELETE("/del", controller.DelHostManage) // 删除
// host.GET("/details", controller.DetailsHostManage) // 详情
// host.GET("/page_list", controller.PageListHostManage) // 列表
// host.POST("/state", controller.StateHostManage) // 状态检测
// host.GET("/ip_exception_list", controller.HostIpExceptionList) // 主机ip异常列表
// host.GET("/export", controller.ExportIp) // 导出ip列表
// host.GET("/list", controller.ListHostManage) // 主机分组列表-不分页
//}
}
src/service/task_history.go
View file @
7f25cae8
...
@@ -15,7 +15,7 @@ type TaskHistorySvc struct {
...
@@ -15,7 +15,7 @@ type TaskHistorySvc struct {
}
}
// TaskHistoryList 任务历史列表
// TaskHistoryList 任务历史列表
func
(
t
*
TaskHistorySvc
)
TaskHistoryList
(
req
request
.
Pagination
)
(
total
int64
,
taskHistoryListRes
[]
response
.
TaskHistoryListRes
,
err
error
)
{
func
(
t
*
TaskHistorySvc
)
TaskHistoryList
(
req
request
.
TaskHistoryReq
)
(
total
int64
,
taskHistoryListRes
[]
response
.
TaskHistoryListRes
,
err
error
)
{
var
(
var
(
//dueDate int
//dueDate int
start
time
.
Time
start
time
.
Time
...
@@ -32,6 +32,9 @@ func (t *TaskHistorySvc) TaskHistoryList(req request.Pagination) (total int64, t
...
@@ -32,6 +32,9 @@ func (t *TaskHistorySvc) TaskHistoryList(req request.Pagination) (total int64, t
" WHERE ID IN (SELECT MAX(ID) FROM task_history GROUP BY task_id) ORDER BY ID DESC) t2"
,
"t1.id = t2.task_id"
)
.
" WHERE ID IN (SELECT MAX(ID) FROM task_history GROUP BY task_id) ORDER BY ID DESC) t2"
,
"t1.id = t2.task_id"
)
.
Where
(
"t1.is_delete = 0"
)
Where
(
"t1.is_delete = 0"
)
if
req
.
Search
!=
""
{
finder
.
Where
(
"t1.task_name LIKE ?"
,
"%"
+
req
.
Search
+
"%"
)
}
//查询任务历史
//查询任务历史
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
)
Limit
(
req
.
PageSize
,
(
req
.
Page
-
1
)
*
req
.
PageSize
)
.
FindAndCount
(
&
taskHistoryListRes
)
...
@@ -61,7 +64,7 @@ func (t *TaskHistorySvc) TaskHistoryList(req request.Pagination) (total int64, t
...
@@ -61,7 +64,7 @@ func (t *TaskHistorySvc) TaskHistoryList(req request.Pagination) (total int64, t
}
}
// TaskInfoList 任务历史详情列表
// TaskInfoList 任务历史详情列表
func
(
t
*
TaskHistorySvc
)
TaskInfoList
(
req
request
.
Task
History
Req
)
(
total
int64
,
taskInfoListRes
[]
response
.
TaskInfoListRes
,
err
error
)
{
func
(
t
*
TaskHistorySvc
)
TaskInfoList
(
req
request
.
Task
InfoList
Req
)
(
total
int64
,
taskInfoListRes
[]
response
.
TaskInfoListRes
,
err
error
)
{
var
(
var
(
//dueDate int
//dueDate int
start
time
.
Time
start
time
.
Time
...
@@ -74,7 +77,9 @@ func (t *TaskHistorySvc) TaskInfoList(req request.TaskHistoryReq) (total int64,
...
@@ -74,7 +77,9 @@ func (t *TaskHistorySvc) TaskInfoList(req request.TaskHistoryReq) (total int64,
}
}
finder
:=
db
.
Table
(
"task_history"
)
.
Where
(
"task_id = ?"
,
req
.
TaskId
)
finder
:=
db
.
Table
(
"task_history"
)
.
Where
(
"task_id = ?"
,
req
.
TaskId
)
if
req
.
Search
!=
""
{
finder
.
Where
(
"exec_desc LIKE ?"
,
"%"
+
req
.
Search
+
"%"
)
}
//查询任务历史
//查询任务历史
total
,
err
=
finder
.
OrderBy
(
"id desc"
)
.
Limit
(
req
.
PageSize
,
(
req
.
Page
-
1
)
*
req
.
PageSize
)
.
FindAndCount
(
&
taskInfoListRes
)
total
,
err
=
finder
.
OrderBy
(
"id desc"
)
.
Limit
(
req
.
PageSize
,
(
req
.
Page
-
1
)
*
req
.
PageSize
)
.
FindAndCount
(
&
taskInfoListRes
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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