添加根据shell的id删除,添加管理员人员删除
This commit is contained in:
parent
cf404a97b9
commit
ef1b2771cd
16
dao/shell.go
16
dao/shell.go
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue