bulk delete outgoing letter
This commit is contained in:
@@ -19,6 +19,7 @@ type LetterOutgoingService interface {
|
||||
SearchOutgoingLetters(ctx context.Context, req *contract.SearchOutgoingLettersRequest) (*contract.SearchOutgoingLettersResponse, error)
|
||||
UpdateOutgoingLetter(ctx context.Context, id uuid.UUID, req *contract.UpdateOutgoingLetterRequest) (*contract.OutgoingLetterResponse, error)
|
||||
DeleteOutgoingLetter(ctx context.Context, id uuid.UUID) error
|
||||
BulkDeleteOutgoingLetters(ctx context.Context, ids []uuid.UUID) error
|
||||
|
||||
SubmitForApproval(ctx context.Context, letterID uuid.UUID) error
|
||||
ApproveOutgoingLetter(ctx context.Context, letterID uuid.UUID, req *contract.ApproveLetterRequest) error
|
||||
@@ -158,7 +159,33 @@ func (h *LetterOutgoingHandler) DeleteOutgoingLetter(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, &contract.SuccessResponse{Message: "deleted"})
|
||||
c.JSON(http.StatusOK, contract.BuildSuccessResponse(&contract.SuccessResponse{Message: "deleted"}))
|
||||
}
|
||||
|
||||
func (h *LetterOutgoingHandler) BulkDeleteOutgoingLetters(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{
|
||||
Error: "Invalid request body",
|
||||
Code: http.StatusBadRequest,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.svc.BulkDeleteOutgoingLetters(c.Request.Context(), req.IDs); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, &contract.ErrorResponse{
|
||||
Error: err.Error(),
|
||||
Code: http.StatusInternalServerError,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, contract.BuildSuccessResponse(&contract.SuccessResponse{
|
||||
Message: fmt.Sprintf("%d letters deleted successfully", len(req.IDs)),
|
||||
}))
|
||||
}
|
||||
|
||||
func (h *LetterOutgoingHandler) SubmitForApproval(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user