code refactor

This commit is contained in:
Ulric Qin 2021-01-03 18:13:48 +08:00
parent 3589c7de69
commit e82f560c44
1 changed files with 8 additions and 5 deletions

View File

@ -113,11 +113,7 @@ type hostTenantForm struct {
Tenant string `json:"tenant"` Tenant string `json:"tenant"`
} }
// 管理员修改主机设备的租户,相当于分配设备 func (f *hostTenantForm) Validate() {
func hostTenantPut(c *gin.Context) {
var f hostTenantForm
bind(c, &f)
if len(f.Ids) == 0 { if len(f.Ids) == 0 {
bomb("ids is empty") bomb("ids is empty")
} }
@ -125,6 +121,13 @@ func hostTenantPut(c *gin.Context) {
if f.Tenant == "" { if f.Tenant == "" {
bomb("tenant is blank") bomb("tenant is blank")
} }
}
// 管理员修改主机设备的租户,相当于分配设备
func hostTenantPut(c *gin.Context) {
var f hostTenantForm
bind(c, &f)
f.Validate()
hosts, err := models.HostByIds(f.Ids) hosts, err := models.HostByIds(f.Ids)
dangerous(err) dangerous(err)