添加根据shell的id删除,添加管理员人员删除

This commit is contained in:
junleea 2025-06-06 14:19:52 +08:00
parent cf404a97b9
commit ef1b2771cd
2 changed files with 20 additions and 0 deletions

View File

@ -114,3 +114,19 @@ func DeleteShellByID(id, authId uint) bool {
} }
return true return true
} }
func DeleteShellByIDV2(id uint) bool {
var db2 *gorm.DB
if proto.Config.SERVER_SQL_LOG {
db2 = DB
} else {
db2 = DB.Debug()
}
result := db2.Where("id = ? ", id).Delete(&Shell{})
if result.Error != nil {
log.Printf("DeleteShellByID failed: %v", result.Error)
return false
}
return true
}

View File

@ -21,6 +21,10 @@ func FindShellByAuthID(id int) []dao.Shell {
} }
func DeleteShellByID(id, authId uint) bool { func DeleteShellByID(id, authId uint) bool {
user := GetUserByIDFromUserCenter(int(authId))
if user.Role == "admin" {
return dao.DeleteShellByIDV2(id)
}
return dao.DeleteShellByID(id, authId) return dao.DeleteShellByID(id, authId)
} }