szj_articles_category.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. 'use strict';
  2. module.exports = app => {
  3. const DataTypes = app.Sequelize;
  4. const sequelize = app.model;
  5. const attributes = {
  6. categoryId: {
  7. type: DataTypes.INTEGER(10).UNSIGNED,
  8. allowNull: false,
  9. defaultValue: null,
  10. primaryKey: true,
  11. autoIncrement: true,
  12. comment: "自增ID",
  13. field: "category_id"
  14. },
  15. categoryName: {
  16. type: DataTypes.STRING(200),
  17. allowNull: false,
  18. defaultValue: null,
  19. primaryKey: false,
  20. autoIncrement: false,
  21. comment: "分类名称",
  22. field: "category_name"
  23. },
  24. categoryDesc: {
  25. type: DataTypes.STRING(255),
  26. allowNull: false,
  27. defaultValue: null,
  28. primaryKey: false,
  29. autoIncrement: false,
  30. comment: "分类描述",
  31. field: "category_desc"
  32. },
  33. categoryImage: {
  34. type: DataTypes.STRING(255),
  35. allowNull: false,
  36. defaultValue: null,
  37. primaryKey: false,
  38. autoIncrement: false,
  39. comment: "分类图片",
  40. field: "category_image"
  41. },
  42. pid: {
  43. type: DataTypes.INTEGER(10).UNSIGNED,
  44. allowNull: false,
  45. defaultValue: null,
  46. primaryKey: false,
  47. autoIncrement: false,
  48. comment: "上级id",
  49. field: "pid"
  50. },
  51. categorySort: {
  52. type: DataTypes.INTEGER(10).UNSIGNED,
  53. allowNull: false,
  54. defaultValue: null,
  55. primaryKey: false,
  56. autoIncrement: false,
  57. comment: "分类排序",
  58. field: "category_sort"
  59. },
  60. categoryStatus: {
  61. type: DataTypes.INTEGER(1).UNSIGNED,
  62. allowNull: false,
  63. defaultValue: null,
  64. primaryKey: false,
  65. autoIncrement: false,
  66. comment: "分类状态",
  67. field: "category_status"
  68. },
  69. categoryLevel: {
  70. type: DataTypes.INTEGER(1).UNSIGNED,
  71. allowNull: false,
  72. defaultValue: null,
  73. primaryKey: false,
  74. autoIncrement: false,
  75. comment: "分类等级",
  76. field: "category_level"
  77. },
  78. categoryRecommend: {
  79. type: DataTypes.INTEGER(1).UNSIGNED,
  80. allowNull: false,
  81. defaultValue: null,
  82. primaryKey: false,
  83. autoIncrement: false,
  84. comment: "是否推荐",
  85. field: "category_recommend"
  86. },
  87. adminId: {
  88. type: DataTypes.INTEGER(10).UNSIGNED,
  89. allowNull: false,
  90. defaultValue: null,
  91. primaryKey: false,
  92. autoIncrement: false,
  93. comment: "管理员ID",
  94. field: "admin_id"
  95. },
  96. updateTime: {
  97. type: DataTypes.DATE,
  98. allowNull: false,
  99. defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
  100. primaryKey: false,
  101. autoIncrement: false,
  102. comment: "更新时间",
  103. field: "update_time"
  104. },
  105. createTime: {
  106. type: DataTypes.DATE,
  107. allowNull: false,
  108. defaultValue: null,
  109. primaryKey: false,
  110. autoIncrement: false,
  111. comment: "添加时间",
  112. field: "create_time"
  113. }
  114. };
  115. const options = {
  116. tableName: "szj_articles_category",
  117. comment: "",
  118. indexes: [{
  119. name: "category_status",
  120. unique: false,
  121. type: "BTREE",
  122. fields: ["category_status"]
  123. }]
  124. };
  125. const SzjArticlesCategoryModel = sequelize.define("szjArticlesCategoryModel", attributes, options);
  126. return SzjArticlesCategoryModel;
  127. };