Created
June 29, 2016 20:10
-
-
Save natdm/8417af9005dcb8bf94964f728d65b68f to your computer and use it in GitHub Desktop.
Testing Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package database | |
import ( | |
"database/sql" | |
"time" | |
"github.com/lib/pq" | |
) | |
// DBUser is the main DB User | |
// TODO: Needs created timestamp. | |
// TODO: Needs Last Attempt timestamp. | |
type ( | |
DBUser struct { | |
UID int `json:"uid"` | |
Email string `json:"email"` | |
FName string `json:"fname"` | |
LName string `json:"lname"` | |
Password string `json:"password"` | |
Number int `json:"number"` | |
Attempts int `json:"attempts"` | |
Verified bool `json:"verified"` | |
Key string `json:"key"` //The JWT api key, strictly for the client. | |
BillingAccount sql.NullString `json:"billing_account"` | |
} | |
//DBEvent is the event information to be pulled from the user. | |
//Note: the dates and times are string format, need to be for insert | |
DBEvent struct { | |
EventKey string `json:"event_key"` //At first, generated by generateRandomKey(). | |
EventID int `json:"event_id"` | |
Name string `json:"name"` | |
Description string `json:"description"` | |
Website string `json:"website"` | |
AddressID int `json:"address_id"` | |
StartDate string `json:"start_date"` | |
EndDate string `json:"end_date"` | |
ContactID int `json:"contact_id"` | |
EventType int `json:"event_type"` | |
MaxBid bool `json:"max_bid"` | |
BuyNow bool `json:"buy_now"` | |
ImagePath string `json:"image_path"` | |
CharityImage string `json:"charity_image"` | |
CharityURL string `json:"charity_url"` | |
} | |
//DBEvent is the event information | |
//Note: the dates and times are time.time format, need to be for the sql.Scan | |
DBEventPull struct { | |
EventKey string `json:"event_key"` | |
EventID int `json:"event_id"` | |
Name string `json:"name"` | |
Description string `json:"description"` | |
Website string `json:"website"` | |
AddressID int `json:"address_id"` | |
StartDate time.Time `json:"start_date"` | |
EndDate time.Time `json:"end_date"` | |
ContactID int `json:"contact_id"` | |
EventType int `json:"event_type"` | |
MaxBid bool `json:"max_bid"` | |
BuyNow bool `json:"buy_now"` | |
ImagePath sql.NullString `json:"image_path"` | |
CharityImage sql.NullString `json:"charity_image"` | |
CharityURL sql.NullString `json:"charity_url"` | |
} | |
DBItemBiddable struct { | |
EventID int `json:"event_id"` | |
EventType int `json:"event_type"` | |
StartDate time.Time `json:"start_date"` | |
EndDate time.Time `json:"end_date"` | |
} | |
//DBContact is contact information, generic | |
DBContact struct { | |
ContactID int `json:"contact_id"` | |
Fname string `json:"fname"` | |
Lname string `json:"lname"` | |
Email string `json:"email"` | |
Number int `json:"number"` | |
} | |
//DBAddress is address information, generic. | |
DBAddress struct { | |
AddressID int `json:"address_id"` | |
Street string `json:"street"` | |
City string `json:"city"` | |
State string `json:"state"` | |
Zip int `json:"zip"` | |
} | |
DBEventContactAddress struct { | |
Event DBEventPull `json:"event"` | |
Contact DBContact `json:"contact"` | |
Address DBAddress `json:"address"` | |
} | |
DBEventContactAddressItems struct { | |
Event DBEventPull `json:"event"` | |
Contact DBContact `json:"contact"` | |
Address DBAddress `json:"address"` | |
Items []DBBidItem `json:"items"` | |
DBEventType DBEventType `json:"dbeventtype"` | |
ImagePath string `json:"image_path"` | |
} | |
EventAndItems struct { | |
EventDetails DBEventContactAddress `json:"event_details"` //Holds event details | |
Items []DBBidItem `json:"items"` //Holds all items for event | |
Watching []DBWatching `json:"watching"` //Holds all items being watched. | |
Open bool `json:"open"` //If the event is open to bidding. Should depend on open/closed time. | |
} | |
//Gets the watched item list. Does not include event ID - this is pulled by event_id, so it should be | |
// assumed they're all for that event. | |
DBWatching struct { | |
Bidder int `json:"bidder"` | |
ItemID int `json:"item_id"` | |
Watching bool `json:"watching"` | |
EventID int `json:"event_id"` | |
} | |
CurrentHighestBid struct { | |
ItemID int `json:"item_id"` | |
Bidder int `json:"bidder"` | |
Timestamp time.Time `json:"timestamp"` | |
} | |
Notification struct { | |
NoteID int `json:"note_id"` | |
BidderID int `json:"bidder"` | |
ItemID int `json:"item_id"` | |
EventID int `json:"event_id"` | |
Message string `json:"message"` | |
Read bool `json:"read"` | |
Timestamp time.Time `json:"timestamp"` | |
} | |
EventContactAddress struct { | |
UserID int `json:"user_id"` | |
Event DBEvent `json:"event"` | |
Contact DBContact `json:"contact"` | |
Address DBAddress `json:"address"` | |
} | |
DBEventType struct { | |
TypeID int `json:"type_id"` | |
Name string `json:"name"` | |
Description string `json:"description"` | |
} | |
DBBidItem struct { | |
ItemID int `json:"item_id"` | |
EventID int `json:"event_id"` | |
Name string `json:"name"` | |
Description string `json:"description"` | |
Sponsor string `json:"sponsor"` //I think I'm calling this sponsor here.. but then charity_url... then sponsor_website.. TODO: Fix this. | |
StartingBid int `json:"starting_bid"` | |
BidIncrement int `json:"bid_increment"` | |
CurrentBid sql.NullInt64 `json:"current_bid"` | |
LastBidder sql.NullInt64 `json:"last_bidder"` //Email address of last bidder | |
BidAmount sql.NullInt64 `json:"bid_amount"` //Bid amount of the last bidders bid | |
BidID sql.NullInt64 `json:"bid_id"` //Key of the bid in the DB table | |
Bid sql.NullInt64 `json:"bid"` //Key of the bid in the DB table | |
BidTimestamp pq.NullTime `json:"bid_timestamp"` //Last Bid Timestamp date/time | |
Value sql.NullInt64 `json:"value"` | |
BuyNow bool `json:"buy_now"` | |
BuyNowAmount int `json:"buy_now_amount"` | |
ImagePath sql.NullString `json:"image_path"` | |
IconPath sql.NullString `json:"icon_path"` | |
CharityURL sql.NullString `json:"charity_url"` | |
SponsorWebsite sql.NullString `json:"sponsor_website"` | |
} | |
BidItemWithUserId struct { | |
ItemID int `json:"item_id"` | |
EventID int `json:"event_id"` | |
Name string `json:"name"` | |
Description string `json:"description"` | |
Sponsor string `json:"sponsor"` | |
StartingBid int `json:"starting_bid"` | |
BidIncrement int `json:"bid_increment"` | |
UserID int `json:"user_id"` | |
Value int `json:"value"` | |
BuyNow bool `json:"buy_now"` | |
BuyNowAmount int `json:"buy_now_amount"` | |
ItemImage string `json:"item_image"` | |
ItemIcon string `json:"item_icon"` | |
SponsorWebsite string `json:"sponsor_website"` | |
} | |
NewBid struct { | |
ItemID int `json:"item_id"` | |
Bidder int `json:"bidder"` | |
Bid int `json:"bid"` | |
UserID int `json:"user_id"` | |
} | |
NewBidderBid struct { | |
ItemID int `json:"item_id"` | |
Bidder int `json:"bidder"` | |
Bid int `json:"bid"` | |
UID int `json:"uid"` | |
EventID int `json:"event_id"` | |
Key string `json:"key"` | |
} | |
DBBid struct { | |
ItemID int `json:"item_id"` | |
Bidder int `json:"bidder"` | |
Bid int `json:"bid"` | |
} | |
LogBidRow struct { | |
BidID sql.NullInt64 `json:"bid_id"` //Key of the bid in the DB table | |
ItemID int `json:"item_id"` | |
ItemName string `json:"item_name"` | |
EventID int `json:"event_id"` | |
Bidder int `json:"bidder"` | |
Bid int `json:"bid"` | |
BidTimestamp pq.NullTime `json:"bid_timestamp"` //Last Bid Timestamp date/time | |
} | |
Signup struct { | |
Email string `json:"email"` | |
Password string `json:"password"` | |
Password2 string `json:"password2"` | |
} | |
Bidder struct { | |
BidderID int `json:"bidder_id"` | |
Phone sql.NullInt64 `json:"phone"` | |
Email string `json:"email"` | |
} | |
//StartEndDate carries the start and end times and dates of an event. | |
StartEndDate struct { | |
StartDate time.Time `json:"start_date"` | |
EndDate time.Time `json:"end_date"` | |
} | |
//CardToken is the struct for the Stripe Card Token | |
CardToken struct { | |
UserID int `json:"user_id"` | |
Token struct { | |
TokenID string `json:"id"` | |
Card struct { | |
ID string `json:"id"` | |
Brand string `json:"brand"` | |
Country string `json:"country"` | |
Funding string `json:"funding"` | |
Last4 string `json:"last4"` | |
Name string `json:"name"` | |
ExpMonth int `json:"exp_month"` | |
ExpYear int `json:"exp_year"` | |
} `json:"card"` | |
} `json:"token"` | |
} | |
//Transaction holds everything necessary for a transaction from the bidder, through | |
// the app to the user. | |
Transaction struct { | |
TransID string `json:"id"` | |
UserID int `json:"user_id"` | |
BidderID int `json:"bidder_id"` | |
EventID int `json:"event_id"` | |
Amount int64 `json:"amount"` | |
AppFee int64 `json:"application_fee"` | |
Desc string `json:"description"` | |
Last4 int `json:"last4"` | |
ExpMonth int `json:"exp_month"` | |
ExpYear int `json:"exp_year"` | |
Funding string `json:"funding"` | |
Name string `json:"name"` | |
Status string `json:"status"` | |
} | |
//TransactionLine is attached to a transaction | |
TransactionLine struct { | |
OrderID int | |
ItemID int | |
Amount uint64 | |
Line int | |
} | |
//CardDetails is the basic credit card details for a user. | |
CardDetails struct { | |
Last4 int `json:"last4"` | |
ExpMonth int `json:"exp_month"` | |
ExpYear int `json:"exp_year"` | |
Funding string `json:"funding"` | |
Name string `json:"name"` | |
Brand string `json:"brand"` | |
Country string `json:"country"` | |
} | |
//AuthUser combines Auth0 login credentials and data required | |
// by the application. | |
AuthUser struct { | |
UserID int `json:"user_id"` | |
AuthID string `json:"auth_id"` | |
Email string `json:"email"` | |
OptInEmail bool `json:"opt_in_email"` | |
Phone int `json:"phone"` | |
OptInPhone bool `json:"opt_in_phone"` | |
OptInNotified bool `json:"opt_in_notified"` | |
Card Card `json:"card"` | |
CCWarning bool `json:"cc_warning"` | |
} | |
Card struct { | |
Details CardDetails `json:"details"` | |
Valid bool `json:"valid"` | |
} | |
//ItemWon is an item won by a bidder | |
ItemWon struct { | |
ItemID int `json:"item_id"` | |
Bid int `json:"bid"` | |
BidderID int `json:"bidder_id"` | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment