feat: add deleteAllSessions functionality and update batch delete logic

- Introduced a new API function `deleteAllSessions` to allow deletion of all sessions for a tenant.
- Updated the `BatchManageDialog` component to support a confirmation dialog for deleting all sessions.
- Enhanced the menu component to reflect the new delete all functionality with appropriate confirmation messages.
- Added internationalization support for the new delete all confirmation message in multiple languages.

These changes improve session management by providing users with the ability to delete all sessions at once, enhancing the overall user experience.
This commit is contained in:
wizardchen
2026-03-02 20:58:09 +08:00
committed by lyingbug
parent 5ba42633ba
commit 284d6c623e
11 changed files with 113 additions and 447 deletions
+22 -3
View File
@@ -306,12 +306,13 @@ func (h *Handler) DeleteSession(c *gin.Context) {
// batchDeleteRequest represents the request body for batch deleting sessions
type batchDeleteRequest struct {
IDs []string `json:"ids" binding:"required,min=1"`
IDs []string `json:"ids"`
DeleteAll bool `json:"delete_all"`
}
// BatchDeleteSessions godoc
// @Summary 批量删除会话
// @Description 根据ID列表批量删除对话会话
// @Description 根据ID列表批量删除对话会话,或设置 delete_all=true 删除当前租户的所有会话
// @Tags 会话
// @Accept json
// @Produce json
@@ -327,7 +328,25 @@ func (h *Handler) BatchDeleteSessions(c *gin.Context) {
var req batchDeleteRequest
if err := c.ShouldBindJSON(&req); err != nil {
logger.Errorf(ctx, "Invalid batch delete request: %v", err)
c.Error(errors.NewBadRequestError("invalid request: ids are required"))
c.Error(errors.NewBadRequestError("invalid request"))
return
}
if req.DeleteAll {
if err := h.sessionService.DeleteAllSessions(ctx); err != nil {
logger.ErrorWithFields(ctx, err, nil)
c.Error(errors.NewInternalServerError(err.Error()))
return
}
c.JSON(http.StatusOK, gin.H{
"success": true,
"message": "All sessions deleted successfully",
})
return
}
if len(req.IDs) == 0 {
c.Error(errors.NewBadRequestError("ids are required when delete_all is false"))
return
}