record.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. package raffle
  2. import (
  3. "zhiyuan/models"
  4. "zhiyuan/pkg/db"
  5. "github.com/gin-gonic/gin"
  6. )
  7. type RaffleRecord struct {
  8. ID int64 `json:"id" prop:"add:false"`
  9. UserId int64 `json:"user_id" type:"int" prop:"add" search:"="`
  10. RaffleId int64 `json:"raffle_id" type:"int" prop:"add" search:"="`
  11. ItemId int64 `json:"item_id" type:"int" prop:"add" search:"="`
  12. Name string `json:"name" label:"姓名" type:"string" prop:"edit" search:"like"`
  13. Phone string `json:"phone" label:"电话" type:"string" prop:"edit" search:"like"`
  14. DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
  15. CreatedAt int64 `json:"created_at" prop:"add:false select:false"`
  16. UpdatedAt int64 `json:"updated_at" prop:"add:false select:false"`
  17. db.BaseModel
  18. }
  19. func (RaffleRecord) TableName() string {
  20. return "zy_raffle_record"
  21. }
  22. func (model RaffleRecord) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  23. return true
  24. }
  25. func (RaffleRecord) OnePrivilege(c *gin.Context, id int64) bool {
  26. return true
  27. }
  28. func (RaffleRecord) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
  29. return nil
  30. }
  31. func (RaffleRecord) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  32. return nil
  33. }
  34. func (RaffleRecord) DelPrivilege(c *gin.Context, id int64) error {
  35. return nil
  36. }
  37. func (RaffleRecord) Page() bool {
  38. return false
  39. }
  40. func (RaffleRecord) Count() bool {
  41. return true
  42. }
  43. type RaffleItemRecord struct {
  44. ID int64 `json:"id" prop:"add:false"`
  45. UserId int64 `json:"user_id" type:"int" prop:"add" search:"="`
  46. RaffleId int64 `json:"raffle_id" type:"int" prop:"add" search:"="`
  47. ItemId int64 `json:"item_id" type:"int" prop:"add" search:"="`
  48. Name string `json:"name" label:"奖品名称" type:"string" prop:"select:item.name"`
  49. Picture string `json:"picture" label:"图片" type:"string" prop:"select:item.picture"`
  50. Winning int64 `json:"winning" label:"是否中奖" type:"int" prop:"select:item.winning" search:"="`
  51. DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
  52. CreatedAt int64 `json:"created_at" prop:"add:false select:false"`
  53. UpdatedAt int64 `json:"updated_at" prop:"add:false select:false"`
  54. db.BaseModel
  55. }
  56. func (RaffleItemRecord) TableName() string {
  57. return "zy_raffle_record"
  58. }
  59. func (model RaffleItemRecord) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  60. return true
  61. }
  62. func (RaffleItemRecord) OnePrivilege(c *gin.Context, id int64) bool {
  63. return true
  64. }
  65. func (RaffleItemRecord) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
  66. return nil
  67. }
  68. func (RaffleItemRecord) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  69. return nil
  70. }
  71. func (RaffleItemRecord) DelPrivilege(c *gin.Context, id int64) error {
  72. return nil
  73. }
  74. func (RaffleItemRecord) Page() bool {
  75. return false
  76. }
  77. func (RaffleItemRecord) Count() bool {
  78. return true
  79. }
  80. func (model RaffleItemRecord) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
  81. return []db.JoinModel{{
  82. Model: RaffleItem{},
  83. As: "item",
  84. On: []string{"`item`.`id` = " + model.TableName() + ".`item_id`"},
  85. }}
  86. }
  87. type RaffleRecords struct {
  88. ID int64 `json:"id" prop:"add:false"`
  89. UserId int64 `json:"user_id" type:"int" prop:"add" search:"="`
  90. RaffleId int64 `json:"raffle_id" type:"int" prop:"add" search:"="`
  91. ItemId int64 `json:"item_id" type:"int" prop:"add" search:"="`
  92. Name string `json:"name" label:"姓名" type:"string" prop:"edit" search:"like"`
  93. Phone string `json:"phone" label:"电话" type:"string" prop:"edit" search:"like"`
  94. Nickname string `json:"nickname" label:"昵称" type:"string" prop:"select:user.nickname" search:"like"`
  95. Headimgurl string `json:"headimgurl" label:"头像" type:"string" prop:"select:user.headimgurl"`
  96. ItemName string `json:"item_name" label:"奖品名称" type:"string" prop:"select:item.name"`
  97. ItemPicture string `json:"item_picture" label:"图片" type:"string" prop:"select:item.picture"`
  98. Winning int64 `json:"winning" label:"是否中奖" type:"int" prop:"select:item.winning" search:"="`
  99. DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
  100. CreatedAt int64 `json:"created_at" prop:"add:false"`
  101. UpdatedAt int64 `json:"updated_at" prop:"add:false select:false"`
  102. db.BaseModel
  103. }
  104. func (RaffleRecords) TableName() string {
  105. return "zy_raffle_record"
  106. }
  107. func (model RaffleRecords) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  108. return true
  109. }
  110. func (RaffleRecords) OnePrivilege(c *gin.Context, id int64) bool {
  111. return true
  112. }
  113. func (RaffleRecords) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
  114. return nil
  115. }
  116. func (RaffleRecords) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  117. return nil
  118. }
  119. func (RaffleRecords) DelPrivilege(c *gin.Context, id int64) error {
  120. return nil
  121. }
  122. func (RaffleRecords) Page() bool {
  123. return false
  124. }
  125. func (RaffleRecords) Count() bool {
  126. return true
  127. }
  128. func (model RaffleRecords) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
  129. return []db.JoinModel{{
  130. Model: RaffleItem{},
  131. As: "item",
  132. On: []string{"`item`.`id` = " + model.TableName() + ".`item_id`"},
  133. }, {
  134. Model: models.WeixinUser{},
  135. As: "user",
  136. On: []string{"`user`.`id` = " + model.TableName() + ".`user_id`"},
  137. }}
  138. }