283 lines
13 KiB
Go
283 lines
13 KiB
Go
package contract
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type CreateOutgoingLetterRecipient struct {
|
|
LetterID uuid.UUID `json:"letter_id"`
|
|
UserID *uuid.UUID `json:"user_id,omitempty"`
|
|
DepartmentID *uuid.UUID `json:"department_id,omitempty"`
|
|
IsPrimary bool `json:"is_primary"`
|
|
Status string `json:"status"`
|
|
Flag *string `json:"flag,omitempty"`
|
|
IsArchived bool `json:"is_archived"`
|
|
}
|
|
|
|
type CreateOutgoingLetterAttachment struct {
|
|
FileURL string `json:"file_url" validate:"required"`
|
|
FileName string `json:"file_name" validate:"required"`
|
|
FileType string `json:"file_type" validate:"required"`
|
|
}
|
|
|
|
type CreateOutgoingLetterRequest struct {
|
|
ReferenceNumber *string `json:"reference_number,omitempty"`
|
|
Subject string `json:"subject" validate:"required"`
|
|
Description *string `json:"description,omitempty"`
|
|
PriorityID *uuid.UUID `json:"priority_id,omitempty"`
|
|
ReceiverInstitutionID *uuid.UUID `json:"receiver_institution_id,omitempty"`
|
|
IssueDate time.Time `json:"issue_date" validate:"required"`
|
|
Attachments []CreateOutgoingLetterAttachment `json:"attachments,omitempty"`
|
|
UserID uuid.UUID
|
|
}
|
|
|
|
type OutgoingLetterRecipientResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
LetterID uuid.UUID `json:"letter_id"`
|
|
UserID *uuid.UUID `json:"user_id,omitempty"`
|
|
DepartmentID *uuid.UUID `json:"department_id,omitempty"`
|
|
IsPrimary bool `json:"is_primary"`
|
|
Status string `json:"status"`
|
|
ReadAt *time.Time `json:"read_at,omitempty"`
|
|
Flag *string `json:"flag,omitempty"`
|
|
IsArchived bool `json:"is_archived"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
User *UserResponse `json:"user,omitempty"`
|
|
Department *DepartmentResponse `json:"department,omitempty"`
|
|
}
|
|
|
|
type OutgoingLetterAttachmentResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
FileURL string `json:"file_url"`
|
|
FileName string `json:"file_name"`
|
|
FileType string `json:"file_type"`
|
|
UploadedAt time.Time `json:"uploaded_at"`
|
|
}
|
|
|
|
type OutgoingLetterApprovalResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
StepOrder int `json:"step_order"`
|
|
ApproverID *uuid.UUID `json:"approver_id,omitempty"`
|
|
Status string `json:"status"`
|
|
Remarks *string `json:"remarks,omitempty"`
|
|
ActedAt *time.Time `json:"acted_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type OutgoingLetterResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
LetterNumber string `json:"letter_number"`
|
|
ReferenceNumber *string `json:"reference_number,omitempty"`
|
|
Subject string `json:"subject"`
|
|
Description *string `json:"description,omitempty"`
|
|
PriorityID *uuid.UUID `json:"priority_id,omitempty"`
|
|
Priority *PriorityResponse `json:"priority,omitempty"`
|
|
ReceiverInstitutionID *uuid.UUID `json:"receiver_institution_id,omitempty"`
|
|
ReceiverInstitution *InstitutionResponse `json:"receiver_institution,omitempty"`
|
|
IssueDate time.Time `json:"issue_date"`
|
|
Status string `json:"status"`
|
|
ApprovalFlowID *uuid.UUID `json:"approval_flow_id,omitempty"`
|
|
CreatedBy uuid.UUID `json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Recipients []OutgoingLetterRecipientResponse `json:"recipients,omitempty"`
|
|
Attachments []OutgoingLetterAttachmentResponse `json:"attachments,omitempty"`
|
|
Approvals []OutgoingLetterApprovalResponse `json:"approvals,omitempty"`
|
|
}
|
|
|
|
type UpdateOutgoingLetterRequest struct {
|
|
ReferenceNumber *string `json:"reference_number,omitempty"`
|
|
Subject *string `json:"subject,omitempty"`
|
|
Description *string `json:"description,omitempty"`
|
|
PriorityID *uuid.UUID `json:"priority_id,omitempty"`
|
|
ReceiverInstitutionID *uuid.UUID `json:"receiver_institution_id,omitempty"`
|
|
IssueDate *time.Time `json:"issue_date,omitempty"`
|
|
}
|
|
|
|
type ListOutgoingLettersRequest struct {
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
Status *string `json:"status,omitempty"`
|
|
Query *string `json:"query,omitempty"`
|
|
CreatedBy *uuid.UUID `json:"created_by,omitempty"`
|
|
ReceiverInstitutionID *uuid.UUID `json:"receiver_institution_id,omitempty"`
|
|
FromDate *time.Time `json:"from_date,omitempty"`
|
|
ToDate *time.Time `json:"to_date,omitempty"`
|
|
}
|
|
|
|
type ListOutgoingLettersResponse struct {
|
|
Items []*OutgoingLetterResponse `json:"items"`
|
|
Total int64 `json:"total"`
|
|
}
|
|
|
|
type ApproveLetterRequest struct {
|
|
Remarks *string `json:"remarks,omitempty"`
|
|
}
|
|
|
|
type RejectLetterRequest struct {
|
|
Reason string `json:"reason" validate:"required"`
|
|
}
|
|
|
|
type AddRecipientsRequest struct {
|
|
Recipients []CreateOutgoingLetterRecipient `json:"recipients" validate:"required,dive"`
|
|
}
|
|
|
|
type UpdateRecipientRequest struct {
|
|
UserID *uuid.UUID `json:"user_id,omitempty"`
|
|
DepartmentID *uuid.UUID `json:"department_id,omitempty"`
|
|
IsPrimary bool `json:"is_primary"`
|
|
Status *string `json:"status,omitempty"`
|
|
Flag *string `json:"flag,omitempty"`
|
|
IsArchived *bool `json:"is_archived,omitempty"`
|
|
}
|
|
|
|
type AddAttachmentsRequest struct {
|
|
Attachments []CreateOutgoingLetterAttachment `json:"attachments" validate:"required,dive"`
|
|
}
|
|
|
|
type CreateDiscussionAttachment struct {
|
|
FileURL string `json:"file_url" validate:"required"`
|
|
FileName string `json:"file_name" validate:"required"`
|
|
FileType string `json:"file_type" validate:"required"`
|
|
}
|
|
|
|
type CreateDiscussionRequest struct {
|
|
ParentID *uuid.UUID `json:"parent_id,omitempty"`
|
|
Message string `json:"message" validate:"required"`
|
|
Mentions map[string]interface{} `json:"mentions,omitempty"`
|
|
Attachments []CreateDiscussionAttachment `json:"attachments,omitempty"`
|
|
}
|
|
|
|
type UpdateDiscussionRequest struct {
|
|
Message string `json:"message" validate:"required"`
|
|
Mentions map[string]interface{} `json:"mentions,omitempty"`
|
|
}
|
|
|
|
type DiscussionResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ParentID *uuid.UUID `json:"parent_id,omitempty"`
|
|
UserID uuid.UUID `json:"user_id"`
|
|
Message string `json:"message"`
|
|
Mentions map[string]interface{} `json:"mentions,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
EditedAt *time.Time `json:"edited_at,omitempty"`
|
|
}
|
|
|
|
type ApprovalFlowRequest struct {
|
|
DepartmentID uuid.UUID `json:"department_id" validate:"required"`
|
|
Name string `json:"name" validate:"required"`
|
|
Description *string `json:"description,omitempty"`
|
|
IsActive bool `json:"is_active"`
|
|
Steps []ApprovalFlowStepRequest `json:"steps" validate:"required,dive"`
|
|
}
|
|
|
|
type ApprovalFlowStepRequest struct {
|
|
StepOrder int `json:"step_order" validate:"required,min=1"`
|
|
ParallelGroup int `json:"parallel_group" validate:"min=1"`
|
|
ApproverRoleID *uuid.UUID `json:"approver_role_id,omitempty"`
|
|
ApproverUserID *uuid.UUID `json:"approver_user_id,omitempty"`
|
|
Required bool `json:"required"`
|
|
}
|
|
|
|
type ApprovalFlowResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
DepartmentID uuid.UUID `json:"department_id"`
|
|
Department *DepartmentResponse `json:"department,omitempty"`
|
|
Name string `json:"name"`
|
|
Description *string `json:"description,omitempty"`
|
|
IsActive bool `json:"is_active"`
|
|
Steps []ApprovalFlowStepResponse `json:"steps,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type ApprovalFlowStepResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
StepOrder int `json:"step_order"`
|
|
ParallelGroup int `json:"parallel_group"`
|
|
ApproverRoleID *uuid.UUID `json:"approver_role_id,omitempty"`
|
|
ApproverRole *RoleResponse `json:"approver_role,omitempty"`
|
|
ApproverUserID *uuid.UUID `json:"approver_user_id,omitempty"`
|
|
ApproverUser *UserResponse `json:"approver_user,omitempty"`
|
|
Required bool `json:"required"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type ListApprovalFlowsRequest struct {
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
DepartmentID *uuid.UUID `json:"department_id,omitempty"`
|
|
IsActive *bool `json:"is_active,omitempty"`
|
|
}
|
|
|
|
type ListApprovalFlowsResponse struct {
|
|
Items []*ApprovalFlowResponse `json:"items"`
|
|
Total int64 `json:"total"`
|
|
}
|
|
|
|
// Letter Approval Information for Approver
|
|
type LetterApprovalInfoResponse struct {
|
|
IsApproverOnActiveStep bool `json:"is_approver_on_active_step"`
|
|
DecisionStatus string `json:"decision_status"`
|
|
CanApprove bool `json:"can_approve"`
|
|
Actions []ApprovalAction `json:"actions"`
|
|
NotesVisibility string `json:"notes_visibility"`
|
|
}
|
|
|
|
type ApprovalAction struct {
|
|
Type string `json:"type"`
|
|
Href string `json:"href"`
|
|
Method string `json:"method"`
|
|
}
|
|
|
|
// OutgoingLetterApprovalDiscussionsResponse combines approvals and discussions for outgoing letters
|
|
type OutgoingLetterApprovalDiscussionsResponse struct {
|
|
Approvals []EnhancedOutgoingLetterApprovalResponse `json:"approvals"`
|
|
Discussions []OutgoingLetterDiscussionResponse `json:"discussions"`
|
|
}
|
|
|
|
// EnhancedOutgoingLetterApprovalResponse includes approval details with related data
|
|
type EnhancedOutgoingLetterApprovalResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
LetterID uuid.UUID `json:"letter_id"`
|
|
StepID uuid.UUID `json:"step_id"`
|
|
ApproverID *uuid.UUID `json:"approver_id,omitempty"`
|
|
Status string `json:"status"`
|
|
Remarks *string `json:"remarks,omitempty"`
|
|
ActedAt *time.Time `json:"acted_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Step *ApprovalFlowStepResponse `json:"step,omitempty"`
|
|
Approver *UserResponse `json:"approver,omitempty"`
|
|
}
|
|
|
|
// OutgoingLetterDiscussionResponse represents a discussion on an outgoing letter
|
|
type OutgoingLetterDiscussionResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
LetterID uuid.UUID `json:"letter_id"`
|
|
ParentID *uuid.UUID `json:"parent_id,omitempty"`
|
|
UserID uuid.UUID `json:"user_id"`
|
|
Message string `json:"message"`
|
|
Mentions map[string]interface{} `json:"mentions,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
EditedAt *time.Time `json:"edited_at,omitempty"`
|
|
User *UserResponse `json:"user,omitempty"`
|
|
MentionedUsers []UserResponse `json:"mentioned_users,omitempty"`
|
|
Attachments []OutgoingLetterDiscussionAttachmentResponse `json:"attachments,omitempty"`
|
|
}
|
|
|
|
// OutgoingLetterDiscussionAttachmentResponse represents an attachment in a discussion
|
|
type OutgoingLetterDiscussionAttachmentResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
DiscussionID uuid.UUID `json:"discussion_id"`
|
|
FileURL string `json:"file_url"`
|
|
FileName string `json:"file_name"`
|
|
FileType string `json:"file_type"`
|
|
UploadedBy *uuid.UUID `json:"uploaded_by,omitempty"`
|
|
UploadedAt time.Time `json:"uploaded_at"`
|
|
}
|