collection_profile.go 10 KB

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