log_relation.go 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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 `log_relation` (
  19. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  20. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  21. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  22. `deleted_at` timestamp NULL DEFAULT NULL,
  23. `user_id` bigint(20) unsigned DEFAULT NULL,
  24. `collection_id` bigint(20) unsigned DEFAULT NULL,
  25. `token_id` bigint(20) unsigned DEFAULT NULL,
  26. `sale_id` bigint(20) unsigned DEFAULT NULL,
  27. PRIMARY KEY (`id`),
  28. KEY `fk_log_relation_user1_idx` (`user_id`),
  29. KEY `fk_log_relation_collection1_idx` (`collection_id`),
  30. KEY `fk_log_relation_token1_idx` (`token_id`),
  31. KEY `fk_log_relation_sale1_idx` (`sale_id`),
  32. CONSTRAINT `fk_log_relation_collection1` FOREIGN KEY (`collection_id`) REFERENCES `collection` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  33. CONSTRAINT `fk_log_relation_sale1` FOREIGN KEY (`sale_id`) REFERENCES `sale` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  34. CONSTRAINT `fk_log_relation_token1` FOREIGN KEY (`token_id`) REFERENCES `token` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  35. CONSTRAINT `fk_log_relation_user1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
  36. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
  37. JSON Sample
  38. -------------------------------------
  39. { "id": 73, "created_at": "2142-07-19T06:33:35.464349449+09:00", "updated_at": "2111-11-13T13:28:26.73839082+09:00", "deleted_at": "2076-11-27T17:15:21.29440524+09:00", "user_id": 44, "collection_id": 45, "token_id": 27, "sale_id": 94}
  40. Comments
  41. -------------------------------------
  42. [ 0] column is set for unsigned
  43. [ 4] column is set for unsigned
  44. [ 5] column is set for unsigned
  45. [ 6] column is set for unsigned
  46. [ 7] column is set for unsigned
  47. */
  48. // LogRelation struct is a row record of the log_relation table in the metarare database
  49. type LogRelation struct {
  50. //[ 0] id ubigint null: false primary: true isArray: false auto: true col: ubigint len: -1 default: []
  51. ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:ubigint;" json:"id"`
  52. //[ 1] created_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
  53. CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"created_at"`
  54. //[ 2] updated_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
  55. UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"updated_at"`
  56. //[ 3] deleted_at timestamp null: true primary: false isArray: false auto: false col: timestamp len: -1 default: []
  57. DeletedAt null.Time `gorm:"column:deleted_at;type:timestamp;" json:"deleted_at"`
  58. //[ 4] user_id ubigint null: true primary: false isArray: false auto: false col: ubigint len: -1 default: []
  59. UserID null.Int `gorm:"column:user_id;type:ubigint;" json:"user_id"`
  60. //[ 5] collection_id ubigint null: true primary: false isArray: false auto: false col: ubigint len: -1 default: []
  61. CollectionID null.Int `gorm:"column:collection_id;type:ubigint;" json:"collection_id"`
  62. //[ 6] token_id ubigint null: true primary: false isArray: false auto: false col: ubigint len: -1 default: []
  63. TokenID null.Int `gorm:"column:token_id;type:ubigint;" json:"token_id"`
  64. //[ 7] sale_id ubigint null: true primary: false isArray: false auto: false col: ubigint len: -1 default: []
  65. Log Log
  66. SaleID null.Int `gorm:"column:sale_id;type:ubigint;" json:"sale_id"`
  67. User User
  68. Collection Collection
  69. Token Token
  70. Sale Sale
  71. }
  72. var log_relationTableInfo = &TableInfo{
  73. Name: "log_relation",
  74. Columns: []*ColumnInfo{
  75. &ColumnInfo{
  76. Index: 0,
  77. Name: "id",
  78. Comment: ``,
  79. Notes: `column is set for unsigned`,
  80. Nullable: false,
  81. DatabaseTypeName: "ubigint",
  82. DatabaseTypePretty: "ubigint",
  83. IsPrimaryKey: true,
  84. IsAutoIncrement: true,
  85. IsArray: false,
  86. ColumnType: "ubigint",
  87. ColumnLength: -1,
  88. GoFieldName: "ID",
  89. GoFieldType: "uint64",
  90. JSONFieldName: "id",
  91. ProtobufFieldName: "id",
  92. ProtobufType: "uint64",
  93. ProtobufPos: 1,
  94. },
  95. &ColumnInfo{
  96. Index: 1,
  97. Name: "created_at",
  98. Comment: ``,
  99. Notes: ``,
  100. Nullable: false,
  101. DatabaseTypeName: "timestamp",
  102. DatabaseTypePretty: "timestamp",
  103. IsPrimaryKey: false,
  104. IsAutoIncrement: false,
  105. IsArray: false,
  106. ColumnType: "timestamp",
  107. ColumnLength: -1,
  108. GoFieldName: "CreatedAt",
  109. GoFieldType: "time.Time",
  110. JSONFieldName: "created_at",
  111. ProtobufFieldName: "created_at",
  112. ProtobufType: "uint64",
  113. ProtobufPos: 2,
  114. },
  115. &ColumnInfo{
  116. Index: 2,
  117. Name: "updated_at",
  118. Comment: ``,
  119. Notes: ``,
  120. Nullable: false,
  121. DatabaseTypeName: "timestamp",
  122. DatabaseTypePretty: "timestamp",
  123. IsPrimaryKey: false,
  124. IsAutoIncrement: false,
  125. IsArray: false,
  126. ColumnType: "timestamp",
  127. ColumnLength: -1,
  128. GoFieldName: "UpdatedAt",
  129. GoFieldType: "time.Time",
  130. JSONFieldName: "updated_at",
  131. ProtobufFieldName: "updated_at",
  132. ProtobufType: "uint64",
  133. ProtobufPos: 3,
  134. },
  135. &ColumnInfo{
  136. Index: 3,
  137. Name: "deleted_at",
  138. Comment: ``,
  139. Notes: ``,
  140. Nullable: true,
  141. DatabaseTypeName: "timestamp",
  142. DatabaseTypePretty: "timestamp",
  143. IsPrimaryKey: false,
  144. IsAutoIncrement: false,
  145. IsArray: false,
  146. ColumnType: "timestamp",
  147. ColumnLength: -1,
  148. GoFieldName: "DeletedAt",
  149. GoFieldType: "null.Time",
  150. JSONFieldName: "deleted_at",
  151. ProtobufFieldName: "deleted_at",
  152. ProtobufType: "uint64",
  153. ProtobufPos: 4,
  154. },
  155. &ColumnInfo{
  156. Index: 4,
  157. Name: "user_id",
  158. Comment: ``,
  159. Notes: `column is set for unsigned`,
  160. Nullable: true,
  161. DatabaseTypeName: "ubigint",
  162. DatabaseTypePretty: "ubigint",
  163. IsPrimaryKey: false,
  164. IsAutoIncrement: false,
  165. IsArray: false,
  166. ColumnType: "ubigint",
  167. ColumnLength: -1,
  168. GoFieldName: "UserID",
  169. GoFieldType: "null.Int",
  170. JSONFieldName: "user_id",
  171. ProtobufFieldName: "user_id",
  172. ProtobufType: "uint64",
  173. ProtobufPos: 5,
  174. },
  175. &ColumnInfo{
  176. Index: 5,
  177. Name: "collection_id",
  178. Comment: ``,
  179. Notes: `column is set for unsigned`,
  180. Nullable: true,
  181. DatabaseTypeName: "ubigint",
  182. DatabaseTypePretty: "ubigint",
  183. IsPrimaryKey: false,
  184. IsAutoIncrement: false,
  185. IsArray: false,
  186. ColumnType: "ubigint",
  187. ColumnLength: -1,
  188. GoFieldName: "CollectionID",
  189. GoFieldType: "null.Int",
  190. JSONFieldName: "collection_id",
  191. ProtobufFieldName: "collection_id",
  192. ProtobufType: "uint64",
  193. ProtobufPos: 6,
  194. },
  195. &ColumnInfo{
  196. Index: 6,
  197. Name: "token_id",
  198. Comment: ``,
  199. Notes: `column is set for unsigned`,
  200. Nullable: true,
  201. DatabaseTypeName: "ubigint",
  202. DatabaseTypePretty: "ubigint",
  203. IsPrimaryKey: false,
  204. IsAutoIncrement: false,
  205. IsArray: false,
  206. ColumnType: "ubigint",
  207. ColumnLength: -1,
  208. GoFieldName: "TokenID",
  209. GoFieldType: "null.Int",
  210. JSONFieldName: "token_id",
  211. ProtobufFieldName: "token_id",
  212. ProtobufType: "uint64",
  213. ProtobufPos: 7,
  214. },
  215. &ColumnInfo{
  216. Index: 7,
  217. Name: "sale_id",
  218. Comment: ``,
  219. Notes: `column is set for unsigned`,
  220. Nullable: true,
  221. DatabaseTypeName: "ubigint",
  222. DatabaseTypePretty: "ubigint",
  223. IsPrimaryKey: false,
  224. IsAutoIncrement: false,
  225. IsArray: false,
  226. ColumnType: "ubigint",
  227. ColumnLength: -1,
  228. GoFieldName: "SaleID",
  229. GoFieldType: "null.Int",
  230. JSONFieldName: "sale_id",
  231. ProtobufFieldName: "sale_id",
  232. ProtobufType: "uint64",
  233. ProtobufPos: 8,
  234. },
  235. },
  236. }
  237. // TableName sets the insert table name for this struct type
  238. func (l *LogRelation) TableName() string {
  239. return "log_relation"
  240. }
  241. // BeforeSave invoked before saving, return an error if field is not populated.
  242. func (l *LogRelation) BeforeSave(*gorm.DB) error {
  243. return nil
  244. }
  245. // Prepare invoked before saving, can be used to populate fields etc.
  246. func (l *LogRelation) Prepare() {
  247. }
  248. // Validate invoked before performing action, return an error if field is not populated.
  249. func (l *LogRelation) Validate(action Action) error {
  250. return nil
  251. }
  252. // TableInfo return table meta data
  253. func (l *LogRelation) TableInfo() *TableInfo {
  254. return log_relationTableInfo
  255. }