forked from ebhomengo/niki
entity added for donate pr
This commit is contained in:
parent
af9918a0c8
commit
c6210967af
|
|
@ -1 +0,0 @@
|
||||||
package service
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// --- Type Aliases ---
|
||||||
|
|
||||||
|
// UserID is a type alias for clarity, representing foreign keys to the User service
|
||||||
|
type UserID uint32
|
||||||
|
|
||||||
|
// TransactionID is a type alias for clarity, representing foreign keys to the Transaction service
|
||||||
|
type TransactionID uint32
|
||||||
|
|
||||||
|
// CampaignID is a type alias for clarity, representing primary keys for Campaigns
|
||||||
|
type CampaignID uint32
|
||||||
|
|
||||||
|
// DonationID is a type alias for clarity, representing primary keys for Donations
|
||||||
|
type DonationID uint32
|
||||||
|
|
||||||
|
// --- Campaign Module Entities ---
|
||||||
|
|
||||||
|
// CampaignStatus represents the possible states of a campaign
|
||||||
|
type CampaignStatus string
|
||||||
|
|
||||||
|
const (
|
||||||
|
StatusActive CampaignStatus = "active"
|
||||||
|
StatusCompleted CampaignStatus = "completed"
|
||||||
|
StatusCancelled CampaignStatus = "cancelled"
|
||||||
|
StatusExpired CampaignStatus = "expired" // New status for deadlines
|
||||||
|
)
|
||||||
|
|
||||||
|
// Campaign represents a fundraising campaign entity
|
||||||
|
type Campaign struct {
|
||||||
|
ID CampaignID `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
GoalAmount float64 `json:"goal_amount"` // Using float64 for decimal, consider using a dedicated decimal type for precision
|
||||||
|
RaisedAmount float64 `json:"raised_amount"`
|
||||||
|
Status CampaignStatus `json:"status"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
DeadlineAt *time.Time `json:"deadline_at,omitempty"` // Pointer to time.Time, allows nil for no deadline. omitempty hides if nil.
|
||||||
|
AdminID UserID `json:"admin_id"` // Foreign Key to User service
|
||||||
|
InitiatedByUserID *UserID `json:"initiated_by_user_id,omitempty"` // Pointer to UserID, allows nil. omitempty hides if nil.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// DonationLevel represents the level of a donation (e.g., Bronze, Silver, Gold)
|
||||||
|
type DonationLevel string
|
||||||
|
|
||||||
|
const (
|
||||||
|
DonationLevelBronze DonationLevel = "Bronze"
|
||||||
|
DonationLevelSilver DonationLevel = "Silver"
|
||||||
|
DonationLevelGold DonationLevel = "Gold"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Donation represents a donation made to a campaign
|
||||||
|
type Donation struct {
|
||||||
|
ID DonationID `json:"id"`
|
||||||
|
UserID UserID `json:"user_id"` // Foreign Key to User service
|
||||||
|
CampaignID CampaignID `json:"campaign_id"` // Foreign Key to Campaign
|
||||||
|
Amount float64 `json:"amount"` // Using float64 for decimal, consider a dedicated decimal type
|
||||||
|
PointsEarned int `json:"points_earned"` // امتیازی که از این تراکنش خاص کسب شده
|
||||||
|
TransactionID TransactionID `json:"transaction_id"` // Foreign Key to Transaction service
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
DonationLevel *DonationLevel `json:"donation_level,omitempty"` // Pointer to DonationLevel, allows nil. omitempty hides if nil.
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue