Commit 0c7752d3 by chenjinjing

no message

parent 302fb886
......@@ -69,7 +69,7 @@ function analysisParamToWhere(param, column) {
let selectParam:any = {where};
if (column && column.length) selectParam.attributes = column;
if (order) selectParam.order = order;
if (order && order.length) selectParam.order = order;
if (limit) selectParam.limit = limit;
return selectParam;
}
......@@ -159,6 +159,7 @@ export async function selectDataToTableAssociation(tableModel, includeConf, para
}
/**
* 多表联查
* @param tableModel
......
......@@ -29,8 +29,8 @@ export const TablesConfig = [
},
loginId:{type:Sequelize.STRING(100), allowNull:false}, //登录账号
pwd:{type:Sequelize.STRING(100), allowNull:false}, //密码
token:{type:Sequelize.STRING(100), allowNull:false},
tokenMs:{type:Sequelize.DATE, allowNull:false, defaultValue:Sequelize.NOW}
token:{type:Sequelize.STRING(100), allowNull:true},
tokenMs:{type:Sequelize.DATE, allowNull:true, defaultValue:Sequelize.NOW}
},
association: []
},
......@@ -106,7 +106,7 @@ export const TablesConfig = [
theme: {type:Sequelize.STRING(100), allowNull:false},//主题
themeType: {type:Sequelize.INTEGER, allowNull:false}, //主题类型
dataMonth: {type:Sequelize.DATE, allowNull:false}, //数据月份
bId: {type:Sequelize.STRING(100), allowNull:false, defaultValue:'[]'}, //支部表id 外键 [1,2] --多选
bId: {type:Sequelize.INTEGER, allowNull:false, defaultValue:'[]'}, //支部表id 外键
fileName: {type:Sequelize.STRING(100), allowNull:true, defaultValue:'[]'}, //文件名称 ["",""] --多选
fileType: {type:Sequelize.INTEGER, allowNull:true}, //文件类型
uploadTime: {type:Sequelize.DATE, allowNull:true, defaultValue:Sequelize.NOW}, //上传时间
......@@ -235,8 +235,10 @@ export const TablesConfig = [
learningCompleted: {type:Sequelize.INTEGER, allowNull:false, defaultValue:1}//是否已完成 1:正在进行、2:阅读完成
},
association: [
{type: "hasOne", check: "partyMember"},
{type: "hasOne", check: "memberLearning"}
{type: "belongsTo", check:"partyMember", foreignKey: "pmId", targetKey:"pmId"},
{type: "belongsTo", check:"memberLearning", foreignKey: "mlId", targetKey:"mlId"},
// {type: "hasOne", check: "partyMember"},
// {type: "hasOne", check: "memberLearning"}
]
},
{
......
......@@ -35,7 +35,10 @@ export async function initMysqlModel() {
} else if (type == "hasMany") {
mysqlModelMap[check].hasMany(mysqlModelMap[tableName]);
}
mysqlModelMap[tableName].belongsTo(mysqlModelMap[check]);
mysqlModelMap[tableName].belongsTo(mysqlModelMap[check], {
foreignKey: item.foreignKey,
targetKey: item.targetKey
});
}
});
}
......
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