Skip to content

Commit

Permalink
updating models
Browse files Browse the repository at this point in the history
  • Loading branch information
p-shubh committed Jun 26, 2024
1 parent f29a109 commit 3f88d06
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 50 deletions.
2 changes: 1 addition & 1 deletion db/db.connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Init() {

InitMigration(DB)

err = DB.AutoMigrate(&models.User{}, &models.Brand{}, &models.Collection{}, &models.Phygital{}, &models.WebXR{}, &models.Avatar{}, &models.Variant{})
err = DB.Debug().AutoMigrate(&models.User{}, &models.Brand{}, &models.Collection{}, &models.Phygital{}, &models.WebXR{}, &models.Avatar{}, &models.Variant{})
if err != nil {
log.Fatalf("failed to migrate database: %v", err)
}
Expand Down
22 changes: 11 additions & 11 deletions models/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import (
)

type Collection struct {
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
Name string `json:"name"`
Description string `json:"description"`
LogoImage string `json:"logo_image"`
CoverImage string `json:"cover_image"`
Category string `json:"category"`
Tags string `json:"tags"`
Status int `json:"status"`
BrandID string `json:"brand_id"`
CreatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"updated_at"`
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
Name string `json:"name"`
Description string `json:"description"`
LogoImage string `json:"logo_image"`
CoverImage string `json:"cover_image"`
Category map[string]interface{} `gorm:"type:jsonb" json:"category"`
Tags string `json:"tags"`
Status int `json:"status"`
BrandID string `json:"brand_id"`
CreatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"updated_at"`
}

func (c *Collection) BeforeCreate(tx *gorm.DB) (err error) {
Expand Down
50 changes: 25 additions & 25 deletions models/phygital.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ import (
)

type Phygital struct {
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
Name string `json:"name"`
BrandName string `json:"brand_name"`
Category string `json:"category"`
Description string `json:"description"`
Price int `json:"price"`
Quantity int `json:"quantity"`
Royality int `json:"royality"`
Image string `json:"image"`
ProductInfo string `json:"product_info"`
Color string `json:"color"`
Size string `json:"size"`
Weight int `json:"weight"`
Material string `json:"material"`
Usage string `json:"usage"`
Quality string `json:"quality"`
Manufacturer string `json:"manufacturer"`
OriginCountry string `json:"origin_country"`
MetadataURI string `json:"metadata_uri"`
DeployerAddress string `json:"deployer_address"`
ContractAddress string `json:"contract_address"`
GraphURL string `json:"graph_url"`
CollectionID uuid.UUID `json:"collection_id"`
CreatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"updated_at"`
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
Name string `json:"name"`
BrandName string `json:"brand_name"`
Category map[string]interface{} `gorm:"type:jsonb" json:"category"`
Description string `json:"description"`
Price int `json:"price"`
Quantity int `json:"quantity"`
Royality int `json:"royality"`
Image string `json:"image"`
ProductInfo string `json:"product_info"`
Color string `json:"color"`
Size string `json:"size"`
Weight int `json:"weight"`
Material string `json:"material"`
Usage string `json:"usage"`
Quality string `json:"quality"`
Manufacturer string `json:"manufacturer"`
OriginCountry string `json:"origin_country"`
MetadataURI string `json:"metadata_uri"`
DeployerAddress string `json:"deployer_address"`
ContractAddress string `json:"contract_address"`
GraphURL string `json:"graph_url"`
CollectionID uuid.UUID `json:"collection_id"`
CreatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"updated_at"`
}

func (p *Phygital) BeforeCreate(tx *gorm.DB) (err error) {
Expand Down
24 changes: 12 additions & 12 deletions models/webxr.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (
)

type WebXR struct {
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
Image360 string `json:"image360"`
Video360 string `json:"video360"`
RewardsMetadataURI string `json:"rewards_metadata_uri"`
Customizations string `json:"customizations"`
FreeNFTImage string `json:"free_nft_image"`
GoldReward string `json:"gold_reward"`
SilverReward string `json:"silver_reward"`
BronzeReward string `json:"bronze_reward"`
PhygitalID string `json:"phygital_id"`
CreatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"updated_at"`
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
Image360 string `json:"image360"`
Video360 string `json:"video360"`
RewardsMetadataURI string `json:"rewards_metadata_uri"`
Customizations map[string]interface{} `gorm:"type:jsonb" json:"category"`
FreeNFTImage string `json:"free_nft_image"`
GoldReward string `json:"gold_reward"`
SilverReward string `json:"silver_reward"`
BronzeReward string `json:"bronze_reward"`
PhygitalID string `json:"phygital_id"`
CreatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"updated_at"`
}

func (w *WebXR) BeforeCreate(tx *gorm.DB) (err error) {
Expand Down
8 changes: 7 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package server

import (
"os"

"app.myriadflow.com/controllers"
"app.myriadflow.com/middleware"
"github.com/gin-gonic/gin"
)

func Router() {
router := gin.Default()
gin.SetMode(gin.DebugMode)
if len(os.Getenv("GIN_MODE")) == 0 {
gin.SetMode(gin.ReleaseMode)
} else {
gin.SetMode(gin.DebugMode)
}

// adding middleware server
router.Use(middleware.CORSMiddleware())
Expand Down

0 comments on commit 3f88d06

Please sign in to comment.