Browse Source

house

master
maochaoying 2 years ago
parent
commit
14187d6550
  1. 9
      src/model/account.model.js
  2. 28
      src/model/house.model.js
  3. 4
      src/router/account.route.js

9
src/model/account.model.js

@ -7,18 +7,23 @@ const Account = seq.define("chicken_account", {
username: {
type: DataTypes.STRING,
allowNull: false,
comment: "用户username,为手机号类型",
unique: true,
comment: "用户名, 唯一",
},
password: {
type: DataTypes.CHAR(64),
allowNull: false,
comment: "密码",
},
name: {
type: DataTypes.STRING,
allowNull: true,
comment: "厂主姓名",
},
role: {
type: DataTypes.INTEGER,
allowNull: false,
comment: "用户角色, 0: 普通管理员; 1: 超级管理员",
comment: "用户角色, 0: 厂主; 1: 超级管理员",
},
});

28
src/model/house.model.js

@ -0,0 +1,28 @@
const { DataTypes } = require("sequelize");
const seq = require("../db/seq");
const House = seq.define("chicken_house", {
// id 会被sequelize自动创建, 管理
house_name: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
comment: "鸡场名称",
},
area: {
type: DataTypes.STRING,
allowNull: false,
comment: "所在地区",
},
belong: {
type: DataTypes.INTEGER,
allowNull: false,
comment: "所属农场主的id,相当于外键",
},
});
// 强制同步数据库(创建数据表)
// House.sync({ force: true });
module.exports = House;

4
src/router/account.route.js

@ -14,8 +14,8 @@ const {
// 注册接口
router.post(
"/register",
auth,
hasAdminPermission,
// auth,
// hasAdminPermission,
accountValidator,
verifyAccount,
bcryptPassword,

Loading…
Cancel
Save