Merge branch 'refs/heads/feat-cmd' into release

This commit is contained in:
junleea 2025-03-05 19:21:48 +08:00
commit e6c51f423c
1 changed files with 17 additions and 2 deletions

View File

@ -77,9 +77,24 @@ func UpdateShellByID(id, authId uint, shellName, shellContent string, status int
func FindShellWillRunByServer(server string, uid uint) []Shell { func FindShellWillRunByServer(server string, uid uint) []Shell {
var shells []Shell var shells []Shell
if proto.Config.SERVER_SQL_LOG { if proto.Config.SERVER_SQL_LOG {
DB.Debug().Exec("select * from shells where server = ? and auth_id = ? and status = 0 order by created_at desc limit 100", server, uid).Scan(&shells) result := DB.Debug().Where("server = ? AND auth_id = ? AND status = 0", server, uid).
Order("created_at DESC").
Limit(100).
Find(&shells)
if result.Error != nil {
// 若查询过程中出现错误,输出错误信息
log.Printf("Failed to query shells: %v\n", result.Error)
}
} else { } else {
DB.Exec("select * from shells where server = ? and auth_id = ? and status = 0 order by created_at desc limit 100", server, uid).Scan(&shells) //DB.Exec("select * from shells where server = ? and auth_id = ? and status = 0 order by created_at desc limit 100", server, uid).Scan(&shells)
result := DB.Where("server = ? AND auth_id = ? AND status = 0", server, uid).
Order("created_at DESC").
Limit(100).
Find(&shells)
if result.Error != nil {
// 若查询过程中出现错误,输出错误信息
log.Printf("Failed to query shells: %v\n", result.Error)
}
} }
return shells return shells
} }