add priority ids at outgoing letter
This commit is contained in:
parent
b81c0be3c4
commit
cdc1244efc
@ -137,6 +137,7 @@ type ListOutgoingLettersRequest struct {
|
||||
FromDate string `form:"from_date" json:"from_date,omitempty"`
|
||||
ToDate string `form:"to_date" json:"to_date,omitempty"`
|
||||
PriorityID *uuid.UUID `form:"priority_id" json:"priority_id,omitempty"`
|
||||
PriorityIDs []uuid.UUID `json:"priority_ids,omitempty"`
|
||||
SortBy string `form:"sort_by" json:"sort_by,omitempty"`
|
||||
SortOrder string `form:"sort_order" json:"sort_order,omitempty"`
|
||||
IsArchived *bool `form:"is_archived" json:"is_archived,omitempty"`
|
||||
|
||||
@ -102,7 +102,17 @@ func (h *LetterOutgoingHandler) ListOutgoingLetters(c *gin.Context) {
|
||||
req.Limit = 10
|
||||
}
|
||||
|
||||
if ids := c.QueryArray("priority_ids[]"); len(ids) > 0 {
|
||||
for _, s := range ids {
|
||||
if id, err := uuid.Parse(s); err == nil {
|
||||
req.PriorityIDs = append(req.PriorityIDs, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("[DEBUG] request: %v\n", req)
|
||||
fmt.Printf("[DEBUG] Raw query: %v\n", c.Request.URL.RawQuery)
|
||||
fmt.Printf("[DEBUG] Parsed form: %v\n", c.Request.URL.Query())
|
||||
|
||||
resp, err := h.svc.ListOutgoingLetters(c.Request.Context(), &req)
|
||||
if err != nil {
|
||||
|
||||
@ -91,6 +91,7 @@ type ListOutgoingLettersFilter struct {
|
||||
FromDate *time.Time
|
||||
ToDate *time.Time
|
||||
PriorityID *uuid.UUID
|
||||
PriorityIDs []uuid.UUID
|
||||
SortBy *string
|
||||
SortOrder *string
|
||||
IsArchived *bool
|
||||
@ -140,13 +141,16 @@ func (r *LetterOutgoingRepository) List(ctx context.Context, filter ListOutgoing
|
||||
query = query.Distinct()
|
||||
}
|
||||
|
||||
|
||||
if filter.ReceiverInstitutionID != nil {
|
||||
query = query.Where("receiver_institution_id = ?", *filter.ReceiverInstitutionID)
|
||||
}
|
||||
if filter.PriorityID != nil {
|
||||
query = query.Where("priority_id = ?", *filter.PriorityID)
|
||||
}
|
||||
if len(filter.PriorityIDs) > 0 {
|
||||
query = query.Where("priority_id IN ?", filter.PriorityIDs)
|
||||
}
|
||||
fmt.Printf("Priority %s", filter.PriorityIDs)
|
||||
if filter.FromDate != nil {
|
||||
query = query.Where("issue_date >= ?", *filter.FromDate)
|
||||
}
|
||||
|
||||
@ -211,6 +211,7 @@ func (s *LetterOutgoingServiceImpl) ListOutgoingLetters(ctx context.Context, req
|
||||
DepartmentID: req.DepartmentID,
|
||||
ReceiverInstitutionID: req.ReceiverInstitutionID,
|
||||
PriorityID: req.PriorityID,
|
||||
PriorityIDs: req.PriorityIDs,
|
||||
UserID: &userID,
|
||||
IsRead: req.IsRead,
|
||||
}
|
||||
@ -219,6 +220,10 @@ func (s *LetterOutgoingServiceImpl) ListOutgoingLetters(ctx context.Context, req
|
||||
filter.DepartmentID = &departmentID
|
||||
}
|
||||
|
||||
if len(req.PriorityIDs) > 0 {
|
||||
filter.PriorityIDs = req.PriorityIDs
|
||||
}
|
||||
|
||||
if req.Status != "" {
|
||||
filter.Status = &req.Status
|
||||
}
|
||||
@ -301,7 +306,6 @@ func (s *LetterOutgoingServiceImpl) ListOutgoingLetters(ctx context.Context, req
|
||||
result := batchResult{}
|
||||
errChan := make(chan error, 4)
|
||||
|
||||
|
||||
// Load attachments
|
||||
go func() {
|
||||
result.attachments, err = s.processor.GetBatchAttachments(ctx, letterIDs)
|
||||
@ -367,7 +371,6 @@ func (s *LetterOutgoingServiceImpl) ListOutgoingLetters(ctx context.Context, req
|
||||
isRead = recipient.ReadAt != nil
|
||||
}
|
||||
|
||||
|
||||
response := transformLetterToResponse(&letter)
|
||||
response.IsRead = isRead
|
||||
items[i] = response
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user