bulk delete incoming letter
This commit is contained in:
@@ -3,6 +3,7 @@ package handler
|
||||
import (
|
||||
"context"
|
||||
"eslogad-be/internal/appcontext"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -23,6 +24,7 @@ type LetterService interface {
|
||||
MarkOutgoingLetterAsRead(ctx context.Context, letterID uuid.UUID) (*contract.MarkLetterReadResponse, error)
|
||||
UpdateIncomingLetter(ctx context.Context, id uuid.UUID, req *contract.UpdateIncomingLetterRequest) (*contract.IncomingLetterResponse, error)
|
||||
SoftDeleteIncomingLetter(ctx context.Context, id uuid.UUID) error
|
||||
BulkSoftDeleteIncomingLetters(ctx context.Context, ids []uuid.UUID) error
|
||||
BulkArchiveIncomingLetters(ctx context.Context, letterIDs []uuid.UUID) (*contract.BulkArchiveLettersResponse, error)
|
||||
ArchiveIncomingLetter(ctx context.Context, letterID uuid.UUID) error
|
||||
|
||||
@@ -282,6 +284,29 @@ func (h *LetterHandler) DeleteIncomingLetter(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func (h *LetterHandler) BulkDeleteIncomingLetters(c *gin.Context) {
|
||||
var req struct {
|
||||
IDs []uuid.UUID `json:"ids" binding:"required,min=1"`
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, contract.ErrorResponse{
|
||||
Message: "Invalid request body",
|
||||
Error: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.svc.BulkSoftDeleteIncomingLetters(c.Request.Context(), req.IDs); err != nil {
|
||||
h.handleServiceError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
h.respondSuccess(c, http.StatusOK, &contract.SuccessResponse{
|
||||
Message: fmt.Sprintf("%d letters deleted successfully", len(req.IDs)),
|
||||
})
|
||||
}
|
||||
|
||||
func (h *LetterHandler) CreateDispositions(c *gin.Context) {
|
||||
var req contract.CreateLetterDispositionRequest
|
||||
if !h.bindJSON(c, &req) {
|
||||
|
||||
Reference in New Issue
Block a user