User.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. module.exports = app => {
  2. const { STRING, INTEGER, DATE } = app.Sequelize;
  3. const User = app.model.define('users', {
  4. id: {
  5. type: INTEGER,
  6. primaryKey: true,
  7. autoIncrement: true,
  8. notNull: true,
  9. notEmpty: true,
  10. comment: '用户ID',
  11. },
  12. username: {
  13. type: STRING(30),
  14. notNull: true,
  15. notEmpty: true,
  16. comment: '用户名',
  17. },
  18. name: {
  19. type: STRING(30),
  20. notNull: true,
  21. notEmpty: true,
  22. comment: '用户名',
  23. },
  24. password: {
  25. type: STRING,
  26. notNull: true,
  27. notEmpty: true,
  28. defaultValue: '',
  29. comment: '用户密码',
  30. },
  31. salt: {
  32. type: STRING(6),
  33. notNull: true,
  34. notEmpty: true,
  35. defaultValue: '',
  36. comment: '用户密码盐',
  37. },
  38. state: {
  39. type: INTEGER,
  40. notNull: true,
  41. notEmpty: true,
  42. defaultValue: 0,
  43. comment: '用户状态: 二进制状态, 从右到左, 是否激活, 是否禁止登录, 是否禁用 0为正常状态',
  44. },
  45. last_login: {
  46. type: DATE,
  47. notNull: true,
  48. notEmpty: true,
  49. defaultValue: '1971-01-01 00:00',
  50. comment: '最后登录时间',
  51. },
  52. created_at: DATE,
  53. updated_at: DATE,
  54. });
  55. return User;
  56. };