product_suppliers.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* indent size: 2 */
  2. module.exports = app => {
  3. const DataTypes = app.Sequelize;
  4. const Model = app.model.define('ProductSuppliers', {
  5. supplier_id: {
  6. type: DataTypes.INTEGER(10).UNSIGNED,
  7. primaryKey: true,
  8. autoIncrement: true
  9. },
  10. supplier_name: {
  11. type: DataTypes.STRING(255),
  12. allowNull: true
  13. },
  14. supplier_phone: {
  15. type: DataTypes.STRING(255),
  16. allowNull: true
  17. },
  18. supplier_status: {
  19. type: DataTypes.INTEGER(1).UNSIGNED,
  20. allowNull: true
  21. },
  22. admin_id: {
  23. type: DataTypes.INTEGER(10).UNSIGNED,
  24. allowNull: true
  25. },
  26. update_time: {
  27. type: DataTypes.TIME
  28. },
  29. create_time: {
  30. type: DataTypes.DATE,
  31. allowNull: true
  32. }
  33. }, {
  34. tableName: 'szj_product_suppliers'
  35. });
  36. Model.associate = function() {
  37. //关联管理员表
  38. Model.belongsTo(app.model.AdminUser,{foreignKey:'admin_id',targetKey:'admin_id',as:'admin_user'});
  39. }
  40. //同步:没有就新建,有就不变
  41. Model.sync();
  42. return Model;
  43. };