Commit 62b04a20 by lixinming

bug

parent b6b32be9
...@@ -2,7 +2,7 @@ import { ERRORENUM } from "../config/errorEnum"; ...@@ -2,7 +2,7 @@ import { ERRORENUM } from "../config/errorEnum";
import { systemConfig } from "../config/serverConfig"; import { systemConfig } from "../config/serverConfig";
import { EccTableConfig } from "../config/mongoTableConfig"; import { EccTableConfig } from "../config/mongoTableConfig";
import { BizError } from "../util/bizError"; import { BizError } from "../util/bizError";
import { modelMap } from "../model/modelBind"; import { mysqlModelMap } from "../model/sqlModelBind";
/** /**
* 中间件 校验连接对象token * 中间件 校验连接对象token
...@@ -41,8 +41,8 @@ export async function checkMySqlSign(req, res, next) { ...@@ -41,8 +41,8 @@ export async function checkMySqlSign(req, res, next) {
if (sign != systemConfig.sign) return next( new BizError(ERRORENUM.身份验证失败, `传入的sign值为:${sign}`) ); if (sign != systemConfig.sign) return next( new BizError(ERRORENUM.身份验证失败, `传入的sign值为:${sign}`) );
if (!table) return next( new BizError(ERRORENUM.缺少必要参数_表名, `传入的table值为:${table}`) ); if (!table) return next( new BizError(ERRORENUM.缺少必要参数_表名, `传入的table值为:${table}`) );
if (!modelMap[table]) return next( new BizError(ERRORENUM.不存在表, `传入的table值为:${table}`) ); if (!mysqlModelMap[table]) return next( new BizError(ERRORENUM.不存在表, `传入的table值为:${table}`) );
req.tableModel = modelMap[table]; req.tableModel = mysqlModelMap[table];
next(); next();
} }
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { TablesConfig } from "../config/mysqlTableConfig"; import { TablesConfig } from "../config/mysqlTableConfig";
import { mysqlDB } from "../db/mysql/mysqlInit"; import { mysqlDB } from "../db/mysql/mysqlInit";
let baseDB = {}; let mysqlModelMap = {};
export async function initMysqlModel() { export async function initMysqlModel() {
...@@ -20,7 +20,7 @@ export async function initMysqlModel() { ...@@ -20,7 +20,7 @@ export async function initMysqlModel() {
let model = mysqlDB.define( tableName, schema, schemaConf); let model = mysqlDB.define( tableName, schema, schemaConf);
baseDB[tableName] = await model.sync({}).then(); mysqlModelMap[tableName] = await model.sync({}).then();
} }
...@@ -31,11 +31,11 @@ export async function initMysqlModel() { ...@@ -31,11 +31,11 @@ export async function initMysqlModel() {
if (item) { if (item) {
let {type, check} = item; let {type, check} = item;
if (type == "hasOne") { if (type == "hasOne") {
baseDB[check].hasOne(baseDB[tableName]); mysqlModelMap[check].hasOne(mysqlModelMap[tableName]);
} else if (type == "hasMany") { } else if (type == "hasMany") {
baseDB[check].hasMany(baseDB[tableName]); mysqlModelMap[check].hasMany(mysqlModelMap[tableName]);
} }
baseDB[tableName].belongsTo(baseDB[check]); mysqlModelMap[tableName].belongsTo(mysqlModelMap[check]);
} }
}); });
} }
...@@ -43,4 +43,4 @@ export async function initMysqlModel() { ...@@ -43,4 +43,4 @@ export async function initMysqlModel() {
} }
export { baseDB }; export { mysqlModelMap };
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment