feat: 添加资产 alias 和 groupId 字段支持
This commit is contained in:
@@ -28,6 +28,8 @@ type Asset struct {
|
||||
Encrypted bool `json:"encrypted"`
|
||||
AccessGatewayId string `gorm:"type:varchar(36)" json:"accessGatewayId"`
|
||||
Sort int `json:"sort" gorm:"default:0"`
|
||||
Alias string `gorm:"type:varchar(200)" json:"alias"`
|
||||
GroupId string `gorm:"index,type:varchar(36)" json:"groupId"`
|
||||
}
|
||||
|
||||
type AssetForPage struct {
|
||||
@@ -45,6 +47,9 @@ type AssetForPage struct {
|
||||
Owner string `json:"owner"`
|
||||
OwnerName string `json:"ownerName"`
|
||||
Sort int `json:"sort"`
|
||||
Alias string `json:"alias"`
|
||||
GroupId string `json:"groupId"`
|
||||
GroupFullName string `json:"groupFullName"`
|
||||
}
|
||||
|
||||
func (r *Asset) TableName() string {
|
||||
|
||||
@@ -45,7 +45,7 @@ func (r assetRepository) FindByProtocolAndIds(c context.Context, protocol string
|
||||
}
|
||||
|
||||
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.last_access_time,assets.tags,assets.description,assets.sort, 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.last_access_time,assets.tags,assets.description,assets.sort,assets.alias,assets.group_id, users.nickname as owner_name, asset_groups.name as group_full_name").Joins("left join users on assets.owner = users.id").Joins("left join asset_groups on assets.group_id = asset_groups.id")
|
||||
dbCounter := r.GetDB(c).Table("assets")
|
||||
|
||||
if len(name) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user