Add letter and user id
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type ApprovalFlow struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
DepartmentID uuid.UUID `gorm:"type:uuid;not null" json:"department_id"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
|
||||
// Relations
|
||||
Department *Department `gorm:"foreignKey:DepartmentID" json:"department,omitempty"`
|
||||
Steps []ApprovalFlowStep `gorm:"foreignKey:FlowID" json:"steps,omitempty"`
|
||||
}
|
||||
|
||||
func (ApprovalFlow) TableName() string { return "approval_flows" }
|
||||
|
||||
type ApprovalFlowStep struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
FlowID uuid.UUID `gorm:"type:uuid;not null" json:"flow_id"`
|
||||
StepOrder int `gorm:"not null" json:"step_order"`
|
||||
ParallelGroup int `gorm:"default:1" json:"parallel_group"`
|
||||
ApproverRoleID *uuid.UUID `json:"approver_role_id,omitempty"`
|
||||
ApproverUserID *uuid.UUID `json:"approver_user_id,omitempty"`
|
||||
Required bool `gorm:"default:true" json:"required"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
|
||||
// Relations
|
||||
ApprovalFlow *ApprovalFlow `gorm:"foreignKey:FlowID" json:"approval_flow,omitempty"`
|
||||
ApproverRole *Role `gorm:"foreignKey:ApproverRoleID" json:"approver_role,omitempty"`
|
||||
ApproverUser *User `gorm:"foreignKey:ApproverUserID" json:"approver_user,omitempty"`
|
||||
}
|
||||
|
||||
func (ApprovalFlowStep) TableName() string { return "approval_flow_steps" }
|
||||
|
||||
type ApprovalStatus string
|
||||
|
||||
const (
|
||||
ApprovalStatusPending ApprovalStatus = "pending"
|
||||
ApprovalStatusApproved ApprovalStatus = "approved"
|
||||
ApprovalStatusRejected ApprovalStatus = "rejected"
|
||||
)
|
||||
|
||||
type LetterOutgoingApproval struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
LetterID uuid.UUID `gorm:"type:uuid;not null" json:"letter_id"`
|
||||
StepID uuid.UUID `gorm:"type:uuid;not null" json:"step_id"`
|
||||
ApproverID *uuid.UUID `json:"approver_id,omitempty"`
|
||||
Status ApprovalStatus `gorm:"not null;default:'pending'" json:"status"`
|
||||
Remarks *string `json:"remarks,omitempty"`
|
||||
ActedAt *time.Time `json:"acted_at,omitempty"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
|
||||
// Relations
|
||||
Letter *LetterOutgoing `gorm:"foreignKey:LetterID" json:"letter,omitempty"`
|
||||
Step *ApprovalFlowStep `gorm:"foreignKey:StepID" json:"step,omitempty"`
|
||||
Approver *User `gorm:"foreignKey:ApproverID" json:"approver,omitempty"`
|
||||
}
|
||||
|
||||
func (LetterOutgoingApproval) TableName() string { return "letter_outgoing_approvals" }
|
||||
@@ -0,0 +1,105 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type LetterOutgoingStatus string
|
||||
|
||||
const (
|
||||
LetterOutgoingStatusDraft LetterOutgoingStatus = "draft"
|
||||
LetterOutgoingStatusPendingApproval LetterOutgoingStatus = "pending_approval"
|
||||
LetterOutgoingStatusApproved LetterOutgoingStatus = "approved"
|
||||
LetterOutgoingStatusSent LetterOutgoingStatus = "sent"
|
||||
LetterOutgoingStatusArchived LetterOutgoingStatus = "archived"
|
||||
)
|
||||
|
||||
type LetterOutgoing struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
LetterNumber string `gorm:"uniqueIndex;not null" json:"letter_number"`
|
||||
ReferenceNumber *string `json:"reference_number,omitempty"`
|
||||
Subject string `gorm:"not null" json:"subject"`
|
||||
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"`
|
||||
Status LetterOutgoingStatus `gorm:"not null;default:'draft'" json:"status"`
|
||||
ApprovalFlowID *uuid.UUID `json:"approval_flow_id,omitempty"`
|
||||
CreatedBy uuid.UUID `gorm:"not null" json:"created_by"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
DeletedAt *time.Time `gorm:"index" json:"deleted_at,omitempty"`
|
||||
|
||||
// Relations
|
||||
Priority *Priority `gorm:"foreignKey:PriorityID" json:"priority,omitempty"`
|
||||
ReceiverInstitution *Institution `gorm:"foreignKey:ReceiverInstitutionID" json:"receiver_institution,omitempty"`
|
||||
Creator *User `gorm:"foreignKey:CreatedBy" json:"creator,omitempty"`
|
||||
ApprovalFlow *ApprovalFlow `gorm:"foreignKey:ApprovalFlowID" json:"approval_flow,omitempty"`
|
||||
Recipients []LetterOutgoingRecipient `gorm:"foreignKey:LetterID" json:"recipients,omitempty"`
|
||||
Attachments []LetterOutgoingAttachment `gorm:"foreignKey:LetterID" json:"attachments,omitempty"`
|
||||
Approvals []LetterOutgoingApproval `gorm:"foreignKey:LetterID" json:"approvals,omitempty"`
|
||||
Discussions []LetterOutgoingDiscussion `gorm:"foreignKey:LetterID" json:"discussions,omitempty"`
|
||||
ActivityLogs []LetterOutgoingActivityLog `gorm:"foreignKey:LetterID" json:"activity_logs,omitempty"`
|
||||
}
|
||||
|
||||
func (LetterOutgoing) TableName() string { return "letters_outgoing" }
|
||||
|
||||
type LetterOutgoingRecipient struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
LetterID uuid.UUID `gorm:"type:uuid;not null" json:"letter_id"`
|
||||
RecipientName string `gorm:"not null" json:"recipient_name"`
|
||||
RecipientEmail *string `json:"recipient_email,omitempty"`
|
||||
RecipientPosition *string `json:"recipient_position,omitempty"`
|
||||
RecipientInstitution *string `json:"recipient_institution,omitempty"`
|
||||
IsPrimary bool `gorm:"default:false" json:"is_primary"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
}
|
||||
|
||||
func (LetterOutgoingRecipient) TableName() string { return "letter_outgoing_recipients" }
|
||||
|
||||
type LetterOutgoingAttachment struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
LetterID uuid.UUID `gorm:"type:uuid;not null" json:"letter_id"`
|
||||
FileURL string `gorm:"not null" json:"file_url"`
|
||||
FileName string `gorm:"not null" json:"file_name"`
|
||||
FileType string `gorm:"not null" json:"file_type"`
|
||||
UploadedBy *uuid.UUID `json:"uploaded_by,omitempty"`
|
||||
UploadedAt time.Time `gorm:"autoCreateTime" json:"uploaded_at"`
|
||||
}
|
||||
|
||||
func (LetterOutgoingAttachment) TableName() string { return "letter_outgoing_attachments" }
|
||||
|
||||
type LetterOutgoingDiscussion struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
LetterID uuid.UUID `gorm:"type:uuid;not null" json:"letter_id"`
|
||||
ParentID *uuid.UUID `json:"parent_id,omitempty"`
|
||||
UserID uuid.UUID `gorm:"not null" json:"user_id"`
|
||||
Message string `gorm:"not null" json:"message"`
|
||||
Mentions JSONB `gorm:"type:jsonb" json:"mentions,omitempty"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
EditedAt *time.Time `json:"edited_at,omitempty"`
|
||||
|
||||
// Relations
|
||||
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
||||
Attachments []LetterOutgoingDiscussionAttachment `gorm:"foreignKey:DiscussionID" json:"attachments,omitempty"`
|
||||
Replies []LetterOutgoingDiscussion `gorm:"foreignKey:ParentID" json:"replies,omitempty"`
|
||||
}
|
||||
|
||||
func (LetterOutgoingDiscussion) TableName() string { return "letter_outgoing_discussions" }
|
||||
|
||||
type LetterOutgoingDiscussionAttachment struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
DiscussionID uuid.UUID `gorm:"type:uuid;not null" json:"discussion_id"`
|
||||
FileURL string `gorm:"not null" json:"file_url"`
|
||||
FileName string `gorm:"not null" json:"file_name"`
|
||||
FileType string `gorm:"not null" json:"file_type"`
|
||||
UploadedBy *uuid.UUID `json:"uploaded_by,omitempty"`
|
||||
UploadedAt time.Time `gorm:"autoCreateTime" json:"uploaded_at"`
|
||||
}
|
||||
|
||||
func (LetterOutgoingDiscussionAttachment) TableName() string {
|
||||
return "letter_outgoing_discussion_attachments"
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type LetterOutgoingActivityLog struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
LetterID uuid.UUID `gorm:"type:uuid;not null" json:"letter_id"`
|
||||
ActionType string `gorm:"not null" json:"action_type"`
|
||||
ActorUserID *uuid.UUID `json:"actor_user_id,omitempty"`
|
||||
ActorDepartmentID *uuid.UUID `json:"actor_department_id,omitempty"`
|
||||
TargetType *string `json:"target_type,omitempty"`
|
||||
TargetID *uuid.UUID `json:"target_id,omitempty"`
|
||||
FromStatus *string `json:"from_status,omitempty"`
|
||||
ToStatus *string `json:"to_status,omitempty"`
|
||||
Context JSONB `gorm:"type:jsonb" json:"context,omitempty"`
|
||||
OccurredAt time.Time `gorm:"autoCreateTime" json:"occurred_at"`
|
||||
|
||||
// Relations
|
||||
Letter *LetterOutgoing `gorm:"foreignKey:LetterID" json:"letter,omitempty"`
|
||||
ActorUser *User `gorm:"foreignKey:ActorUserID" json:"actor_user,omitempty"`
|
||||
ActorDepartment *Department `gorm:"foreignKey:ActorDepartmentID" json:"actor_department,omitempty"`
|
||||
}
|
||||
|
||||
func (LetterOutgoingActivityLog) TableName() string { return "letter_outgoing_activity_logs" }
|
||||
|
||||
// Action types for letter outgoing activity logs
|
||||
const (
|
||||
LetterOutgoingActionCreated = "created"
|
||||
LetterOutgoingActionUpdated = "updated"
|
||||
LetterOutgoingActionDeleted = "deleted"
|
||||
LetterOutgoingActionStatusChanged = "status_changed"
|
||||
LetterOutgoingActionSubmittedApproval = "submitted_for_approval"
|
||||
LetterOutgoingActionApproved = "approved"
|
||||
LetterOutgoingActionRejected = "rejected"
|
||||
LetterOutgoingActionSent = "sent"
|
||||
LetterOutgoingActionArchived = "archived"
|
||||
LetterOutgoingActionAttachmentAdded = "attachment_added"
|
||||
LetterOutgoingActionAttachmentRemoved = "attachment_removed"
|
||||
LetterOutgoingActionRecipientAdded = "recipient_added"
|
||||
LetterOutgoingActionRecipientRemoved = "recipient_removed"
|
||||
LetterOutgoingActionDiscussionAdded = "discussion_added"
|
||||
)
|
||||
Reference in New Issue
Block a user