feat(handlers): implement consolidated user profile endpoints

Implement DeleteUser, ResetUserPassword, and UpdateUserAdmin handlers.
Update collections handler to check soft-deleted users. Update dashboard
service to exclude deleted users from statistics.
This commit is contained in:
2026-02-22 01:57:49 -05:00
parent e3a3aa124f
commit bb0970dfd0
4 changed files with 293 additions and 42 deletions
+10 -1
View File
@@ -103,6 +103,7 @@ func (h *DashboardHandler) RestoreSystemCollection(c echo.Context) error {
var req struct {
CollectionName string `json:"collection_name"`
ResetType string `json:"reset_type"` // "full" or "keep_books"
}
if err := c.Bind(&req); err != nil {
@@ -113,6 +114,10 @@ func (h *DashboardHandler) RestoreSystemCollection(c echo.Context) error {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "collection_name required"})
}
if req.ResetType == "" {
req.ResetType = "full"
}
validCollections := map[string]bool{
"continue-reading": true,
"recently-added": true,
@@ -123,7 +128,11 @@ func (h *DashboardHandler) RestoreSystemCollection(c echo.Context) error {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "Invalid system collection name"})
}
err := h.dashboardService.RestoreSystemCollection(c.Request().Context(), userUUID, req.CollectionName)
if req.ResetType != "full" && req.ResetType != "keep_books" {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "reset_type must be 'full' or 'keep_books'"})
}
err := h.dashboardService.RestoreSystemCollection(c.Request().Context(), userUUID, req.CollectionName, req.ResetType)
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{"error": "Failed to restore system collection"})
}