Commit d60d6dd4 by 兰国旗

Merge branch 'gsb-marketplat-mag' of gitlab.gongsibao.com:jiangyong/zhichan into gsb-marketplat-mag

parents 33ba76bc 3071545a
......@@ -16,5 +16,16 @@ class ProductCtl extends CtlBase {
const up = await this.service.update(pobj);
return up;
}
/**
* 获取某一类下的产品
* @create rxs
* @param pobj
* @returns {Promise<void>}
*/
async getProductsByType(pobj){
const result = await this.service.getProductsByType(pobj);
return result;
}
}
module.exports = ProductCtl;
......@@ -4,6 +4,7 @@ const settings = require("../../../../config/settings");
class ProductService extends ServiceBase {
constructor() {
super("aggregation", ServiceBase.getDaoName(ProductService));
this.producttypeDao = system.getObject('db.aggregation.producttypeDao')
}
async getImgList(pobj) {
let res = await this.dao.findAndCountAll(pobj);
......@@ -48,5 +49,28 @@ class ProductService extends ServiceBase {
}
return system.getResultSuccess(this.dao.update(pobj));
}
/**
* 获取某一类下的产品
* @create rxs
* @param pobj
* @returns {Promise<void>}
*/
async getProductsByType(pobj){
const type = await this.producttypeDao.findOne({name:pobj.typeName},[]);
if(!type){
return system.getResultFail(-1,'获取产品类型数据失败');
}
let products = await this.dao.model.findAll({
attributes:["name"],
where:{product_type_id:type.id},raw:true
});
let names = '';
products.forEach(item =>{
names += item.name +','
})
names = names.substring(0,names.length-1);
return system.getResult(names)
}
}
module.exports = ProductService;
\ 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