Skip to content

Commit

Permalink
feat : added elevateRegion
Browse files Browse the repository at this point in the history
  • Loading branch information
surajhub255 committed Oct 8, 2024
1 parent 5b052b3 commit af87da7
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 37 deletions.
9 changes: 9 additions & 0 deletions controllers/avatar_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ func GetAllAvatarsByChainType(c *gin.Context) {
c.JSON(http.StatusOK, avatars)
}

func GetAllAvatarByRegion(c *gin.Context) {
var avatars []models.Avatar
if err := db.DB.Where("elevate_region = ?", "Africa").Find(&avatars).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, avatars)
}

func GetAllAvatars(c *gin.Context) {
var avatars []models.Avatar
if err := db.DB.Find(&avatars).Error; err != nil {
Expand Down
9 changes: 9 additions & 0 deletions controllers/brand_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ func GetBrandsByManager(c *gin.Context) {
c.JSON(http.StatusOK, brands)
}

func GetAllBrandsByRegion(c *gin.Context) {
var brands []models.Brand
if err := db.DB.Where("elevate_region = ?", "Africa").Find(&brands).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, brands)
}

func UpdateBrand(c *gin.Context) {
id := c.Param("id")
var brand models.Brand
Expand Down
9 changes: 9 additions & 0 deletions controllers/collection_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ func GetCollection(c *gin.Context) {
c.JSON(http.StatusOK, collection)
}

func GetAllCollectionByRegion(c *gin.Context) {
var collection []models.Collection
if err := db.DB.Where("elevate_region = ?", "Africa").Find(&collection).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, collection)
}

func GetCollectionByBrandId(c *gin.Context) {
brand_id := c.Param("brandId")
var collection models.Collection
Expand Down
9 changes: 9 additions & 0 deletions controllers/phygital_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ func GetPhygital(c *gin.Context) {
c.JSON(http.StatusOK, oldPhygital)
}

func GetAllPhygitalByRegion(c *gin.Context) {
var phygitals []models.Phygital
if err := db.DB.Where("elevate_region = ?", "Africa").Find(&phygitals).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, phygitals)
}

func GetPhygitalByWalletAddress(c *gin.Context) {
deployer_address := c.Param("deployer_address")
var oldPhygital models.Phygital
Expand Down
9 changes: 9 additions & 0 deletions controllers/variant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ func GetAllVariantByChainType(c *gin.Context) {
c.JSON(http.StatusOK, variants)
}

func GetAllVariantByRegion(c *gin.Context) {
var variants []models.Variant
if err := db.DB.Where("elevate_region = ?", "Africa").Find(&variants).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, variants)
}

func GetAllVariant(c *gin.Context) {
var variants []models.Variant
if err := db.DB.Find(&variants).Error; err != nil {
Expand Down
9 changes: 9 additions & 0 deletions controllers/webxr_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ func GetAllWebXRByChainType(c *gin.Context) {
c.JSON(http.StatusOK, webxr)
}

func GetAllWebxrByRegion(c *gin.Context) {
var webxr []models.WebXR
if err := db.DB.Where("elevate_region = ?", "Africa").Find(&webxr).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, webxr)
}

func GetAllWebXR(c *gin.Context) {
var webxr []models.WebXR
if err := db.DB.Find(&webxr).Error; err != nil {
Expand Down
19 changes: 10 additions & 9 deletions models/avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import (
)

type Avatar struct {
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
AvatarID string `json:"avatar_id"`
URL string `json:"url"`
UserID string `json:"user_id"`
PhygitalID string `json:"phygital_id"`
AvatarVoice string `json:"avatar_voice"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_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"`
AvatarID string `json:"avatar_id"`
URL string `json:"url"`
UserID string `json:"user_id"`
PhygitalID string `json:"phygital_id"`
AvatarVoice string `json:"avatar_voice"`
ElevateRegion string `json:"elevate_region"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_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 (a *Avatar) BeforeCreate(tx *gorm.DB) (err error) {
Expand Down
13 changes: 7 additions & 6 deletions models/brand.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ type Brand struct {
ContactEmail string `json:"contact_email"`
ContactPhone string `json:"contact_phone"`
ShippingAddress string `json:"shipping_address"`
Website string `json:"website"`
Website string `json:"website"`
Twitter string `json:"twitter"`
Instagram string `json:"instagram"`
Facebook string `json:"facebook"`
Instagram string `json:"instagram"`
Facebook string `json:"facebook"`
AdditionalLink string `json:"additional_link"`
Link string `json:"link"`
Discord string `json:"discord"`
Link string `json:"link"`
Discord string `json:"discord"`
AdditionalInfo string `json:"additional_info"`
Industry string `json:"industry"`
Tags string `json:"tags"`
Expand All @@ -34,8 +34,9 @@ type Brand struct {
TradeHub string `json:"trade_hub"`
Blockchain string `json:"blockchain"`
ChainID string `json:"chain_id"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_id"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_id"`
ManagerID string `json:"manager_id"` //user walletaddress
ElevateRegion string `json:"elevate_region"`
CreatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"updated_at"`
}
Expand Down
25 changes: 13 additions & 12 deletions models/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ 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 datatypes.JSON `gorm:"type:jsonb" json:"category"`
Tags string `json:"tags"`
Status int `json:"status"`
BrandID string `json:"brand_id"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_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 datatypes.JSON `gorm:"type:jsonb" json:"category"`
Tags string `json:"tags"`
Status int `json:"status"`
BrandID string `json:"brand_id"`
ElevateRegion string `json:"elevate_region"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_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
5 changes: 3 additions & 2 deletions models/phygital.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ type Phygital struct {
Name string `json:"name"`
BrandName string `json:"brand_name"`
Category datatypes.JSON `gorm:"type:jsonb" json:"category"`
Tags datatypes.JSON `gorm:"type:jsonb" json:"tags"`
Tags datatypes.JSON `gorm:"type:jsonb" json:"tags"`
Description string `json:"description"`
Price *float64 `json:"price" gorm:"type:decimal(20,10);"`
Price *float64 `json:"price" gorm:"type:decimal(20,10);"`
Quantity int `json:"quantity"`
Royality int `json:"royality"`
Image string `json:"image"`
Expand All @@ -33,6 +33,7 @@ type Phygital struct {
DeployerAddress string `json:"deployer_address"`
ContractAddress string `json:"contract_address"`
GraphURL string `json:"graph_url"`
ElevateRegion string `json:"elevate_region"`
CollectionID uuid.UUID `json:"collection_id"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_id"`
CreatedAt time.Time `gorm:"type:timestamp;default:current_timestamp" json:"created_at"`
Expand Down
15 changes: 8 additions & 7 deletions models/variant.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
)

type Variant struct {
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key" json:"id"`
Variant string `json:"variant"`
Description string `json:"description"`
PhygitalID string `json:"phygital_id"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_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"`
Variant string `json:"variant"`
Description string `json:"description"`
ElevateRegion string `json:"elevate_region"`
PhygitalID string `json:"phygital_id"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_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 (v *Variant) BeforeCreate(tx *gorm.DB) (err error) {
Expand Down
3 changes: 2 additions & 1 deletion models/webxr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ type WebXR struct {
GoldReward string `json:"gold_reward"`
SilverReward string `json:"silver_reward"`
BronzeReward string `json:"bronze_reward"`
ElevateRegion string `json:"elevate_region"`
PhygitalID string `json:"phygital_id"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_id"`
ChaintypeID uuid.UUID `gorm:"type:uuid" json:"chaintype_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"`
}
Expand Down
6 changes: 6 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func Routes(r *gin.Engine) {
r.PUT("/brands/:id", controllers.UpdateBrand)
r.DELETE("/brands/:id", controllers.DeleteBrand)
r.GET("/brands/manager/:manager_id", controllers.GetBrandsByManager)
r.GET("/brands/region", controllers.GetAllBrandsByRegion)

// Collection routes
r.POST("/collections", controllers.CreateCollection)
Expand All @@ -56,6 +57,7 @@ func Routes(r *gin.Engine) {
r.PUT("/collections/:id", controllers.UpdateCollection)
r.PUT("/collections/brand-id/:brandId", controllers.UpdateCollectionByBrandId)
r.DELETE("/collections/:id", controllers.DeleteCollection)
r.GET("/collections/region", controllers.GetAllCollectionByRegion)

// Phygital routes
r.POST("/phygitals", controllers.CreatePhygital)
Expand All @@ -65,6 +67,7 @@ func Routes(r *gin.Engine) {
r.GET("/phygitals/all", controllers.GetAllPhygital)
r.PUT("/phygitals/:id", controllers.UpdatePhygital)
r.DELETE("/phygitals/:id", controllers.DeletePhygital)
r.GET("/phygitals/region", controllers.GetAllPhygitalByRegion)

// WebXR routes
r.POST("/webxr", controllers.CreateWebXR)
Expand All @@ -74,6 +77,7 @@ func Routes(r *gin.Engine) {
r.PUT("/webxr/:id", controllers.UpdateWebXR)
r.DELETE("/webxr/:id", controllers.DeleteWebXR)
r.GET("/webxr/phygital/:phygital_id", controllers.GetWebXRByPhygitalID)
r.GET("/webxr/region", controllers.GetAllWebxrByRegion)

// Avatar routes
r.POST("/avatars", controllers.CreateAvatar)
Expand All @@ -83,6 +87,7 @@ func Routes(r *gin.Engine) {
r.PUT("/avatars/:id", controllers.UpdateAvatar)
r.DELETE("/avatars/:id", controllers.DeleteAvatar)
r.GET("/avatars/phygital/:phygital_id", controllers.GetAvatarByPhygitalID)
r.GET("/avatars/region", controllers.GetAllAvatarByRegion)

// Variant routes
r.POST("/variants", controllers.CreateVariant)
Expand All @@ -91,6 +96,7 @@ func Routes(r *gin.Engine) {
r.GET("/variants/all", controllers.GetAllVariant)
r.PUT("/variants/:id", controllers.UpdateVariant)
r.DELETE("/variants/:id", controllers.DeleteVariant)
r.GET("/variants/region", controllers.GetAllVariantByRegion)

//FanToken routes
r.POST("/fantoken", controllers.CreateFanToken)
Expand Down

0 comments on commit af87da7

Please sign in to comment.