code refactor

This commit is contained in:
Ulric Qin 2020-10-12 18:04:59 +08:00
parent f3962266b4
commit 7f4dd8859e
1 changed files with 8 additions and 2 deletions

View File

@ -245,14 +245,20 @@ func resourceBindNode(c *gin.Context) {
var err error
if f.Field == "uuid" {
ids, err = models.ResourceIdsByUUIDs(f.Items)
dangerous(err)
if len(ids) == 0 {
bomb("resources not found by uuid")
}
} else if f.Field == "ident" {
ids, err = models.ResourceIdsByIdents(f.Items)
dangerous(err)
if len(ids) == 0 {
bomb("resources not found by ident")
}
} else {
bomb("field[%s] not supported", f.Field)
}
dangerous(err)
loginUser(c).CheckPermByNode(node, "rdb_resource_bind")
renderMessage(c, node.Bind(ids))