Commit 4db671c8 by 任晓松

add getAllPathName

parent 382ba98b
...@@ -6,6 +6,7 @@ class ProductAPI extends WEBBase { ...@@ -6,6 +6,7 @@ class ProductAPI extends WEBBase {
constructor() { constructor() {
super(); super();
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve"); this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
} }
/** /**
...@@ -41,6 +42,9 @@ class ProductAPI extends WEBBase { ...@@ -41,6 +42,9 @@ class ProductAPI extends WEBBase {
case "getOrderInfo"://获取订单列表信息 case "getOrderInfo"://获取订单列表信息
opResult = await this.utilsOrderSve.getOrderInfo(pobj, pobj.actionBody); opResult = await this.utilsOrderSve.getOrderInfo(pobj, pobj.actionBody);
break; break;
case "getPathName":
opResult = await this.utilsProductSve.getAllPathName(pobj);
break;
case "getOrderStatisticsByUappId": case "getOrderStatisticsByUappId":
opResult = await this.utilsOrderSve.getOrdersStatisticsByUappId(pobj); opResult = await this.utilsOrderSve.getOrdersStatisticsByUappId(pobj);
break; break;
......
...@@ -153,6 +153,44 @@ class UtilsProductService extends AppServiceBase { ...@@ -153,6 +153,44 @@ class UtilsProductService extends AppServiceBase {
let result = await this.restPostUrl(pobj,url); let result = await this.restPostUrl(pobj,url);
return result; return result;
} }
}
module.exports = UtilsProductService;
/**
* 根据path_name 聚合
* @param pobj
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|any>}
*/
async getAllPathName(pobj){
let url = settings.centerAppUrl() + 'action/opProduct/springBoard';
pobj.actionType = 'getAllPathName';
let result = await this.restPostUrl(pobj,url);
if(result.status !=0){
return system.getResultFail(-1,'获取数据失败,请稍后再试!');
}
let data = result.data;
let map = new Map();
for(let i =0;i<data.length;i++){
let item = data[i];
let strs = item.path_name.split('/');
let classOne = strs[1];
let classTwo = strs[2];
if(map.has(classOne)){
let val = map.get(classOne);
val.push(classTwo)
map.set(classOne,val);
}else{
let arr = [];
arr.push(classTwo)
map.set(classOne,arr);
}
}
let resultData = [];
map.forEach((v,k) =>{
let obj = {};
obj['key'] = k;
obj['data'] = v;
resultData.push(obj)
})
return system.getResult(resultData);
}
}
module.exports = UtilsProductService;
\ 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