Commit 53fc5d9f by 庄冰

getProductTypeInfo

parent f2e6bb61
......@@ -16,5 +16,10 @@ class ProductTypeCtl extends CtlBase {
const up = await this.service.update(pobj);
return up;
}
async getProductTypeInfo(pobj){
const res = await this.service.getProductTypeInfo(pobj);
return res;
}
}
module.exports = ProductTypeCtl;
......@@ -57,6 +57,31 @@ class ProducttypeService extends ServiceBase {
}
return system.getResultSuccess(this.dao.update(pobj));
}
//获取产品类型信息-用于后台管理页面
async getProductTypeInfo(obj){
// if(!obj || !obj.company_id){
// return system.getResultFail();
// }
var typeones = await this.dao.model.findAll({
attributes:["id","code","name","pic_url","jump_link_type","jump_link"],
where:{p_id:0},raw:true,
order:[["sequence","desc"]]
});
for(var i=0;i<typeones.length;i++){
if(typeones[i] && typeones[i].id)
var typetwos = await this.dao.model.findAll({
attributes:["id","code","name","pic_url"],
where:{p_id:typeones[i].id},raw:true,
order:[["sequence","desc"]]
});
typeones[i]["children"] = typetwos
}
return system.getResultSuccess(typeones);
}
}
module.exports = ProducttypeService;
\ No newline at end of file
module.exports = ProducttypeService;
// var task = new ProducttypeService();
// task.getProductTypeInfo(null).then(d=>{
// console.log(JSON.stringify(d));
// })
\ 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