configs.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* indent size: 2 */
  2. module.exports = app => {
  3. const DataTypes = app.Sequelize;
  4. const Model = app.model.define('Configs', {
  5. config_id: {
  6. type: DataTypes.INTEGER(10).UNSIGNED,
  7. primaryKey: true,
  8. autoIncrement: true
  9. },
  10. field_index: {
  11. type: DataTypes.STRING(100)
  12. },
  13. field_type: {
  14. type: DataTypes.STRING(20)
  15. },
  16. field_label: {
  17. type: DataTypes.STRING(20)
  18. },
  19. field_group: {
  20. type: DataTypes.STRING(50)
  21. },
  22. field_options: {
  23. type: DataTypes.STRING(255)
  24. },
  25. field_desc: {
  26. type: DataTypes.STRING(50)
  27. },
  28. field_status: {
  29. type: DataTypes.INTEGER(1).UNSIGNED
  30. },
  31. field_value: {
  32. type: DataTypes.TEXT,
  33. },
  34. field_sort: {
  35. type: DataTypes.INTEGER(10).UNSIGNED
  36. },
  37. admin_id: {
  38. type: DataTypes.INTEGER(10).UNSIGNED
  39. },
  40. update_time: {
  41. type: DataTypes.TIME
  42. },
  43. create_time: {
  44. type: DataTypes.DATE
  45. }
  46. }, {
  47. tableName: 'szj_configs'
  48. });
  49. Model.associate = function() {
  50. //关联管理员表
  51. Model.belongsTo(app.model.AdminUser,{foreignKey:'admin_id',targetKey:'admin_id',as:'admin_user'});
  52. }
  53. //同步:没有就新建,有就不变
  54. Model.sync();
  55. return Model;
  56. };