models

package
v0.0.0-...-b412a5c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APPLICATION_NAME = "Lesgo"
View Source
var C *cache.Cache
View Source
var DATASET string
View Source
var Db *gorm.DB
View Source
var GOOGLE_APPLICATION_CREDENTIALS_FILE string
View Source
var JWT_SIGNATURE_KEY = []byte("15 besar")
View Source
var JWT_SIGNING_METHOD = jwt.SigningMethodHS256
View Source
var LOGIN_EXPIRATION_DURATION = 7 * 24 * time.Hour
View Source
var PROJECT_ID string

Functions

func ConnectBq

func ConnectBq(projectId string, dataset string, googlecredentialfile string)

func ConnectDatabase

func ConnectDatabase(dbUser string, dbPwd string, dbName string, dbTCPHost string, dbPort string) (*gorm.DB, error)

func SetupCache

func SetupCache() *cache.Cache

Types

type ClaimsJWT

type ClaimsJWT struct {
	jwt.RegisteredClaims
	Username string `json:"username"`
}

type Journey

type Journey struct {
	JourneyID         string    `json:"journeyId" gorm:"primaryKey"`
	UserID            string    `json:"userId" binding:"required" FK`
	StartTime         time.Time `json:"startTime" binding:"required"`
	FinishTime        time.Time `json:"finishTime" binding:"required"`
	Origin            string    `json:"origin" binding:"required"`
	Destination       string    `json:"destination" binding:"required"`
	DistanceTravelled float64   `json:"distanceTravelled" binding:"required"`
	EmissionSaved     float64   `json:"emissionSaved" binding:"required"`
	Reward            int       `json:"reward" binding:"required"`
}

func (*Journey) BeforeCreate

func (journey *Journey) BeforeCreate(tx *gorm.DB) error

type Partner

type Partner struct {
	PartnerID   string    `json:"partnerId" gorm:"primaryKey"`
	PartnerName string    `json:"partnerName" binding:"required"`
	Email       string    `json:"email" gorm:"unique" binding:"required"`
	Username    string    `json:"username" gorm:"unique" binding:"required"`
	Password    string    `json:"password" binding:"required"`
	Vouchers    []Voucher `gorm:"foreignKey:PartnerID;references:PartnerID"`
}

func (*Partner) BeforeCreate

func (partner *Partner) BeforeCreate(tx *gorm.DB) error

type PartnerLogin

type PartnerLogin struct {
	Email    string `gorm:"unique" json:"email"`
	Username string `gorm:"unique" json:"username"`
	Password string `json:"password" binding:"required"`
}

type Purchase

type Purchase struct {
	PurchaseID  string    `json:"purchaseId" gorm:"primaryKey"`
	VoucherID   string    `json:"voucherId"`
	UserID      string    `json:"userId"`
	BuyDate     time.Time `json:"buyDate" binding:"required"`
	BuyQuantity int       `json:"buyQuantity" binding:"required"`
}

func (*Purchase) BeforeCreate

func (purchase *Purchase) BeforeCreate(tx *gorm.DB) error

type PurchaseReceipt

type PurchaseReceipt struct {
	Purchase
	VoucherStockRemaining int `json:"voucherStockRemaining"`
	UserPointsRemaining   int `json:"userPointsRemaining"`
}

type RowType

type RowType struct {
	Forecast_hour          int
	Forecasted_temperature float32
	Forecasted_uv          float32
	Forecasted_pm25        float32
	City                   string
}

func GetQuery

func GetQuery(query string) []RowType

type TokenRefresh

type TokenRefresh struct {
	Token string `json:"token"`
}

type User

type User struct {
	UserID          string    `json:"userId" gorm:"primaryKey"`
	Email           string    `json:"email" gorm:"unique" binding:"required"`
	Username        string    `json:"username" gorm:"unique" binding:"required"`
	Password        string    `json:"password" binding:"required"`
	FirstName       string    `json:"firstName" binding:"required"`
	LastName        string    `json:"lastName" binding:"required"`
	BirthDate       time.Time `json:"birthDate" binding:"required"`
	Age             int       `json:"age"`
	Gender          string    `json:"gender" gorm:"default:null"`
	Job             string    `json:"job" gorm:"default:null"`
	Points          int       `json:"points" gorm:"default:0"`
	VoucherInterest string    `json:"voucherInterest" gorm:"default:null"`
	Domicile        string    `json:"domicile" gorm:"default:null"`
	Education       string    `json:"education" gorm:"default:null"`
	MarriageStatus  bool      `json:"marriageStatus" gorm:"default:null"`
	Income          int       `json:"income" gorm:"default:0"`
	Vehicle         string    `json:"vehicle" gorm:"default:null"`
	Journeys        []Journey `gorm:"foreignKey:UserID;references:UserID"`
}

func (*User) BeforeCreate

func (user *User) BeforeCreate(tx *gorm.DB) error

type UserLogin

type UserLogin struct {
	Email    string `gorm:"unique" json:"email"`
	Username string `gorm:"unique" json:"username"`
	Password string `json:"password" binding:"required"`
}

type UserUpdate

type UserUpdate struct {
	Job             string `json:"job" gorm:"default:null"`
	VoucherInterest string `json:"voucherInterest" gorm:"default:null"`
	Domicile        string `json:"domicile" gorm:"default:null"`
	Education       string `json:"education" gorm:"default:null"`
	MarriageStatus  bool   `json:"marriageStatus" gorm:"default:null"`
	Income          int    `json:"income" gorm:"default:0"`
	Vehicle         string `json:"vehicle" gorm:"default:null"`
	Gender          string `json:"gender" gorm:"default:null"`
}

type Voucher

type Voucher struct {
	VoucherID   string `json:"voucherId" gorm:"primaryKey"`
	PartnerID   string `json:"partnerId" binding:"required"`
	PartnerName string `json:"partnerName" binding:"required"`
	VoucherName string `json:"voucherName" binding:"required"`
	VoucherDesc string `json:"voucherDesc" binding:"required"`
	Category    string `json:"category" binding:"required"`
	ImageUrl    string `json:"imageUrl" default:"https://storage.googleapis.com/voucher-images-2909/jco.jpg"`
	Stock       int    `json:"stock" binding:"required"`
	Price       int    `json:"price" binding:"required"`
}

func (*Voucher) BeforeCreate

func (voucher *Voucher) BeforeCreate(tx *gorm.DB) error

type VoucherPurchased

type VoucherPurchased struct {
	gorm.Model
	VoucherID   string
	UserID      string
	IsPurchased bool    `default:"false"`
	Voucher     Voucher `gorm:"foreignKey:VoucherID;references:VoucherID"`
	User        User    `gorm:"foreignKey:UserID;references:UserID"`
}

func (*VoucherPurchased) BeforeCreate

func (voucherPurchased *VoucherPurchased) BeforeCreate(tx *gorm.DB) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL