Commit d7462a05 by lixinming

no message

parent 1825e86e
......@@ -7,7 +7,7 @@ function analysisParamToWhere(param, column) {
let where
for (let key in param) {// 模糊查询{"字段名":{"%like%":'三'}}
if (param[key]["%like%"]) {
where[key] = {[Op.like]:`%${param[key]}%`};
where[key] = {[Op.like]:`%${param[key]["%like%"]}%`};
} else {
where[key] = param[key];
}
......@@ -101,3 +101,31 @@ export async function selectDataToTableAssociation(tableModel, includeConf, para
let data = tableModel.findAll(selectParam);
return {data};
}
/**
* 多表联查
* @param tableModel
* @param includeConf {"表名":["",""] }
* @param param
* @param column
* @returns
*/
export async function selectDataToTableAssociationToPage(tableModel, includeConf, param, column, pageNumber:number, pageSize:number) {
let include = [];
for (let tableName in includeConf) {
if (!modelMap[tableName]) throw new BizError(ERRORENUM.不存在表, `尝试进行多表联查,但是不存在${tableName}`);
include.push({
attributes : includeConf[tableName],
module : modelMap[tableName]
});
}
let selectParam:any = analysisParamToWhere(param, column);
selectParam.include = include;
selectParam.limit = pageSize || 10;
selectParam.offset = (pageNumber-1)*10;
let data = tableModel.findAll(selectParam);
return {data};
}
\ No newline at end of file
......@@ -117,7 +117,7 @@ export const TablesConfig = [
dId: {type:Sequelize.STRING(100), allowNull:false, defaultValue:'[]'}, //所属科室表id 外键 [1,2] --多选
askForTime: {type:Sequelize.DATE, allowNull:false}, //申请入党时间 --入党积极分子录入、入党申请录入
listedAsActivistsTime: {type:Sequelize.DATE, allowNull:false}, //列为积极分子时间 --入党积极分子录入
liaison: {type:Sequelize.STRING(100), allowNull:false, defaultValue:'[]'}, //联系人 --入党积极分子录入 ["",""] --多选
liaison: {type:Sequelize.STRING(100), allowNull:false, defaultValue:'[]'}, //联系人 --入党积极分子录入 "" --多选
talkTime: {type:Sequelize.DATE, allowNull:false}, //谈话时间 --入党申请录入
partyState: {type:Sequelize.INTEGER, allowNull:false, defaultValue:1}, //党员状态 1:在党、2:退党
isAdmin: {type:Sequelize.BOOLEAN, allowNull:false, defaultValue:false}, //是否为管理员
......
......@@ -19,6 +19,7 @@ export function setRouter(httpServer){
httpServer.post('/yfs/dataserver/mysql/table/find/manytopage', checkMySqlSign, asyncHandler(findManyToPageData));
httpServer.post('/yfs/dataserver/mysql/table/find/count', checkMySqlSign, asyncHandler(findCountData));
httpServer.post('/yfs/dataserver/mysql/table/find/aggragate', checkMySqlSign, asyncHandler(findAggragateData));
httpServer.post('/yfs/dataserver/mysql/table/find/aggragatetopage', checkMySqlSign, asyncHandler(findAggragateDataToPage));
}
......@@ -105,3 +106,14 @@ async function findAggragateData(req, res) {
let result = await findBiz.selectDataToTableAssociation(table, includeConf, param, column);
res.success(result);
}
async function findAggragateDataToPage(req, res) {
let table = req.tableModel;
let reqConf = {param:'Object', includeConf:'Object', column:"[String]", pageNumber:'Number', pageSize:'Number', };
let { param, includeConf, column, pageNumber, pageSize } = eccReqParamater(reqConf, req.body);
let result = await findBiz.selectDataToTableAssociationToPage(table, includeConf, param, column, pageNumber, pageSize);
res.success(result);
}
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