From 14187d6550856aab25aabd20e63bbd4884462fe0 Mon Sep 17 00:00:00 2001 From: maochaoying <925670706@qq.com> Date: Tue, 21 Mar 2023 09:59:49 +0800 Subject: [PATCH] house --- src/model/account.model.js | 9 +++++++-- src/model/house.model.js | 28 ++++++++++++++++++++++++++++ src/router/account.route.js | 4 ++-- 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/model/house.model.js diff --git a/src/model/account.model.js b/src/model/account.model.js index e9d0703..6c47119 100644 --- a/src/model/account.model.js +++ b/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: 超级管理员", }, }); diff --git a/src/model/house.model.js b/src/model/house.model.js new file mode 100644 index 0000000..5c2cb96 --- /dev/null +++ b/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; diff --git a/src/router/account.route.js b/src/router/account.route.js index d2e4986..b29da3f 100644 --- a/src/router/account.route.js +++ b/src/router/account.route.js @@ -14,8 +14,8 @@ const { // 注册接口 router.post( "/register", - auth, - hasAdminPermission, + // auth, + // hasAdminPermission, accountValidator, verifyAccount, bcryptPassword,