update get letter

This commit is contained in:
efrilm
2025-10-22 11:39:40 +07:00
parent 88ad35c5d0
commit 7f67f6db4f
6 changed files with 169 additions and 0 deletions
@@ -2,6 +2,7 @@ package processor
import (
"context"
"eslogad-be/internal/appcontext"
"fmt"
"sort"
"time"
@@ -310,6 +311,16 @@ func (p *LetterOutgoingProcessorImpl) GetOutgoingLetterByID(ctx context.Context,
}
func (p *LetterOutgoingProcessorImpl) ListOutgoingLetters(ctx context.Context, filter repository.ListOutgoingLettersFilter, limit, offset int) ([]entities.LetterOutgoing, int64, error) {
appCtx := appcontext.FromGinContext(ctx)
fmt.Printf("Checked User Role: %s\n", appCtx.UserRole)
fmt.Printf("Checked User ID: %s\n", appCtx.UserID)
if appCtx.IsSuperAdmin() {
fmt.Println("Checked Role: super admin")
return p.letterRepo.ListAll(ctx, filter, limit, offset)
}
return p.letterRepo.List(ctx, filter, limit, offset)
}
+10
View File
@@ -206,6 +206,16 @@ func (p *LetterProcessorImpl) MarkOutgoingLetterAsRead(ctx context.Context, lett
func (p *LetterProcessorImpl) ListIncomingLetters(ctx context.Context, filter repository.ListIncomingLettersFilter, page, limit int) ([]entities.LetterIncoming, int64, error) {
// Just fetch the raw data
appCtx := appcontext.FromGinContext(ctx)
fmt.Printf("Checked User Role: %s\n", appCtx.UserRole)
fmt.Printf("Checked User ID: %s\n", appCtx.UserID)
if appCtx.IsSuperAdmin() {
fmt.Println("Checked Role: super admin")
return p.letterRepo.ListAll(ctx, filter, page, limit)
}
return p.letterRepo.List(ctx, filter, limit, (page-1)*limit)
}