Browse Source

修复orm

kobe6258 1 week ago
parent
commit
c9ff2fc2ea
1 changed files with 3 additions and 4 deletions
  1. 3 4
      models/cloud_disk_resource.go

+ 3 - 4
models/cloud_disk_resource.go

@@ -304,10 +304,10 @@ func toCloudDiskResourceList(items []*CloudDiskResource) (resourceList []*CloudD
 	return
 }
 func GetCloudDiskResourceList(resourceCond string, resourcePars []interface{}) (resourceList []*CloudDiskResourcePageItem, err error) {
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	sql := fmt.Sprintf(`SELECT resource_id , resource_name, resource_suffix, menu_id, size, admin_name, create_time FROM cloud_disk_resource WHERE 1=1 %s `, resourceCond)
 	var ormList []*CloudDiskResource
-	_, err = o.Raw(sql, resourcePars).QueryRows(&ormList)
+	err = global.DEFAULT_DB.Raw(sql, resourcePars).Find(&ormList).Error
 	if err != nil {
 		return
 	}
@@ -320,8 +320,7 @@ func BatchMoveCloudDiskResource(menuId int, resourceIds []int) (err error) {
 	if resourceLens == 0 {
 		return
 	}
-	o := orm.NewOrm()
 	sql := `UPDATE cloud_disk_resource SET menu_id = ?  WHERE resource_id IN (` + utils.GetOrmInReplace(resourceLens) + `)`
-	_, err = o.Raw(sql, menuId, resourceIds).Exec()
+	err = global.DEFAULT_DB.Exec(sql, menuId, resourceIds).Error
 	return
 }