Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02adc73
commit 2201239
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package models | ||
|
||
import ( | ||
"gorm.io/gorm" | ||
"time" | ||
"gorm.io/plugin/soft_delete" | ||
) | ||
|
||
type ProductPricingModel struct { | ||
ID string `gorm:"column:id;primary_key" json:"id"` | ||
CustomerLevelID string `gorm:"column:customer_level_id" json:"customer_level_id"` | ||
ProductModelDataID string `gorm:"column:product_model_data_id" json:"product_model_data_id"` | ||
Active int `gorm:"column:active" json:"active"` | ||
INC int `gorm:"column:inc" json:"inc"` | ||
Price int `gorm:"column:price" json:"price"` | ||
CreatedBy NullString `gorm:"column:created_by" json:"created_by"` | ||
CreatedAt time.Time `gorm:"column:created_at" json:"crated_at"` | ||
UpdatedBy NullString `gorm:"column:updated_by" json:"updated_by"` | ||
UpdatedAt time.Time `gorm:"column:updated_at" sql:"type:timestamp without time zone" json:"updated_at"` | ||
DeletedBy NullString `gorm:"column:updated_by" json:"deleted_by"` | ||
DeletedAt soft_delete.DeletedAt `gorm:"uniqueIndex:udx_name;column:deleted_at" json:"deleted_at"` | ||
} | ||
|
||
type ProductPricingModelPreload struct { | ||
ID string `gorm:"column:id;primary_key" json:"id"` | ||
CustomerLevelID string `gorm:"column:customer_level_id" json:"customer_level_id"` | ||
ProductModelDataID string `gorm:"column:product_model_data_id" json:"product_model_data_id"` | ||
Active int `gorm:"column:active" json:"active"` | ||
INC int `gorm:"column:inc" json:"inc"` | ||
Price int `gorm:"column:price" json:"price"` | ||
DeletedAt soft_delete.DeletedAt `gorm:"uniqueIndex:udx_name;column:deleted_at" json:"-"` | ||
CustomerLevel []CustomerLevelModelInfo `gorm:"foreignKey:ID;references:CustomerLevelID" json:"customer_level"` | ||
} | ||
|
||
// TableName sets the insert table name for this struct type | ||
func (p *ProductPricingModel) TableName() string { | ||
return "product_price" | ||
} | ||
func (p *ProductPricingModelPreload) TableName() string { | ||
return "product_price" | ||
} | ||
|
||
func (p *ProductPricingModel) BeforeCreate(tx *gorm.DB) (err error) { | ||
return | ||
} | ||
|
||
func (p *ProductPricingModel) BeforeUpdate(tx *gorm.DB) (err error) { | ||
return | ||
} | ||
func (p *ProductPricingModel) AfterUpdate(tx *gorm.DB) (err error) { | ||
return | ||
} | ||
func (p *ProductPricingModel) BeforeDelete(tx *gorm.DB) (err error) { | ||
// fmt.Println("Before Delete") | ||
// _,con,_ := DbConnect() | ||
// var model ProductPricingModel | ||
// con.Model(&model).Where("id=?", p.ID).Update("deleted_by",ActiveUser) | ||
return | ||
} | ||
|
||
//strcture input | ||
type ProductPricingModelInput struct { | ||
CustomerLevelID map[string][]string `json:"customer_level_id"` | ||
ProductModelDataID []string `json:"product_model_data_id" binding:"required"` | ||
Price map[string][]int `json:"price"` | ||
} | ||
type ProductPricingModelUpdate struct { | ||
ID string `json:"id" binding:"required"` | ||
CustomerLevelID string `json:"customer_level_id" binding:"required"` | ||
ProductModelDataID string `json:"product_model_data_id" binding:"required"` | ||
Active int `json:"active"` | ||
Price int `json:"price"` | ||
} | ||
type ProductPricingModellInfo struct { | ||
ID string `json:"id" binding:"required"` | ||
} |