add priority ids at outgoing letter
This commit is contained in:
parent
b81c0be3c4
commit
cdc1244efc
@ -7,19 +7,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SearchOutgoingLettersRequest struct {
|
type SearchOutgoingLettersRequest struct {
|
||||||
Query string `json:"query" form:"query"`
|
Query string `json:"query" form:"query"`
|
||||||
LetterNumber string `json:"letter_number" form:"letter_number"`
|
LetterNumber string `json:"letter_number" form:"letter_number"`
|
||||||
Subject string `json:"subject" form:"subject"`
|
Subject string `json:"subject" form:"subject"`
|
||||||
Status string `json:"status" form:"status"`
|
Status string `json:"status" form:"status"`
|
||||||
PriorityID *uuid.UUID `json:"priority_id" form:"priority_id"`
|
PriorityID *uuid.UUID `json:"priority_id" form:"priority_id"`
|
||||||
InstitutionID *uuid.UUID `json:"institution_id" form:"institution_id"`
|
InstitutionID *uuid.UUID `json:"institution_id" form:"institution_id"`
|
||||||
CreatedBy *uuid.UUID `json:"created_by" form:"created_by"`
|
CreatedBy *uuid.UUID `json:"created_by" form:"created_by"`
|
||||||
DateFrom *time.Time `json:"date_from" form:"date_from"`
|
DateFrom *time.Time `json:"date_from" form:"date_from"`
|
||||||
DateTo *time.Time `json:"date_to" form:"date_to"`
|
DateTo *time.Time `json:"date_to" form:"date_to"`
|
||||||
Page int `json:"page" form:"page"`
|
Page int `json:"page" form:"page"`
|
||||||
Limit int `json:"limit" form:"limit"`
|
Limit int `json:"limit" form:"limit"`
|
||||||
SortBy string `json:"sort_by" form:"sort_by"`
|
SortBy string `json:"sort_by" form:"sort_by"`
|
||||||
SortOrder string `json:"sort_order" form:"sort_order"`
|
SortOrder string `json:"sort_order" form:"sort_order"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchOutgoingLettersResponse struct {
|
type SearchOutgoingLettersResponse struct {
|
||||||
@ -55,7 +55,7 @@ type CreateOutgoingLetterRequest struct {
|
|||||||
IssueDate time.Time `json:"issue_date" validate:"required"`
|
IssueDate time.Time `json:"issue_date" validate:"required"`
|
||||||
Attachments []CreateOutgoingLetterAttachment `json:"attachments,omitempty"`
|
Attachments []CreateOutgoingLetterAttachment `json:"attachments,omitempty"`
|
||||||
UserID uuid.UUID
|
UserID uuid.UUID
|
||||||
ApprovalFlowID *uuid.UUID `json:"approval_flow_id,omitempty"`
|
ApprovalFlowID *uuid.UUID `json:"approval_flow_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OutgoingLetterRecipientResponse struct {
|
type OutgoingLetterRecipientResponse struct {
|
||||||
@ -110,7 +110,7 @@ type OutgoingLetterResponse struct {
|
|||||||
CreatedBy uuid.UUID `json:"created_by"`
|
CreatedBy uuid.UUID `json:"created_by"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
IsRead bool `json:"is_read"`
|
IsRead bool `json:"is_read"`
|
||||||
Recipients []OutgoingLetterRecipientResponse `json:"recipients,omitempty"`
|
Recipients []OutgoingLetterRecipientResponse `json:"recipients,omitempty"`
|
||||||
Attachments []OutgoingLetterAttachmentResponse `json:"attachments,omitempty"`
|
Attachments []OutgoingLetterAttachmentResponse `json:"attachments,omitempty"`
|
||||||
Approvals []OutgoingLetterApprovalResponse `json:"approvals,omitempty"`
|
Approvals []OutgoingLetterApprovalResponse `json:"approvals,omitempty"`
|
||||||
@ -127,20 +127,21 @@ type UpdateOutgoingLetterRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ListOutgoingLettersRequest struct {
|
type ListOutgoingLettersRequest struct {
|
||||||
Page int `form:"page" json:"page"`
|
Page int `form:"page" json:"page"`
|
||||||
Limit int `form:"limit" json:"limit"`
|
Limit int `form:"limit" json:"limit"`
|
||||||
Status string `form:"status" json:"status,omitempty"`
|
Status string `form:"status" json:"status,omitempty"`
|
||||||
Query string `form:"q" json:"query,omitempty"`
|
Query string `form:"q" json:"query,omitempty"`
|
||||||
CreatedBy *uuid.UUID `form:"created_by" json:"created_by,omitempty"`
|
CreatedBy *uuid.UUID `form:"created_by" json:"created_by,omitempty"`
|
||||||
DepartmentID *uuid.UUID `form:"department_id" json:"department_id,omitempty"`
|
DepartmentID *uuid.UUID `form:"department_id" json:"department_id,omitempty"`
|
||||||
ReceiverInstitutionID *uuid.UUID `form:"receiver_institution_id" json:"receiver_institution_id,omitempty"`
|
ReceiverInstitutionID *uuid.UUID `form:"receiver_institution_id" json:"receiver_institution_id,omitempty"`
|
||||||
FromDate string `form:"from_date" json:"from_date,omitempty"`
|
FromDate string `form:"from_date" json:"from_date,omitempty"`
|
||||||
ToDate string `form:"to_date" json:"to_date,omitempty"`
|
ToDate string `form:"to_date" json:"to_date,omitempty"`
|
||||||
PriorityID *uuid.UUID `form:"priority_id" json:"priority_id,omitempty"`
|
PriorityID *uuid.UUID `form:"priority_id" json:"priority_id,omitempty"`
|
||||||
SortBy string `form:"sort_by" json:"sort_by,omitempty"`
|
PriorityIDs []uuid.UUID `json:"priority_ids,omitempty"`
|
||||||
SortOrder string `form:"sort_order" json:"sort_order,omitempty"`
|
SortBy string `form:"sort_by" json:"sort_by,omitempty"`
|
||||||
IsArchived *bool `form:"is_archived" json:"is_archived,omitempty"`
|
SortOrder string `form:"sort_order" json:"sort_order,omitempty"`
|
||||||
IsRead *bool `form:"is_read,omitempty"`
|
IsArchived *bool `form:"is_archived" json:"is_archived,omitempty"`
|
||||||
|
IsRead *bool `form:"is_read,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListOutgoingLettersResponse struct {
|
type ListOutgoingLettersResponse struct {
|
||||||
@ -245,8 +246,8 @@ type ApprovalFlowStepResponse struct {
|
|||||||
|
|
||||||
type ListApprovalFlowsRequest struct {
|
type ListApprovalFlowsRequest struct {
|
||||||
Limit int `json:"limit"`
|
Limit int `json:"limit"`
|
||||||
Page int `json:"page"`
|
Page int `json:"page"`
|
||||||
Search *string `json:"search"`
|
Search *string `json:"search"`
|
||||||
DepartmentID *uuid.UUID `json:"department_id,omitempty"`
|
DepartmentID *uuid.UUID `json:"department_id,omitempty"`
|
||||||
IsActive *bool `json:"is_active,omitempty"`
|
IsActive *bool `json:"is_active,omitempty"`
|
||||||
}
|
}
|
||||||
@ -333,16 +334,16 @@ type OutgoingLetterDiscussionAttachmentResponse struct {
|
|||||||
|
|
||||||
// TimelineEvent represents a single event in the approval timeline
|
// TimelineEvent represents a single event in the approval timeline
|
||||||
type TimelineEvent struct {
|
type TimelineEvent struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Type string `json:"type"` // "approval", "discussion", "submission", "rejection"
|
Type string `json:"type"` // "approval", "discussion", "submission", "rejection"
|
||||||
Timestamp time.Time `json:"timestamp"`
|
Timestamp time.Time `json:"timestamp"`
|
||||||
Actor *UserResponse `json:"actor,omitempty"`
|
Actor *UserResponse `json:"actor,omitempty"`
|
||||||
Action string `json:"action"`
|
Action string `json:"action"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
StepOrder int `json:"step_order,omitempty"`
|
StepOrder int `json:"step_order,omitempty"`
|
||||||
Message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
Data interface{} `json:"data,omitempty"`
|
Data interface{} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApprovalTimelineResponse represents the complete timeline for a letter
|
// ApprovalTimelineResponse represents the complete timeline for a letter
|
||||||
@ -358,11 +359,11 @@ type ApprovalTimelineResponse struct {
|
|||||||
|
|
||||||
// TimelineSummary provides overview statistics for the timeline
|
// TimelineSummary provides overview statistics for the timeline
|
||||||
type TimelineSummary struct {
|
type TimelineSummary struct {
|
||||||
TotalSteps int `json:"total_steps"`
|
TotalSteps int `json:"total_steps"`
|
||||||
CompletedSteps int `json:"completed_steps"`
|
CompletedSteps int `json:"completed_steps"`
|
||||||
PendingSteps int `json:"pending_steps"`
|
PendingSteps int `json:"pending_steps"`
|
||||||
CurrentStep int `json:"current_step"`
|
CurrentStep int `json:"current_step"`
|
||||||
TotalDuration string `json:"total_duration"`
|
TotalDuration string `json:"total_duration"`
|
||||||
AverageStepTime string `json:"average_step_time"`
|
AverageStepTime string `json:"average_step_time"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,7 +102,17 @@ func (h *LetterOutgoingHandler) ListOutgoingLetters(c *gin.Context) {
|
|||||||
req.Limit = 10
|
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] 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)
|
resp, err := h.svc.ListOutgoingLetters(c.Request.Context(), &req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -91,6 +91,7 @@ type ListOutgoingLettersFilter struct {
|
|||||||
FromDate *time.Time
|
FromDate *time.Time
|
||||||
ToDate *time.Time
|
ToDate *time.Time
|
||||||
PriorityID *uuid.UUID
|
PriorityID *uuid.UUID
|
||||||
|
PriorityIDs []uuid.UUID
|
||||||
SortBy *string
|
SortBy *string
|
||||||
SortOrder *string
|
SortOrder *string
|
||||||
IsArchived *bool
|
IsArchived *bool
|
||||||
@ -140,13 +141,16 @@ func (r *LetterOutgoingRepository) List(ctx context.Context, filter ListOutgoing
|
|||||||
query = query.Distinct()
|
query = query.Distinct()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if filter.ReceiverInstitutionID != nil {
|
if filter.ReceiverInstitutionID != nil {
|
||||||
query = query.Where("receiver_institution_id = ?", *filter.ReceiverInstitutionID)
|
query = query.Where("receiver_institution_id = ?", *filter.ReceiverInstitutionID)
|
||||||
}
|
}
|
||||||
if filter.PriorityID != nil {
|
if filter.PriorityID != nil {
|
||||||
query = query.Where("priority_id = ?", *filter.PriorityID)
|
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 {
|
if filter.FromDate != nil {
|
||||||
query = query.Where("issue_date >= ?", *filter.FromDate)
|
query = query.Where("issue_date >= ?", *filter.FromDate)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -211,6 +211,7 @@ func (s *LetterOutgoingServiceImpl) ListOutgoingLetters(ctx context.Context, req
|
|||||||
DepartmentID: req.DepartmentID,
|
DepartmentID: req.DepartmentID,
|
||||||
ReceiverInstitutionID: req.ReceiverInstitutionID,
|
ReceiverInstitutionID: req.ReceiverInstitutionID,
|
||||||
PriorityID: req.PriorityID,
|
PriorityID: req.PriorityID,
|
||||||
|
PriorityIDs: req.PriorityIDs,
|
||||||
UserID: &userID,
|
UserID: &userID,
|
||||||
IsRead: req.IsRead,
|
IsRead: req.IsRead,
|
||||||
}
|
}
|
||||||
@ -219,6 +220,10 @@ func (s *LetterOutgoingServiceImpl) ListOutgoingLetters(ctx context.Context, req
|
|||||||
filter.DepartmentID = &departmentID
|
filter.DepartmentID = &departmentID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(req.PriorityIDs) > 0 {
|
||||||
|
filter.PriorityIDs = req.PriorityIDs
|
||||||
|
}
|
||||||
|
|
||||||
if req.Status != "" {
|
if req.Status != "" {
|
||||||
filter.Status = &req.Status
|
filter.Status = &req.Status
|
||||||
}
|
}
|
||||||
@ -301,7 +306,6 @@ func (s *LetterOutgoingServiceImpl) ListOutgoingLetters(ctx context.Context, req
|
|||||||
result := batchResult{}
|
result := batchResult{}
|
||||||
errChan := make(chan error, 4)
|
errChan := make(chan error, 4)
|
||||||
|
|
||||||
|
|
||||||
// Load attachments
|
// Load attachments
|
||||||
go func() {
|
go func() {
|
||||||
result.attachments, err = s.processor.GetBatchAttachments(ctx, letterIDs)
|
result.attachments, err = s.processor.GetBatchAttachments(ctx, letterIDs)
|
||||||
@ -367,7 +371,6 @@ func (s *LetterOutgoingServiceImpl) ListOutgoingLetters(ctx context.Context, req
|
|||||||
isRead = recipient.ReadAt != nil
|
isRead = recipient.ReadAt != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
response := transformLetterToResponse(&letter)
|
response := transformLetterToResponse(&letter)
|
||||||
response.IsRead = isRead
|
response.IsRead = isRead
|
||||||
items[i] = response
|
items[i] = response
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user