szj_admin_user.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. 'use strict';
  2. module.exports = app => {
  3. const DataTypes = app.Sequelize;
  4. const sequelize = app.model;
  5. const attributes = {
  6. adminId: {
  7. type: DataTypes.INTEGER(10).UNSIGNED,
  8. allowNull: false,
  9. defaultValue: null,
  10. primaryKey: true,
  11. autoIncrement: true,
  12. comment: "管理员ID",
  13. field: "admin_id"
  14. },
  15. username: {
  16. type: DataTypes.STRING(20),
  17. allowNull: false,
  18. defaultValue: null,
  19. primaryKey: false,
  20. autoIncrement: false,
  21. comment: null,
  22. field: "username"
  23. },
  24. password: {
  25. type: DataTypes.STRING(255),
  26. allowNull: false,
  27. defaultValue: null,
  28. primaryKey: false,
  29. autoIncrement: false,
  30. comment: null,
  31. field: "password"
  32. },
  33. roleId: {
  34. type: DataTypes.INTEGER(10).UNSIGNED,
  35. allowNull: false,
  36. defaultValue: null,
  37. primaryKey: false,
  38. autoIncrement: false,
  39. comment: null,
  40. field: "role_id"
  41. },
  42. adminStatus: {
  43. type: DataTypes.INTEGER(1).UNSIGNED,
  44. allowNull: false,
  45. defaultValue: null,
  46. primaryKey: false,
  47. autoIncrement: false,
  48. comment: null,
  49. field: "admin_status"
  50. },
  51. loginIp: {
  52. type: DataTypes.STRING(15),
  53. allowNull: false,
  54. defaultValue: null,
  55. primaryKey: false,
  56. autoIncrement: false,
  57. comment: null,
  58. field: "login_ip"
  59. },
  60. loginTime: {
  61. type: DataTypes.DATE,
  62. allowNull: false,
  63. defaultValue: null,
  64. primaryKey: false,
  65. autoIncrement: false,
  66. comment: null,
  67. field: "login_time"
  68. },
  69. loginCount: {
  70. type: DataTypes.INTEGER(10).UNSIGNED,
  71. allowNull: false,
  72. defaultValue: null,
  73. primaryKey: false,
  74. autoIncrement: false,
  75. comment: "登录次数",
  76. field: "login_count"
  77. },
  78. adminToken: {
  79. type: DataTypes.STRING(255),
  80. allowNull: false,
  81. defaultValue: null,
  82. primaryKey: false,
  83. autoIncrement: false,
  84. comment: null,
  85. field: "admin_token"
  86. },
  87. adminCode: {
  88. type: DataTypes.CHAR(6),
  89. allowNull: false,
  90. defaultValue: null,
  91. primaryKey: false,
  92. autoIncrement: false,
  93. comment: null,
  94. field: "admin_code"
  95. },
  96. otherAuth: {
  97. type: DataTypes.STRING(255),
  98. allowNull: false,
  99. defaultValue: null,
  100. primaryKey: false,
  101. autoIncrement: false,
  102. comment: null,
  103. field: "other_auth"
  104. },
  105. actionUser: {
  106. type: DataTypes.INTEGER(10).UNSIGNED,
  107. allowNull: false,
  108. defaultValue: null,
  109. primaryKey: false,
  110. autoIncrement: false,
  111. comment: "操作user_id",
  112. field: "action_user"
  113. },
  114. updateTime: {
  115. type: DataTypes.DATE,
  116. allowNull: false,
  117. defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
  118. primaryKey: false,
  119. autoIncrement: false,
  120. comment: "变动时间",
  121. field: "update_time"
  122. },
  123. createTime: {
  124. type: DataTypes.DATE,
  125. allowNull: false,
  126. defaultValue: null,
  127. primaryKey: false,
  128. autoIncrement: false,
  129. comment: "创建时间",
  130. field: "create_time"
  131. }
  132. };
  133. const options = {
  134. tableName: "szj_admin_user",
  135. comment: "",
  136. indexes: [{
  137. name: "role_id",
  138. unique: false,
  139. type: "BTREE",
  140. fields: ["role_id"]
  141. }, {
  142. name: "username",
  143. unique: false,
  144. type: "BTREE",
  145. fields: ["username"]
  146. }]
  147. };
  148. const SzjAdminUserModel = sequelize.define("szjAdminUserModel", attributes, options);
  149. return SzjAdminUserModel;
  150. };