修复删除资源时未删除与用户关系的bug
This commit is contained in:
@ -155,8 +155,8 @@ func UpdateAssetActiveById(active bool, id string) {
|
||||
global.DB.Exec(sql, active, id)
|
||||
}
|
||||
|
||||
func DeleteAssetById(id string) {
|
||||
global.DB.Where("id = ?", id).Delete(&Asset{})
|
||||
func DeleteAssetById(id string) error {
|
||||
return global.DB.Where("id = ?", id).Delete(&Asset{}).Error
|
||||
}
|
||||
|
||||
func CountAsset() (total int64, err error) {
|
||||
|
@ -77,6 +77,6 @@ func UpdateCommandById(o *Command, id string) {
|
||||
global.DB.Updates(o)
|
||||
}
|
||||
|
||||
func DeleteCommandById(id string) {
|
||||
global.DB.Where("id = ?", id).Delete(&Command{})
|
||||
func DeleteCommandById(id string) error {
|
||||
return global.DB.Where("id = ?", id).Delete(&Command{}).Error
|
||||
}
|
||||
|
@ -95,8 +95,8 @@ func UpdateCredentialById(o *Credential, id string) {
|
||||
global.DB.Updates(o)
|
||||
}
|
||||
|
||||
func DeleteCredentialById(id string) {
|
||||
global.DB.Where("id = ?", id).Delete(&Credential{})
|
||||
func DeleteCredentialById(id string) error {
|
||||
return global.DB.Where("id = ?", id).Delete(&Credential{}).Error
|
||||
}
|
||||
|
||||
func CountCredential() (total int64, err error) {
|
||||
|
@ -102,6 +102,10 @@ func DeleteByUserIdAndResourceTypeAndResourceIdIn(userGroupId, userId, resourceT
|
||||
return db.Delete(&ResourceSharer{}).Error
|
||||
}
|
||||
|
||||
func DeleteResourceSharerByResourceId(resourceId string) error {
|
||||
return global.DB.Where("resource_id = ?", resourceId).Delete(&ResourceSharer{}).Error
|
||||
}
|
||||
|
||||
func AddSharerResources(userGroupId, userId, resourceType string, resourceIds []string) error {
|
||||
return global.DB.Transaction(func(tx *gorm.DB) (err error) {
|
||||
|
||||
|
Reference in New Issue
Block a user