Commit c442ea95 by 庄冰

policy

parent a1be3adc
......@@ -110,11 +110,10 @@ class PolicyinfoService extends ServiceBase {
}
async addPolicyByExcel(){
var workbook = xl.readFile("policy7.xlsx");
var workbook = xl.readFile("policy8.xls");
const sheetNames = workbook.SheetNames; // 返回 ['sheet1', 'sheet2']
const worksheet = workbook.Sheets[sheetNames[0]];
var dataa =xl.utils.sheet_to_json(worksheet);
var arr = [];
var that=this;
await this.db.transaction(async function (t) {
......
......@@ -112,6 +112,8 @@ class PolicysubscribeService extends ServiceBase {
if(!obj.policySubscribeId){
return system.getResult(null, "policySubscribeId不能为空");
}
var currentPage = obj.currentPage || 1;
var pageSize = obj.pageSize || 100 ;
var ps = await this.dao.model.findOne({
where:{id:obj.policySubscribeId,openid:obj.openid},
raw:true
......@@ -135,10 +137,27 @@ class PolicysubscribeService extends ServiceBase {
}
var pis = await this.policyinfoDao.model.findAll({//获取该订阅下的政策数据
where:whereObj,raw:true,attributes:attributes,
order:[["id", "DESC"]]
order:[["id", "DESC"]],
offset:(currentPage - 1) * pageSize,
limit:pageSize
});
if(!pis || pis.length<1){
delete whereObj["created_at"];
pis = await this.policyinfoDao.model.findAll({//获取该订阅下的政策数据
where:whereObj,raw:true,attributes:attributes,
order:[["id", "DESC"]],
offset:(currentPage - 1) * pageSize,
limit:pageSize
});
}
var picount = await this.policyinfoDao.model.findAll({//获取该订阅下的政策数据
where:whereObj,raw:true,attributes:["id"],
});
picount = picount.length;
var res = system.getResultSuccess(pis);
res.dataCount = picount;
await this.dao.update({id:obj.policySubscribeId,releaseDate:new Date()});//修改订阅发布日期
return system.getResultSuccess(pis);
return res;
}
}
......
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