currency_price.go 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 `currency_price` (
  19. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  20. `eth` double NOT NULL,
  21. `mf` double NOT NULL,
  22. `mr` double NOT NULL,
  23. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  24. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  25. `deleted_at` timestamp NULL DEFAULT NULL,
  26. PRIMARY KEY (`id`),
  27. UNIQUE KEY `id_UNIQUE` (`id`)
  28. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
  29. JSON Sample
  30. -------------------------------------
  31. { "id": 69, "eth": 0.1595842824549021, "mf": 0.017632045175807368, "mr": 0.9302054954344651, "created_at": "2294-07-30T19:13:49.896724656+09:00", "updated_at": "2296-03-25T10:20:56.792055059+09:00", "deleted_at": "2180-10-28T17:52:32.433015569+09:00"}
  32. Comments
  33. -------------------------------------
  34. [ 0] column is set for unsigned
  35. */
  36. // CurrencyPrice struct is a row record of the currency_price table in the metarare database
  37. type CurrencyPrice struct {
  38. //[ 0] id ubigint null: false primary: true isArray: false auto: true col: ubigint len: -1 default: []
  39. ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:ubigint;" json:"id"`
  40. //[ 1] eth double null: false primary: false isArray: false auto: false col: double len: -1 default: []
  41. Eth float64 `gorm:"column:eth;type:double;" json:"eth"`
  42. //[ 2] mf double null: false primary: false isArray: false auto: false col: double len: -1 default: []
  43. Mf float64 `gorm:"column:mf;type:double;" json:"mf"`
  44. //[ 3] mr double null: false primary: false isArray: false auto: false col: double len: -1 default: []
  45. Mr float64 `gorm:"column:mr;type:double;" json:"mr"`
  46. //[ 4] 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. //[ 5] 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. //[ 6] 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. }
  53. var currency_priceTableInfo = &TableInfo{
  54. Name: "currency_price",
  55. Columns: []*ColumnInfo{
  56. &ColumnInfo{
  57. Index: 0,
  58. Name: "id",
  59. Comment: ``,
  60. Notes: `column is set for unsigned`,
  61. Nullable: false,
  62. DatabaseTypeName: "ubigint",
  63. DatabaseTypePretty: "ubigint",
  64. IsPrimaryKey: true,
  65. IsAutoIncrement: true,
  66. IsArray: false,
  67. ColumnType: "ubigint",
  68. ColumnLength: -1,
  69. GoFieldName: "ID",
  70. GoFieldType: "uint64",
  71. JSONFieldName: "id",
  72. ProtobufFieldName: "id",
  73. ProtobufType: "uint64",
  74. ProtobufPos: 1,
  75. },
  76. &ColumnInfo{
  77. Index: 1,
  78. Name: "eth",
  79. Comment: ``,
  80. Notes: ``,
  81. Nullable: false,
  82. DatabaseTypeName: "double",
  83. DatabaseTypePretty: "double",
  84. IsPrimaryKey: false,
  85. IsAutoIncrement: false,
  86. IsArray: false,
  87. ColumnType: "double",
  88. ColumnLength: -1,
  89. GoFieldName: "Eth",
  90. GoFieldType: "float64",
  91. JSONFieldName: "eth",
  92. ProtobufFieldName: "eth",
  93. ProtobufType: "float",
  94. ProtobufPos: 2,
  95. },
  96. &ColumnInfo{
  97. Index: 2,
  98. Name: "mf",
  99. Comment: ``,
  100. Notes: ``,
  101. Nullable: false,
  102. DatabaseTypeName: "double",
  103. DatabaseTypePretty: "double",
  104. IsPrimaryKey: false,
  105. IsAutoIncrement: false,
  106. IsArray: false,
  107. ColumnType: "double",
  108. ColumnLength: -1,
  109. GoFieldName: "Mf",
  110. GoFieldType: "float64",
  111. JSONFieldName: "mf",
  112. ProtobufFieldName: "mf",
  113. ProtobufType: "float",
  114. ProtobufPos: 3,
  115. },
  116. &ColumnInfo{
  117. Index: 3,
  118. Name: "mr",
  119. Comment: ``,
  120. Notes: ``,
  121. Nullable: false,
  122. DatabaseTypeName: "double",
  123. DatabaseTypePretty: "double",
  124. IsPrimaryKey: false,
  125. IsAutoIncrement: false,
  126. IsArray: false,
  127. ColumnType: "double",
  128. ColumnLength: -1,
  129. GoFieldName: "Mr",
  130. GoFieldType: "float64",
  131. JSONFieldName: "mr",
  132. ProtobufFieldName: "mr",
  133. ProtobufType: "float",
  134. ProtobufPos: 4,
  135. },
  136. &ColumnInfo{
  137. Index: 4,
  138. Name: "created_at",
  139. Comment: ``,
  140. Notes: ``,
  141. Nullable: false,
  142. DatabaseTypeName: "timestamp",
  143. DatabaseTypePretty: "timestamp",
  144. IsPrimaryKey: false,
  145. IsAutoIncrement: false,
  146. IsArray: false,
  147. ColumnType: "timestamp",
  148. ColumnLength: -1,
  149. GoFieldName: "CreatedAt",
  150. GoFieldType: "time.Time",
  151. JSONFieldName: "created_at",
  152. ProtobufFieldName: "created_at",
  153. ProtobufType: "uint64",
  154. ProtobufPos: 5,
  155. },
  156. &ColumnInfo{
  157. Index: 5,
  158. Name: "updated_at",
  159. Comment: ``,
  160. Notes: ``,
  161. Nullable: false,
  162. DatabaseTypeName: "timestamp",
  163. DatabaseTypePretty: "timestamp",
  164. IsPrimaryKey: false,
  165. IsAutoIncrement: false,
  166. IsArray: false,
  167. ColumnType: "timestamp",
  168. ColumnLength: -1,
  169. GoFieldName: "UpdatedAt",
  170. GoFieldType: "time.Time",
  171. JSONFieldName: "updated_at",
  172. ProtobufFieldName: "updated_at",
  173. ProtobufType: "uint64",
  174. ProtobufPos: 6,
  175. },
  176. &ColumnInfo{
  177. Index: 6,
  178. Name: "deleted_at",
  179. Comment: ``,
  180. Notes: ``,
  181. Nullable: true,
  182. DatabaseTypeName: "timestamp",
  183. DatabaseTypePretty: "timestamp",
  184. IsPrimaryKey: false,
  185. IsAutoIncrement: false,
  186. IsArray: false,
  187. ColumnType: "timestamp",
  188. ColumnLength: -1,
  189. GoFieldName: "DeletedAt",
  190. GoFieldType: "null.Time",
  191. JSONFieldName: "deleted_at",
  192. ProtobufFieldName: "deleted_at",
  193. ProtobufType: "uint64",
  194. ProtobufPos: 7,
  195. },
  196. },
  197. }
  198. // TableName sets the insert table name for this struct type
  199. func (c *CurrencyPrice) TableName() string {
  200. return "currency_price"
  201. }
  202. // BeforeSave invoked before saving, return an error if field is not populated.
  203. func (c *CurrencyPrice) BeforeSave(*gorm.DB) error {
  204. return nil
  205. }
  206. // Prepare invoked before saving, can be used to populate fields etc.
  207. func (c *CurrencyPrice) Prepare() {
  208. }
  209. // Validate invoked before performing action, return an error if field is not populated.
  210. func (c *CurrencyPrice) Validate(action Action) error {
  211. return nil
  212. }
  213. // TableInfo return table meta data
  214. func (c *CurrencyPrice) TableInfo() *TableInfo {
  215. return currency_priceTableInfo
  216. }