szj_articles.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. 'use strict';
  2. module.exports = app => {
  3. const DataTypes = app.Sequelize;
  4. const sequelize = app.model;
  5. const attributes = {
  6. articleId: {
  7. type: DataTypes.INTEGER(10).UNSIGNED,
  8. allowNull: false,
  9. defaultValue: null,
  10. primaryKey: true,
  11. autoIncrement: true,
  12. comment: "文章ID",
  13. field: "article_id"
  14. },
  15. articleTitle: {
  16. type: DataTypes.STRING(200),
  17. allowNull: false,
  18. defaultValue: null,
  19. primaryKey: false,
  20. autoIncrement: false,
  21. comment: "文章标题",
  22. field: "article_title"
  23. },
  24. articleDesc: {
  25. type: DataTypes.STRING(255),
  26. allowNull: false,
  27. defaultValue: null,
  28. primaryKey: false,
  29. autoIncrement: false,
  30. comment: "文章描述",
  31. field: "article_desc"
  32. },
  33. articleContent: {
  34. type: DataTypes.TEXT,
  35. allowNull: false,
  36. defaultValue: null,
  37. primaryKey: false,
  38. autoIncrement: false,
  39. comment: "文章内容",
  40. field: "article_content"
  41. },
  42. articleImage: {
  43. type: DataTypes.STRING(255),
  44. allowNull: false,
  45. defaultValue: null,
  46. primaryKey: false,
  47. autoIncrement: false,
  48. comment: "封面图片",
  49. field: "article_image"
  50. },
  51. articleType: {
  52. type: DataTypes.INTEGER(1).UNSIGNED,
  53. allowNull: false,
  54. defaultValue: null,
  55. primaryKey: false,
  56. autoIncrement: false,
  57. comment: "文章类型 0文章 1视频",
  58. field: "article_type"
  59. },
  60. categoryId: {
  61. type: DataTypes.INTEGER(10).UNSIGNED,
  62. allowNull: false,
  63. defaultValue: null,
  64. primaryKey: false,
  65. autoIncrement: false,
  66. comment: "分类ID",
  67. field: "category_id"
  68. },
  69. articleTags: {
  70. type: DataTypes.STRING(255),
  71. allowNull: false,
  72. defaultValue: null,
  73. primaryKey: false,
  74. autoIncrement: false,
  75. comment: "文章标签,多个用逗号隔开",
  76. field: "article_tags"
  77. },
  78. articleStatus: {
  79. type: DataTypes.INTEGER(1).UNSIGNED,
  80. allowNull: false,
  81. defaultValue: null,
  82. primaryKey: false,
  83. autoIncrement: false,
  84. comment: "文章状态",
  85. field: "article_status"
  86. },
  87. articleAuthor: {
  88. type: DataTypes.STRING(100),
  89. allowNull: false,
  90. defaultValue: null,
  91. primaryKey: false,
  92. autoIncrement: false,
  93. comment: "文章作者",
  94. field: "article_author"
  95. },
  96. articleViews: {
  97. type: DataTypes.INTEGER(10).UNSIGNED,
  98. allowNull: false,
  99. defaultValue: null,
  100. primaryKey: false,
  101. autoIncrement: false,
  102. comment: "浏览次数",
  103. field: "article_views"
  104. },
  105. articleTemplateInfo: {
  106. type: DataTypes.STRING(255),
  107. allowNull: false,
  108. defaultValue: null,
  109. primaryKey: false,
  110. autoIncrement: false,
  111. comment: "文章详情模版",
  112. field: "article_template_info"
  113. },
  114. articleRecommend: {
  115. type: DataTypes.INTEGER(1).UNSIGNED,
  116. allowNull: false,
  117. defaultValue: null,
  118. primaryKey: false,
  119. autoIncrement: false,
  120. comment: "文章推荐 0不推荐 1推荐",
  121. field: "article_recommend"
  122. },
  123. articleTemplateList: {
  124. type: DataTypes.STRING(255),
  125. allowNull: false,
  126. defaultValue: null,
  127. primaryKey: false,
  128. autoIncrement: false,
  129. comment: "文章列表模版",
  130. field: "article_template_list"
  131. },
  132. articleSort: {
  133. type: DataTypes.INTEGER(10).UNSIGNED,
  134. allowNull: false,
  135. defaultValue: null,
  136. primaryKey: false,
  137. autoIncrement: false,
  138. comment: "文章排序",
  139. field: "article_sort"
  140. },
  141. viewAuth: {
  142. type: DataTypes.INTEGER(1).UNSIGNED,
  143. allowNull: false,
  144. defaultValue: null,
  145. primaryKey: false,
  146. autoIncrement: false,
  147. comment: "0 所有人 1超管",
  148. field: "view_auth"
  149. },
  150. adminId: {
  151. type: DataTypes.INTEGER(10).UNSIGNED,
  152. allowNull: false,
  153. defaultValue: null,
  154. primaryKey: false,
  155. autoIncrement: false,
  156. comment: "管理员ID",
  157. field: "admin_id"
  158. },
  159. updateTime: {
  160. type: DataTypes.DATE,
  161. allowNull: false,
  162. defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
  163. primaryKey: false,
  164. autoIncrement: false,
  165. comment: "更新时间",
  166. field: "update_time"
  167. },
  168. createTime: {
  169. type: DataTypes.DATE,
  170. allowNull: false,
  171. defaultValue: null,
  172. primaryKey: false,
  173. autoIncrement: false,
  174. comment: "创建时间",
  175. field: "create_time"
  176. }
  177. };
  178. const options = {
  179. tableName: "szj_articles",
  180. comment: "",
  181. indexes: [{
  182. name: "category_id",
  183. unique: false,
  184. type: "BTREE",
  185. fields: ["category_id"]
  186. }, {
  187. name: "article_status",
  188. unique: false,
  189. type: "BTREE",
  190. fields: ["article_status"]
  191. }]
  192. };
  193. const SzjArticlesModel = sequelize.define("szjArticlesModel", attributes, options);
  194. return SzjArticlesModel;
  195. };