Documentation
¶
Index ¶
- func AddNewUsr(input NewUsrInput, coredb *gorm.DB) (string, error)
- func CheckDuplicate(phone string, username string, user User, coredb *gorm.DB) (map[string]bool, error)
- func CheckPasswordHash(password string, hash string) bool
- func DecodeJwt(token string) (*jwt.Token, error)
- func GenerateJwt(userID string, expiredAt int64) string
- func HashPassword(password string) (string, error)
- func JwtMiddleware() func(http.Handler) http.Handler
- func TokenFromHTTPRequestgo(r *http.Request) string
- func UserIDFromHTTPRequestgo(tokenString string) string
- type Address
- type AuthResult
- type Beverages
- type Booking
- type BookingCoverPic
- type BookingOffer
- type BookingOfferPics
- type BookingOrder
- type BookingOrderDraft
- type BookingTag
- type Chatroom
- type Comment
- type Country
- type Currency
- type DeviceDataInput
- type Devices
- type EventPromotionPic
- type EventTicketPurchaseOrder
- type Events
- type HashTag
- type Ingredients
- type InstantMessage
- type InstatntMessage
- type Invitation
- type ItemCategory
- type Like
- type Menu
- type MenuItem
- type MenuOrder
- type MenuOrderDraft
- type MenuType
- type Message
- type NewUsrInput
- type NotificationChannel
- type Notifications
- type Place
- type PlacePic
- type PlaceType
- type Post
- type PostImages
- type Pricing
- type ProductPurchaseOrder
- type ProductPurchaseOrderDraft
- type ProductSales
- type ProductSalesType
- type ProductSalesTypeImage
- type Profile
- type ProfileStarterInput
- type ProfileUpdateResult
- type PromotionalPosts
- type ServiceProvider
- type TimedLabel
- type User
- type UserAuth
- type UserCircle
- type UserClaims
- type UserTravel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckDuplicate ¶
func CheckPasswordHash ¶
func HashPassword ¶
func JwtMiddleware ¶
JwtMiddleware middleware for http server
func TokenFromHTTPRequestgo ¶
TokenFromHTTPRequestgo - get jwt token from request
func UserIDFromHTTPRequestgo ¶
UserIDFromHTTPRequestgo - get user id from request
Types ¶
type Address ¶
type Address struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` // TODO make sure city and country matches City string CountryId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` Country Country `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` }
type AuthResult ¶
func EmailAuthLogin ¶
type Booking ¶
type Booking struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` BookingName string CoverPic []BookingCoverPic `gorm:"polymorphic:Owner"` BookingOffers []BookingOffer `gorm:"polymorphic:Owner"` ServiceProviderId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` ServiceProvider ServiceProvider `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` }
type BookingCoverPic ¶
type BookingOffer ¶
type BookingOffer struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` ServiceTitle string ServiceDescription string Pricings []Pricing `gorm:"polymorphic:Owner"` Pics []BookingOfferPics `gorm:"polymorphic:Owner"` OwnerID string OwnerType string }
type BookingOfferPics ¶
type BookingOrder ¶
type BookingOrder struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` BookingOrderDraftId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` BookingOrderDraft BookingOrderDraft `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` // Booking draft orderer UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` // Important manage order status and udpate detail OrderStatus string }
type BookingOrderDraft ¶
type BookingOrderDraft struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` // booking draft manager UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` BookingId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` Booking Booking `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` BookingOfferId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` BookingOffer BookingOffer `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` InvitationId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` Invitation Invitation `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` Complete bool Removed bool }
type BookingTag ¶
type Comment ¶
type Comment struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` Comment string PostId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` Post Post `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` ParentComment string }
Comments section with a recursive setup
type DeviceDataInput ¶
type EventPromotionPic ¶
type EventTicketPurchaseOrder ¶
type EventTicketPurchaseOrder struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` // booking draft manager UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` EventID string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` Event Events `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` Complete bool Removed bool }
type Events ¶
type Events struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` EventType string EventName string EventDescription string EventPrice int FreeEvent bool EventPromotionPics []EventPromotionPic `gorm:"polymorphic:Owner"` MaxInvitations int AddressId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` Address Address `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` Closed bool EventDate time.Time }
type Ingredients ¶
type InstantMessage ¶
type InstatntMessage ¶
type Invitation ¶
type Invitation struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` CircleInvitation bool // add single circle for invitation CircleId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` Circle UserCircle `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` }
type ItemCategory ¶
type Like ¶
type Like struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` OwnerID string OwnerType string }
type Menu ¶
type Menu struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` Name string MenuTypeId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` MenuType MenuType `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` MenuItem []MenuItem `gorm:"polymorphic:Owner"` Beverages []Beverages `gorm:"polymorphic:Owner"` // Sp added to menu directly ServiceProviderId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` ServiceProvider ServiceProvider `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` }
type MenuItem ¶
type MenuItem struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` ItemTitle string Price int Image string ItemCategoryId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` ItemCategory Post `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` InstantlyMade bool Description string Ingredients []Ingredients `gorm:"polymorphic:Owner"` ItemType string OwnerID string OwnerType string }
type MenuOrder ¶
type MenuOrder struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` MenuOrderDraftId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` MenuOrderDraft MenuOrderDraft `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` // Booking draft orderer UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` // Important manage order status and udpate detail OrderStatus string }
type MenuOrderDraft ¶
type MenuOrderDraft struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` // booking draft manager UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` MenuId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` Menu Menu `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` MenuItemId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` MenuItem MenuItem `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` InvitationId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` Invitation Invitation `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` Complete bool Removed bool }
type NewUsrInput ¶
type NewUsrInput struct { Email string `json:"email"` Password string `json:"password"` DeviceInput *DeviceDataInput `json:"deviceInput"` }
type NotificationChannel ¶
type Notifications ¶
type Place ¶
type Place struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` PlaceTypeId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` PlaceType PlaceType `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` AdminOrigin bool ServiceProviderId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` ServiceProvider ServiceProvider `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` PlacePics []PlacePic `gorm:"polymorphic:Owner"` }
type Post ¶
type Post struct { // TODO Add place Foreign key model here ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` Caption string UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` PostImages []PostImages `gorm:"polymorphic:Owner"` PostLikes []Like `gorm:"polymorphic:Owner"` Approved bool IsDrafted bool HashTags []HashTag `gorm:"polymorphic:Owner"` Promotional bool ServiceProviderId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` ServiceProvider ServiceProvider `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` }
main posts model
type PostImages ¶
type PostImages struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` PostImage string OwnerID string OwnerType string }
Posts images multiple relation with post
type Pricing ¶
type Pricing struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` OwnerID string OwnerType string // Label is for the timestamp detail of the pricing Label string Price string ComparingPrice string Timed bool TimedLabelId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` TimedLabel TimedLabel `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` }
type ProductPurchaseOrder ¶
type ProductPurchaseOrder struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` ProductPurchaseOrderDraftId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` ProductPurchaseOrderDraft ProductPurchaseOrderDraft `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` // Booking draft orderer UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` // Important manage order status and udpate detail OrderStatus string }
type ProductPurchaseOrderDraft ¶
type ProductPurchaseOrderDraft struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` // booking draft manager UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` ProductSalesId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` ProductSales ProductSales `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` Complete bool Removed bool }
type ProductSales ¶
type ProductSales struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` ProductSalesTypeId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` ProductSalesType ProductSalesType `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` Images []ProductSalesTypeImage `gorm:"polymorphic:Owner"` SellingPrice int ListingPrice int CurrencyId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` Currency Currency `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` IsAvailable bool Quantity int ServiceProviderId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` ServiceProvider ServiceProvider `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` }
type ProductSalesType ¶
type ProductSalesTypeImage ¶
type Profile ¶
type Profile struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` Name string `gorm:"column:name;size:128;not null;"` Username string `gorm:"uniqueIndex,unique"` Phone string `gorm:"uniqueIndex,unique"` ProfilePic string Complete bool Progress int Bio string }
Profile is the model for the profile table.
type ProfileStarterInput ¶
type ProfileUpdateResult ¶
func ProfileMessages ¶
func ProfileMessages(messageType string, message string) ProfileUpdateResult
func UpdateUserProfile ¶
func UpdateUserProfile(coredb *gorm.DB, user User, input ProfileStarterInput) (ProfileUpdateResult, error)
type PromotionalPosts ¶
type PromotionalPosts struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` PostId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` Post Post `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` ServiceProviderId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` ServiceProvider ServiceProvider `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` Featured bool }
type ServiceProvider ¶
type ServiceProvider struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` Phone string SpID string `gorm:"unique"` SpType string Email string `gorm:"unique"` BusinessName string AddressId string `gorm:"UNIQUE_INDEX:compositeindex;index;not null"` Address Address `gorm:"UNIQUE_INDEX:compositeindex;type:text;not null"` BusinessPhone string `gorm:"unique"` BusinessDescription string IsVerified bool AccountAppoved bool }
type TimedLabel ¶
type User ¶
type User struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` SomeFlag bool `gorm:"column:some_flag;not null;default:true"` // main content goes here Email string `gorm:"uniqueIndex,unique"` Password string ProfileId string Profile Profile IsVerified bool Qrcode string // UserDevices []Devices `gorm:"many2many:devices;" json:"devices,omitempty"` UserDevices []Devices `gorm:"polymorphic:Owner"` OwnerID string OwnerType string }
type UserAuth ¶
UserAuth - user auth middleware structure
func GetAuthFromContext ¶
GetAuthFromContext - Gets context
type UserCircle ¶
type UserCircle struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` CircleName string Users []User `gorm:"polymorphic:Owner"` UserId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` User User `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` Removed bool OwnerID string OwnerType string }
type UserClaims ¶
type UserClaims struct { UserID string `json:"id"` jwt.StandardClaims }
UserClaims for jwt
type UserTravel ¶
type UserTravel struct { ID string `gorm:"type:char(36);primary_key"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` // TODO complete User travel setup OrderTravel bool BookingOrderId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` BookingOrder BookingOrder `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` MenuOrderId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` MenuOrder MenuOrder `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` ProductPurchaseOrderId string `gorm:"UNIQUE_INDEX:compositeindex;index;null"` ProductPurchaseOrder ProductPurchaseOrder `gorm:"UNIQUE_INDEX:compositeindex;type:text;null"` TravelStatus string }
Click to show internal directories.
Click to hide internal directories.