update get letter
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user