From ef1b2771cdf01916bc5ef02a388326e3ae454383 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Fri, 6 Jun 2025 14:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=B9=E6=8D=AEshell?= =?UTF-8?q?=E7=9A=84id=E5=88=A0=E9=99=A4,=E6=B7=BB=E5=8A=A0=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E4=BA=BA=E5=91=98=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/shell.go | 16 ++++++++++++++++ service/shellService.go | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/dao/shell.go b/dao/shell.go index f83722a..b033a24 100644 --- a/dao/shell.go +++ b/dao/shell.go @@ -114,3 +114,19 @@ func DeleteShellByID(id, authId uint) bool { } 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 +} diff --git a/service/shellService.go b/service/shellService.go index ee38023..430c7dd 100644 --- a/service/shellService.go +++ b/service/shellService.go @@ -21,6 +21,10 @@ func FindShellByAuthID(id int) []dao.Shell { } func DeleteShellByID(id, authId uint) bool { + user := GetUserByIDFromUserCenter(int(authId)) + if user.Role == "admin" { + return dao.DeleteShellByIDV2(id) + } return dao.DeleteShellByID(id, authId) }