Commit d89054b4 by 庄冰

policySubscribe

parent b4939a85
...@@ -65,6 +65,9 @@ class PolicyAPI extends APIBase { ...@@ -65,6 +65,9 @@ class PolicyAPI extends APIBase {
case "policyTypeCount"://政策类型统计计数 case "policyTypeCount"://政策类型统计计数
opResult = this.policyinfoSve.policyTypeCount(pobj); opResult = this.policyinfoSve.policyTypeCount(pobj);
break; break;
case "policySubscribeQuery"://政策订阅检索列表(通过订阅信息查询订阅的政策信息)
opResult = this.policysubscribeSve.policySubscribeQuery(pobj);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -3,6 +3,7 @@ const ServiceBase = require("../../sve.base"); ...@@ -3,6 +3,7 @@ const ServiceBase = require("../../sve.base");
class PolicysubscribeService extends ServiceBase { class PolicysubscribeService extends ServiceBase {
constructor() { constructor() {
super("dbpolicy", ServiceBase.getDaoName(PolicysubscribeService)); super("dbpolicy", ServiceBase.getDaoName(PolicysubscribeService));
this.policyinfoDao = system.getObject("db.dbpolicy.policyinfoDao");
} }
//提交政策订阅 //提交政策订阅
async submitPolicysubscribe(pobj){ async submitPolicysubscribe(pobj){
...@@ -78,9 +79,46 @@ class PolicysubscribeService extends ServiceBase { ...@@ -78,9 +79,46 @@ class PolicysubscribeService extends ServiceBase {
paramObj["openid"] = obj.openid; paramObj["openid"] = obj.openid;
var resList = await this.dao.model.findAll({ var resList = await this.dao.model.findAll({
attributes:["id","policyProvince","policyTypes","created_at"], attributes:["id","policyProvince","policyTypes","created_at"],
where:paramObj,raw:true where:paramObj,raw:true,
order:[["id", "DESC"]]
}); });
return system.getResultSuccess(resList); return system.getResultSuccess(resList);
} }
//政策订阅检索列表
async policySubscribeQuery(pobj){
var app = pobj.appInfo;
var obj = pobj.actionBody;
var paramObj={uapp_id:app.uapp_id};
if(!obj.openid){
return system.getResult(null, "openid不能为空");
}
if(!obj.policySubscribeId){
return system.getResult(null, "policySubscribeId不能为空");
}
var ps = await this.dao.model.findOne({
where:{id:obj.policySubscribeId,openid:obj.openid},
raw:true
});
if(!ps || !ps.id){
return system.getResult(null, "订阅信息不存在");
}
//{ where: { id: { [this.db.Op.in]: ids } } }
var whereObj = {};
var attributes =["id","policyType","policyTypeName","policyDate","policyCity","policyProvince",
"policyLinkUrl","policySource","policyName","policyNo"];
if(ps.policyProvince){
whereObj["policyProvince"] = ps.policyProvince;
}
if(ps.policyTypes){
var types = ps.policyTypes.split(",");
whereObj["policyType"] = { [this.db.Op.in]: types};
}
var pis = await this.policyinfoDao.model.findAll({
where:whereObj,raw:true,attributes:attributes,
order:[["id", "DESC"]]
});
return system.getResultSuccess(pis);
}
} }
module.exports = PolicysubscribeService; module.exports = PolicysubscribeService;
\ 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