bid_log.go 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. package models
  2. import (
  3. "database/sql"
  4. "time"
  5. "github.com/google/uuid"
  6. "github.com/guregu/null"
  7. "gorm.io/gorm"
  8. )
  9. var (
  10. _ = time.Second
  11. _ = sql.LevelDefault
  12. _ = null.Bool{}
  13. _ = uuid.UUID{}
  14. )
  15. /*
  16. DB Table Details
  17. -------------------------------------
  18. CREATE TABLE `bid_log` (
  19. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  20. `sale_id` bigint(20) unsigned NOT NULL,
  21. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  22. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  23. `deleted_at` timestamp NULL DEFAULT NULL,
  24. `is_cancel` tinyint(4) NOT NULL DEFAULT '0',
  25. `price` double NOT NULL,
  26. `address` varchar(256) COLLATE utf8mb4_bin NOT NULL,
  27. PRIMARY KEY (`id`),
  28. UNIQUE KEY `id_UNIQUE` (`id`),
  29. KEY `fk_bid_log_sale1_idx` (`sale_id`),
  30. CONSTRAINT `fk_bid_log_sale1` FOREIGN KEY (`sale_id`) REFERENCES `sale` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
  31. ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
  32. JSON Sample
  33. -------------------------------------
  34. { "id": 38, "sale_id": 64, "created_at": "2156-08-08T11:03:10.82280454+09:00", "updated_at": "2218-11-23T22:03:03.956572056+09:00", "deleted_at": "2060-10-14T01:16:12.869036271+09:00", "is_cancel": 52, "price": 0.7131124904145746, "address": "XXJsmsDCmliBjyRIkeDgrJKih"}
  35. Comments
  36. -------------------------------------
  37. [ 0] column is set for unsigned
  38. [ 1] column is set for unsigned
  39. */
  40. // BidLog struct is a row record of the bid_log table in the metarare database
  41. type BidLog struct {
  42. //[ 0] id ubigint null: false primary: true isArray: false auto: true col: ubigint len: -1 default: []
  43. ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:ubigint;" json:"id"`
  44. //[ 1] sale_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: []
  45. SaleID uint64 `gorm:"column:sale_id;type:ubigint;" json:"sale_id"`
  46. //[ 2] created_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
  47. CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"created_at"`
  48. //[ 3] updated_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
  49. UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"updated_at"`
  50. //[ 4] deleted_at timestamp null: true primary: false isArray: false auto: false col: timestamp len: -1 default: []
  51. DeletedAt null.Time `gorm:"column:deleted_at;type:timestamp;" json:"deleted_at"`
  52. //[ 5] is_cancel tinyint null: false primary: false isArray: false auto: false col: tinyint len: -1 default: [0]
  53. IsCancel int32 `gorm:"column:is_cancel;type:tinyint;default:0;" json:"is_cancel"`
  54. //[ 6] price double null: false primary: false isArray: false auto: false col: double len: -1 default: []
  55. Price float64 `gorm:"column:price;type:double;" json:"price"`
  56. //[ 7] address varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: []
  57. Address string `gorm:"column:address;type:varchar;size:256;" json:"address"`
  58. }
  59. var bid_logTableInfo = &TableInfo{
  60. Name: "bid_log",
  61. Columns: []*ColumnInfo{
  62. &ColumnInfo{
  63. Index: 0,
  64. Name: "id",
  65. Comment: ``,
  66. Notes: `column is set for unsigned`,
  67. Nullable: false,
  68. DatabaseTypeName: "ubigint",
  69. DatabaseTypePretty: "ubigint",
  70. IsPrimaryKey: true,
  71. IsAutoIncrement: true,
  72. IsArray: false,
  73. ColumnType: "ubigint",
  74. ColumnLength: -1,
  75. GoFieldName: "ID",
  76. GoFieldType: "uint64",
  77. JSONFieldName: "id",
  78. ProtobufFieldName: "id",
  79. ProtobufType: "uint64",
  80. ProtobufPos: 1,
  81. },
  82. &ColumnInfo{
  83. Index: 1,
  84. Name: "sale_id",
  85. Comment: ``,
  86. Notes: `column is set for unsigned`,
  87. Nullable: false,
  88. DatabaseTypeName: "ubigint",
  89. DatabaseTypePretty: "ubigint",
  90. IsPrimaryKey: false,
  91. IsAutoIncrement: false,
  92. IsArray: false,
  93. ColumnType: "ubigint",
  94. ColumnLength: -1,
  95. GoFieldName: "SaleID",
  96. GoFieldType: "uint64",
  97. JSONFieldName: "sale_id",
  98. ProtobufFieldName: "sale_id",
  99. ProtobufType: "uint64",
  100. ProtobufPos: 2,
  101. },
  102. &ColumnInfo{
  103. Index: 2,
  104. Name: "created_at",
  105. Comment: ``,
  106. Notes: ``,
  107. Nullable: false,
  108. DatabaseTypeName: "timestamp",
  109. DatabaseTypePretty: "timestamp",
  110. IsPrimaryKey: false,
  111. IsAutoIncrement: false,
  112. IsArray: false,
  113. ColumnType: "timestamp",
  114. ColumnLength: -1,
  115. GoFieldName: "CreatedAt",
  116. GoFieldType: "time.Time",
  117. JSONFieldName: "created_at",
  118. ProtobufFieldName: "created_at",
  119. ProtobufType: "uint64",
  120. ProtobufPos: 3,
  121. },
  122. &ColumnInfo{
  123. Index: 3,
  124. Name: "updated_at",
  125. Comment: ``,
  126. Notes: ``,
  127. Nullable: false,
  128. DatabaseTypeName: "timestamp",
  129. DatabaseTypePretty: "timestamp",
  130. IsPrimaryKey: false,
  131. IsAutoIncrement: false,
  132. IsArray: false,
  133. ColumnType: "timestamp",
  134. ColumnLength: -1,
  135. GoFieldName: "UpdatedAt",
  136. GoFieldType: "time.Time",
  137. JSONFieldName: "updated_at",
  138. ProtobufFieldName: "updated_at",
  139. ProtobufType: "uint64",
  140. ProtobufPos: 4,
  141. },
  142. &ColumnInfo{
  143. Index: 4,
  144. Name: "deleted_at",
  145. Comment: ``,
  146. Notes: ``,
  147. Nullable: true,
  148. DatabaseTypeName: "timestamp",
  149. DatabaseTypePretty: "timestamp",
  150. IsPrimaryKey: false,
  151. IsAutoIncrement: false,
  152. IsArray: false,
  153. ColumnType: "timestamp",
  154. ColumnLength: -1,
  155. GoFieldName: "DeletedAt",
  156. GoFieldType: "null.Time",
  157. JSONFieldName: "deleted_at",
  158. ProtobufFieldName: "deleted_at",
  159. ProtobufType: "uint64",
  160. ProtobufPos: 5,
  161. },
  162. &ColumnInfo{
  163. Index: 5,
  164. Name: "is_cancel",
  165. Comment: ``,
  166. Notes: ``,
  167. Nullable: false,
  168. DatabaseTypeName: "tinyint",
  169. DatabaseTypePretty: "tinyint",
  170. IsPrimaryKey: false,
  171. IsAutoIncrement: false,
  172. IsArray: false,
  173. ColumnType: "tinyint",
  174. ColumnLength: -1,
  175. GoFieldName: "IsCancel",
  176. GoFieldType: "int32",
  177. JSONFieldName: "is_cancel",
  178. ProtobufFieldName: "is_cancel",
  179. ProtobufType: "int32",
  180. ProtobufPos: 6,
  181. },
  182. &ColumnInfo{
  183. Index: 6,
  184. Name: "price",
  185. Comment: ``,
  186. Notes: ``,
  187. Nullable: false,
  188. DatabaseTypeName: "double",
  189. DatabaseTypePretty: "double",
  190. IsPrimaryKey: false,
  191. IsAutoIncrement: false,
  192. IsArray: false,
  193. ColumnType: "double",
  194. ColumnLength: -1,
  195. GoFieldName: "Price",
  196. GoFieldType: "float64",
  197. JSONFieldName: "price",
  198. ProtobufFieldName: "price",
  199. ProtobufType: "float",
  200. ProtobufPos: 7,
  201. },
  202. &ColumnInfo{
  203. Index: 7,
  204. Name: "address",
  205. Comment: ``,
  206. Notes: ``,
  207. Nullable: false,
  208. DatabaseTypeName: "varchar",
  209. DatabaseTypePretty: "varchar(256)",
  210. IsPrimaryKey: false,
  211. IsAutoIncrement: false,
  212. IsArray: false,
  213. ColumnType: "varchar",
  214. ColumnLength: 256,
  215. GoFieldName: "Address",
  216. GoFieldType: "string",
  217. JSONFieldName: "address",
  218. ProtobufFieldName: "address",
  219. ProtobufType: "string",
  220. ProtobufPos: 8,
  221. },
  222. },
  223. }
  224. // TableName sets the insert table name for this struct type
  225. func (b *BidLog) TableName() string {
  226. return "bid_log"
  227. }
  228. // BeforeSave invoked before saving, return an error if field is not populated.
  229. func (b *BidLog) BeforeSave(*gorm.DB) error {
  230. return nil
  231. }
  232. // Prepare invoked before saving, can be used to populate fields etc.
  233. func (b *BidLog) Prepare() {
  234. }
  235. // Validate invoked before performing action, return an error if field is not populated.
  236. func (b *BidLog) Validate(action Action) error {
  237. return nil
  238. }
  239. // TableInfo return table meta data
  240. func (b *BidLog) TableInfo() *TableInfo {
  241. return bid_logTableInfo
  242. }