Commit 0110717b authored by 陈子龙's avatar 陈子龙

Merge branch 'dev-czl' into dev

parents e913199c b17036ed
...@@ -49,6 +49,11 @@ type HostManagesRes struct { ...@@ -49,6 +49,11 @@ type HostManagesRes struct {
IpCnt int `json:"ip_cnt"` // ip数量(全部) IpCnt int `json:"ip_cnt"` // ip数量(全部)
} }
type HostManagesListRes struct {
Id int `json:"id"` // id
HostName string `json:"host_name"` // 主机分组名称
}
type HostManageListRes struct { type HostManageListRes struct {
Id int `json:"id"` // id Id int `json:"id"` // id
Ip string `json:"ip"` // ip Ip string `json:"ip"` // ip
......
...@@ -179,8 +179,8 @@ func DetailsHostManage(c *gin.Context) { ...@@ -179,8 +179,8 @@ func DetailsHostManage(c *gin.Context) {
SendJsonResponse(c, resp.OK, data) SendJsonResponse(c, resp.OK, data)
} }
// ListHostManage 列表 // PageListHostManage 列表-分页
func ListHostManage(c *gin.Context) { func PageListHostManage(c *gin.Context) {
var req request.ListHostManageReq var req request.ListHostManageReq
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.WithError(err), nil)
...@@ -188,7 +188,7 @@ func ListHostManage(c *gin.Context) { ...@@ -188,7 +188,7 @@ func ListHostManage(c *gin.Context) {
} }
hostManageSvc := service.HostManageSvc{} hostManageSvc := service.HostManageSvc{}
total, list, err := hostManageSvc.ListHostManage(req) total, list, err := hostManageSvc.PageListHostManage(req)
if err != nil { if err != nil {
SendJsonPageResponse(c, err, nil, 0) SendJsonPageResponse(c, err, nil, 0)
return return
...@@ -344,3 +344,15 @@ func ExportIp(c *gin.Context) { ...@@ -344,3 +344,15 @@ func ExportIp(c *gin.Context) {
c.File(conf.Options.TempDirPrefix + fileName) c.File(conf.Options.TempDirPrefix + fileName)
} }
// ListHostManage 列表
func ListHostManage(c *gin.Context) {
hostManageSvc := service.HostManageSvc{}
list, err := hostManageSvc.ListHostManage()
if err != nil {
SendJsonResponse(c, err, nil)
return
}
SendJsonResponse(c, resp.OK, list)
}
...@@ -27,9 +27,10 @@ func InitAutomatedMaintenRouter(e *gin.Engine) { ...@@ -27,9 +27,10 @@ func InitAutomatedMaintenRouter(e *gin.Engine) {
host.PUT("/edit", controller.EditHostManage) // 编辑 host.PUT("/edit", controller.EditHostManage) // 编辑
host.DELETE("/del", controller.DelHostManage) // 删除 host.DELETE("/del", controller.DelHostManage) // 删除
host.GET("/details", controller.DetailsHostManage) // 详情 host.GET("/details", controller.DetailsHostManage) // 详情
host.GET("/list", controller.ListHostManage) // 列表 host.GET("/page_list", controller.PageListHostManage) // 列表-分页
host.POST("/state", controller.StateHostManage) // 状态检测 host.POST("/state", controller.StateHostManage) // 状态检测
host.GET("/ip_exception_list", controller.HostIpExceptionList) // 主机ip异常列表 host.GET("/ip_exception_list", controller.HostIpExceptionList) // 主机ip异常列表
host.GET("/export", controller.ExportIp) // 导出ip列表 host.GET("/export", controller.ExportIp) // 导出ip列表
host.GET("/list", controller.ListHostManage) // 主机分组列表
} }
} }
...@@ -294,8 +294,8 @@ func (h *HostManageSvc) DetailsHostManage(id int) (hostManageRes response.HostMa ...@@ -294,8 +294,8 @@ func (h *HostManageSvc) DetailsHostManage(id int) (hostManageRes response.HostMa
return return
} }
// ListHostManage 列表 // PageListHostManage 列表-分页
func (h *HostManageSvc) ListHostManage(req request.ListHostManageReq) (total int64, hostManageListRes []response.HostManagesRes, err error) { func (h *HostManageSvc) PageListHostManage(req request.ListHostManageReq) (total int64, hostManageListRes []response.HostManagesRes, err error) {
db, err := client.GetDbClient() db, err := client.GetDbClient()
if err != nil { if err != nil {
err = resp.DbConnectError.WithError(err) err = resp.DbConnectError.WithError(err)
...@@ -634,3 +634,23 @@ func generatePushExportXlsx(push []ExportIpStr) (string, error) { ...@@ -634,3 +634,23 @@ func generatePushExportXlsx(push []ExportIpStr) (string, error) {
err := file.Save(conf.Options.TempDirPrefix + saveFileName) err := file.Save(conf.Options.TempDirPrefix + saveFileName)
return saveFileName, err return saveFileName, err
} }
// ListHostManage 列表
func (h *HostManageSvc) ListHostManage() (hostManagesListRes []response.HostManagesListRes, err error) {
db, err := client.GetDbClient()
if err != nil {
err = resp.DbConnectError.WithError(err)
return
}
finder := db.Table("host_manage").Where("is_delete = 0")
finder.OrderBy("id")
//查询任务
err = finder.Select("id,host_name").Find(&hostManagesListRes)
if err != nil {
err = resp.DbSelectError.WithError(err)
return
}
return
}
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