product.go 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package model
  2. import (
  3. "time"
  4. )
  5. type Product struct {
  6. BaseModel
  7. ID int `json:"id" form:"id" gorm:"primaryKey" binding:"required"`
  8. Name string `json:"name" form:"name"`
  9. Path string `json:"url" gorm:"column:url" form:"url"`
  10. UnitPrice int `json:"unit_price" form:"unit_price"` //单价
  11. MinUnit int `json:"min_unit" form:"min_unit"` //最小单位
  12. ProductType int `json:"product_type" form:"product_type"` //产品类型 按次-0,按条-1
  13. TestNum int `json:"test_num" form:"test_num"` //试用量
  14. }
  15. func (p *Product) TableName() string {
  16. return "product"
  17. }
  18. type UserProduct struct {
  19. ID int `json:"id" gorm:"primaryKey"`
  20. AppID string `json:"app_id"`
  21. ProductID int `json:"product_id"`
  22. CreateAt time.Time `json:"-" gorm:"autoCreateTime"` //标签autoCreateTime设置如果字段名字不为CreatAt时候自动插入当前时间
  23. StartAt time.Time `json:"start_at" grom:"start_at"`
  24. EndAt time.Time `json:"end_at" grom:"end_at"`
  25. LeftNum int `json:"left_num"` //剩余量 加锁处理
  26. CostModel int `json:"cost_model"` //扣费模式(0-按剩余量扣,1-按账户余额扣,2-优先扣剩余量,量为0扣余额)
  27. InterfaceStatus int `json:"interface_status"` //接口状态(0开启|-1停用|-2异常|-3维护)
  28. CallTimesLimitDay int `json:"call_times_limit_day"` //接口调用次数每日上限
  29. DataNumLimitOneTimes int `json:"data_num_limit_one_times"` //接口每次返回数据量上限
  30. UpdateAt time.Time `json:"-" gorm:"autoUpdateTime"` //更新时间
  31. Discount int `json:"discount"` //用户产品折扣
  32. }
  33. func (p *UserProduct) TableName() string {
  34. return "user_product"
  35. }
  36. type UserProductModel struct {
  37. ID int `json:"id" gorm:"primaryKey"`
  38. AppID string `json:"app_id"`
  39. ProductID int `json:"product_id"`
  40. CreateAt time.Time `json:"-" gorm:"autoCreateTime"` //标签autoCreateTime设置如果字段名字不为CreatAt时候自动插入当前时间
  41. CostModel int `json:"cost_model"` //扣费模式(0-按剩余量扣,1-按账户余额扣,2-优先扣剩余量,量为0扣余额)
  42. LeftNum int `json:"left_num"` //剩余量 加锁处理
  43. InterfaceStatus int `json:"interface_status"` //接口状态(0开启|-1停用|-2异常|-3维护)
  44. CallTimesLimitDay int `json:"call_times_limit_day"` //接口调用次数每日上限
  45. DataNumLimitOneTimes int `json:"data_num_limit_one_times"` //接口每次返回数据量上限
  46. UpdateAt time.Time `json:"-" gorm:"autoUpdateTime"` //更新时间
  47. Discount int `json:"discount"` //用户产品折扣
  48. }
  49. func (p *UserProductModel) TableName() string {
  50. return "user_product"
  51. }