user.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package model
  2. import (
  3. "time"
  4. )
  5. type User struct {
  6. BaseModel
  7. Name string `json:"name" form:"name" binding:"required"`
  8. Phone string `json:"phone" form:"phone" binding:"required"`
  9. AppID string `json:"app_id"`
  10. SecretKey string `json:"secret_key"`
  11. IpWhiteList string `json:"ip_white_list" form:"ip_white_list" binding:"required"`
  12. }
  13. func (user *User) TableName() string {
  14. return "user"
  15. }
  16. type UserAccount struct {
  17. ID int `json:"id" gorm:"primaryKey"`
  18. AppID string `json:"app_id"`
  19. Money int `json:"money"`
  20. CreateAt time.Time `json:"-" gorm:"autoCreateTime"` //标签autoCreateTime设置如果字段名字不为CreatAt时候自动插入当前时间
  21. UpdateAt time.Time `json:"-" gorm:"autoUpdateTime"`
  22. }
  23. func (p *UserAccount) TableName() string {
  24. return "user_account"
  25. }
  26. type UserMoneyRecord struct {
  27. ID int `json:"id" gorm:"primaryKey"`
  28. AppID string `json:"app_id"`
  29. Before int `json:"before"`
  30. After int `json:"after"`
  31. TradeMoney int `json:"tarde_money"`
  32. CreateAt time.Time `json:"-" gorm:"autoCreateTime"`
  33. }
  34. func (p *UserMoneyRecord) TableName() string {
  35. return "user_money_record"
  36. }
  37. type UserBuyRecord struct {
  38. ID int `json:"id" gorm:"primaryKey"`
  39. AppID string `json:"app_id"`
  40. ProductId int `json:"product_id"`
  41. UserProductId int `json:"user_product_id"`
  42. Before int `json:"before"`
  43. After int `json:"after"`
  44. TradeMoney int `json:"tarde_money"`
  45. BuyType int `json:"buy_type"`
  46. HistoryUnitPrice int `json:"history_unit_price"`
  47. CreateAt time.Time `json:"-" gorm:"autoCreateTime"`
  48. }
  49. func (p *UserBuyRecord) TableName() string {
  50. return "user_buy_record"
  51. }