- 增加资产列表使用IP端口查询的功能
This commit is contained in:
parent
a52ad2e356
commit
fd8b36dcc2
@ -118,12 +118,13 @@ func (assetApi AssetApi) AssetPagingEndpoint(c echo.Context) error {
|
|||||||
protocol := c.QueryParam("protocol")
|
protocol := c.QueryParam("protocol")
|
||||||
tags := c.QueryParam("tags")
|
tags := c.QueryParam("tags")
|
||||||
ip := c.QueryParam("ip")
|
ip := c.QueryParam("ip")
|
||||||
|
port := c.QueryParam("port")
|
||||||
active := c.QueryParam("active")
|
active := c.QueryParam("active")
|
||||||
|
|
||||||
order := c.QueryParam("order")
|
order := c.QueryParam("order")
|
||||||
field := c.QueryParam("field")
|
field := c.QueryParam("field")
|
||||||
|
|
||||||
items, total, err := repository.AssetRepository.Find(context.Background(), pageIndex, pageSize, name, protocol, tags, ip, active, order, field)
|
items, total, err := repository.AssetRepository.Find(context.Background(), pageIndex, pageSize, name, protocol, tags, ip, port, active, order, field)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func (r assetRepository) FindByProtocolAndIds(c context.Context, protocol string
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r assetRepository) Find(c context.Context, pageIndex, pageSize int, name, protocol, tags, ip, active, order, field string) (o []model.AssetForPage, total int64, err error) {
|
func (r assetRepository) Find(c context.Context, pageIndex, pageSize int, name, protocol, tags, ip, port, active, order, field string) (o []model.AssetForPage, total int64, err error) {
|
||||||
db := r.GetDB(c).Table("assets").Select("assets.id,assets.name,assets.ip,assets.port,assets.protocol,assets.active,assets.active_message,assets.owner,assets.created,assets.tags,assets.description, users.nickname as owner_name").Joins("left join users on assets.owner = users.id")
|
db := r.GetDB(c).Table("assets").Select("assets.id,assets.name,assets.ip,assets.port,assets.protocol,assets.active,assets.active_message,assets.owner,assets.created,assets.tags,assets.description, users.nickname as owner_name").Joins("left join users on assets.owner = users.id")
|
||||||
dbCounter := r.GetDB(c).Table("assets")
|
dbCounter := r.GetDB(c).Table("assets")
|
||||||
|
|
||||||
@ -57,6 +57,11 @@ func (r assetRepository) Find(c context.Context, pageIndex, pageSize int, name,
|
|||||||
dbCounter = dbCounter.Where("assets.ip like ?", "%"+ip+"%")
|
dbCounter = dbCounter.Where("assets.ip like ?", "%"+ip+"%")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(port) > 0 {
|
||||||
|
db = db.Where("assets.port = ?", port)
|
||||||
|
dbCounter = dbCounter.Where("assets.port = ?", ip)
|
||||||
|
}
|
||||||
|
|
||||||
if len(protocol) > 0 {
|
if len(protocol) > 0 {
|
||||||
db = db.Where("assets.protocol = ?", protocol)
|
db = db.Where("assets.protocol = ?", protocol)
|
||||||
dbCounter = dbCounter.Where("assets.protocol = ?", protocol)
|
dbCounter = dbCounter.Where("assets.protocol = ?", protocol)
|
||||||
|
@ -116,7 +116,9 @@ const Asset = () => {
|
|||||||
title: '网络',
|
title: '网络',
|
||||||
dataIndex: 'network',
|
dataIndex: 'network',
|
||||||
key: 'network',
|
key: 'network',
|
||||||
hideInSearch: true,
|
fieldProps: {
|
||||||
|
placeholder: '示例: 127.0.0.1:22'
|
||||||
|
},
|
||||||
render: (text, record) => {
|
render: (text, record) => {
|
||||||
return `${record['ip'] + ':' + record['port']}`;
|
return `${record['ip'] + ':' + record['port']}`;
|
||||||
}
|
}
|
||||||
@ -346,6 +348,15 @@ const Asset = () => {
|
|||||||
order = Object.values(sort)[0];
|
order = Object.values(sort)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let ip, port;
|
||||||
|
if (params.network) {
|
||||||
|
let split = params.network.split(':');
|
||||||
|
if (split.length >= 2) {
|
||||||
|
ip = split[0];
|
||||||
|
port = split[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let queryParams = {
|
let queryParams = {
|
||||||
pageIndex: params.current,
|
pageIndex: params.current,
|
||||||
pageSize: params.pageSize,
|
pageSize: params.pageSize,
|
||||||
@ -354,6 +365,8 @@ const Asset = () => {
|
|||||||
protocol: params.protocol,
|
protocol: params.protocol,
|
||||||
active: params.active,
|
active: params.active,
|
||||||
'tags': params.tags?.join(','),
|
'tags': params.tags?.join(','),
|
||||||
|
ip: ip,
|
||||||
|
port: port,
|
||||||
field: field,
|
field: field,
|
||||||
order: order
|
order: order
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user