business.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const { DataTypes } = require('sequelize');
  2. const connect = require('./connect');
  3. /*
  4. type: DataTypes.STRING,
  5. allowNull: false,
  6. defaultValue:'',
  7. comment: '名',
  8. */
  9. const model = connect.define(
  10. __filename.slice(__dirname.length + 1).replace('.js', ''),
  11. {
  12. id: {
  13. type: DataTypes.INTEGER,
  14. autoIncrement: true,
  15. primaryKey: true,
  16. comment: 'id',
  17. },
  18. name: {
  19. type: DataTypes.STRING,
  20. allowNull: false,
  21. defaultValue: '',
  22. comment: '名',
  23. },
  24. account: {
  25. type: DataTypes.STRING,
  26. allowNull: false,
  27. defaultValue: '',
  28. comment: '账号',
  29. },
  30. phone: {
  31. type: DataTypes.STRING,
  32. defaultValue: '',
  33. comment: '手机号',
  34. },
  35. company: {
  36. type: DataTypes.STRING,
  37. defaultValue: '',
  38. comment: '公司',
  39. },
  40. cityId: {
  41. type: DataTypes.INTEGER,
  42. defaultValue: 0,
  43. comment: '城市ID',
  44. },
  45. provinceId: {
  46. type: DataTypes.INTEGER,
  47. defaultValue: 0,
  48. comment: '省ID',
  49. },
  50. deadline: {
  51. type: DataTypes.STRING,
  52. defaultValue: '',
  53. comment: '到期时间',
  54. },
  55. pwd: {
  56. type: DataTypes.STRING,
  57. defaultValue: '',
  58. comment: '密码',
  59. },
  60. type: {
  61. type: DataTypes.INTEGER,
  62. defaultValue: 0,
  63. comment: '1审定核证机构2资源减排所有方3两个都选',
  64. },
  65. lastTime: {
  66. type: DataTypes.STRING,
  67. defaultValue: '',
  68. comment: '上次登录时间',
  69. },
  70. },
  71. {
  72. comment: '商家',
  73. hooks: {
  74. beforeFind(option) {
  75. if (!option.order) {
  76. option.order = [['id', 'desc']];
  77. }
  78. },
  79. },
  80. }
  81. );
  82. module.exports = model;