articles_category.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* indent size: 2 */
  2. module.exports = app => {
  3. const DataTypes = app.Sequelize;
  4. const Model = app.model.define('ArticlesCategory', {
  5. category_id: {
  6. type: DataTypes.INTEGER(10).UNSIGNED,
  7. primaryKey: true,
  8. autoIncrement: true
  9. },
  10. category_name: {
  11. type: DataTypes.STRING(200),
  12. },
  13. category_desc: {
  14. type: DataTypes.STRING(255),
  15. },
  16. category_image: {
  17. type: DataTypes.STRING(255),
  18. },
  19. pid: {
  20. type: DataTypes.INTEGER(10).UNSIGNED,
  21. },
  22. category_sort: {
  23. type: DataTypes.INTEGER(10).UNSIGNED,
  24. },
  25. category_status: {
  26. type: DataTypes.INTEGER(1).UNSIGNED,
  27. },
  28. category_level: {
  29. type: DataTypes.INTEGER(1).UNSIGNED,
  30. },
  31. category_recommend: {
  32. type: DataTypes.INTEGER(1).UNSIGNED,
  33. },
  34. admin_id: {
  35. type: DataTypes.INTEGER(10).UNSIGNED,
  36. },
  37. update_time: {
  38. type: DataTypes.TIME,
  39. },
  40. create_time: {
  41. type: DataTypes.DATE,
  42. }
  43. }, {
  44. tableName: 'szj_articles_category'
  45. });
  46. Model.associate = function() {
  47. //关联角色表
  48. Model.belongsTo(app.model.AdminUser,{foreignKey:'admin_id',targetKey:'admin_id',as:'admin_user'});
  49. }
  50. //同步:没有就新建,有就不变
  51. Model.sync();
  52. return Model;
  53. };