Commit 892b06ad by 兰国旗

laolan

parent d8252066
...@@ -25,5 +25,10 @@ class ProductTypeCtl extends CtlBase { ...@@ -25,5 +25,10 @@ class ProductTypeCtl extends CtlBase {
const res = await this.service.getProductTypeInfo(pobj); const res = await this.service.getProductTypeInfo(pobj);
return res; return res;
} }
async delete(pobj, qobj, req) {
const up = await this.service.delete(pobj);
return up;
}
} }
module.exports = ProductTypeCtl; module.exports = ProductTypeCtl;
...@@ -52,6 +52,8 @@ class BottommenuconfigService extends ServiceBase { ...@@ -52,6 +52,8 @@ class BottommenuconfigService extends ServiceBase {
async update(pobj) { async update(pobj) {
var functionName = "bottomMenuConfig";
await this.redisdel.redisInfo(functionName);
return system.getResultSuccess(this.dao.update(pobj)); return system.getResultSuccess(this.dao.update(pobj));
} }
} }
......
...@@ -20,6 +20,14 @@ class CycleproductService extends ServiceBase { ...@@ -20,6 +20,14 @@ class CycleproductService extends ServiceBase {
try { try {
var functionName = "cycleProduct"; var functionName = "cycleProduct";
await this.redisdel.redisInfo(functionName); await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
......
...@@ -21,6 +21,14 @@ class PopularrecommendationService extends ServiceBase { ...@@ -21,6 +21,14 @@ class PopularrecommendationService extends ServiceBase {
var functionName = "popularRecommendationList"; var functionName = "popularRecommendationList";
await this.redisdel.redisInfo(functionName); await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
return system.getResultSuccess(this.dao.update(pobj)); return system.getResultSuccess(this.dao.update(pobj));
} }
} }
......
...@@ -15,6 +15,14 @@ class ProductService extends ServiceBase { ...@@ -15,6 +15,14 @@ class ProductService extends ServiceBase {
async update(pobj) { async update(pobj) {
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
return system.getResultSuccess(this.dao.update(pobj)); return system.getResultSuccess(this.dao.update(pobj));
} }
...@@ -24,14 +32,14 @@ class ProductService extends ServiceBase { ...@@ -24,14 +32,14 @@ class ProductService extends ServiceBase {
* @param pobj * @param pobj
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getProductsByType(pobj){ async getProductsByType(pobj) {
const type = await this.producttypeDao.findOne({code:pobj.typeName},[]); const type = await this.producttypeDao.findOne({ code: pobj.typeName }, []);
if(!type){ if (!type) {
return system.getResultFail(-1,'获取产品类型数据失败'); return system.getResultFail(-1, '获取产品类型数据失败');
} }
let products = await this.dao.model.findAll({ let products = await this.dao.model.findAll({
attributes:["code","name"], attributes: ["code", "name"],
where:{product_type_id:type.id,is_enabled:1},raw:true where: { product_type_id: type.id, is_enabled: 1 }, raw: true
}); });
return system.getResult(products) return system.getResult(products)
} }
......
...@@ -5,12 +5,12 @@ class ProducttypeService extends ServiceBase { ...@@ -5,12 +5,12 @@ class ProducttypeService extends ServiceBase {
constructor() { constructor() {
super("aggregation", ServiceBase.getDaoName(ProducttypeService)); super("aggregation", ServiceBase.getDaoName(ProducttypeService));
} }
async findAndCountAll (obj) { async findAndCountAll(obj) {
let res = await this.dao.findAndCountAll(obj); let res = await this.dao.findAndCountAll(obj);
if(obj && obj.search && obj.search.p_id === 0 && res && res.results && res.results.rows && res.results.rows.length>0){ if (obj && obj.search && obj.search.p_id === 0 && res && res.results && res.results.rows && res.results.rows.length > 0) {
for(var i=0;i<res.results.rows.length;i++){ for (var i = 0; i < res.results.rows.length; i++) {
if(res.results.rows[i].id){ if (res.results.rows[i].id) {
var count = await this.dao.findCount({ where: {p_id:res.results.rows[i].id} }); var count = await this.dao.findCount({ where: { p_id: res.results.rows[i].id } });
res.results.rows[i].dataValues.childCount = count; res.results.rows[i].dataValues.childCount = count;
} }
} }
...@@ -39,19 +39,19 @@ class ProducttypeService extends ServiceBase { ...@@ -39,19 +39,19 @@ class ProducttypeService extends ServiceBase {
// return system.getResultFail(-106, "名称最多4位字符"); // return system.getResultFail(-106, "名称最多4位字符");
// } // }
// } // }
if(pobj.p_code){ if (pobj.p_code) {
// if (pobj.name && pobj.name.length > 5) { // if (pobj.name && pobj.name.length > 5) {
// return system.getResultFail(-106, "请输入5字以内名称"); // return system.getResultFail(-106, "请输入5字以内名称");
// } // }
var p_type = await this.dao.model.findOne({ var p_type = await this.dao.model.findOne({
where:{code:pobj.p_code,p_id:0},raw:true where: { code: pobj.p_code, p_id: 0 }, raw: true
}); });
if(!p_type){ if (!p_type) {
return system.getResultFail(-300,"产品一类不存在"); return system.getResultFail(-300, "产品一类不存在");
} }
pobj.p_id = p_type.id; pobj.p_id = p_type.id;
pobj.p_name = p_type.name; pobj.p_name = p_type.name;
}else if (!pobj.jump_link_type || !pobj.jump_link) { } else if (!pobj.jump_link_type || !pobj.jump_link) {
return system.getResultFail(-104, "连接不能为空"); return system.getResultFail(-104, "连接不能为空");
} }
return system.getResultSuccess(this.dao.create(pobj)); return system.getResultSuccess(this.dao.create(pobj));
...@@ -60,7 +60,7 @@ class ProducttypeService extends ServiceBase { ...@@ -60,7 +60,7 @@ class ProducttypeService extends ServiceBase {
if (!pobj.pic_url) { if (!pobj.pic_url) {
return system.getResultFail(-101, "图标不能为空"); return system.getResultFail(-101, "图标不能为空");
} }
if (!pobj.sequence && pobj.sequence!==0) { if (!pobj.sequence && pobj.sequence !== 0) {
return system.getResultFail(-102, "排序不能为空"); return system.getResultFail(-102, "排序不能为空");
} }
// if (!pobj.jump_link_type || !pobj.jump_link) { // if (!pobj.jump_link_type || !pobj.jump_link) {
...@@ -72,30 +72,58 @@ class ProducttypeService extends ServiceBase { ...@@ -72,30 +72,58 @@ class ProducttypeService extends ServiceBase {
// if (pobj.name && pobj.name.length > 4) { // if (pobj.name && pobj.name.length > 4) {
// return system.getResultFail(-106, "名称最多4位字符"); // return system.getResultFail(-106, "名称最多4位字符");
// } // }
try {
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) {
console.log(error)
}
return system.getResultSuccess(this.dao.update(pobj)); return system.getResultSuccess(this.dao.update(pobj));
} }
//获取产品类型信息-用于后台管理页面 //获取产品类型信息-用于后台管理页面
async getProductTypeInfo(obj){ async getProductTypeInfo(obj) {
// if(!obj || !obj.company_id){ // if(!obj || !obj.company_id){
// return system.getResultFail(); // return system.getResultFail();
// } // }
var typeones = await this.dao.model.findAll({ var typeones = await this.dao.model.findAll({
attributes:["id","code","name","pic_url","jump_link_type","jump_link"], attributes: ["id", "code", "name", "pic_url", "jump_link_type", "jump_link"],
where:{p_id:0},raw:true, where: { p_id: 0 }, raw: true,
order:[["sequence","desc"]] order: [["sequence", "desc"]]
}); });
for(var i=0;i<typeones.length;i++){ for (var i = 0; i < typeones.length; i++) {
if(typeones[i] && typeones[i].id) if (typeones[i] && typeones[i].id)
var typetwos = await this.dao.model.findAll({ var typetwos = await this.dao.model.findAll({
attributes:["id","code","name","pic_url"], attributes: ["id", "code", "name", "pic_url"],
where:{p_id:typeones[i].id},raw:true, where: { p_id: typeones[i].id }, raw: true,
order:[["sequence","desc"]] order: [["sequence", "desc"]]
}); });
typeones[i]["children"] = typetwos typeones[i]["children"] = typetwos
} }
return system.getResultSuccess(typeones); return system.getResultSuccess(typeones);
} }
async delete(pobj){
try {
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) {
console.log(error)
}
return system.getResultSuccess(this.dao.delete(pobj));
}
} }
module.exports = ProducttypeService; module.exports = ProducttypeService;
// var task = new ProducttypeService(); // var task = new ProducttypeService();
......
...@@ -56,6 +56,14 @@ class RotationchartService extends ServiceBase { ...@@ -56,6 +56,14 @@ class RotationchartService extends ServiceBase {
try { try {
var functionName = "rotationChartList"; var functionName = "rotationChartList";
await this.redisdel.redisInfo(functionName); await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
...@@ -66,6 +74,14 @@ class RotationchartService extends ServiceBase { ...@@ -66,6 +74,14 @@ class RotationchartService extends ServiceBase {
try { try {
var functionName = "rotationChartList"; var functionName = "rotationChartList";
await this.redisdel.redisInfo(functionName); await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
......
...@@ -16,6 +16,20 @@ class SecondlevelneedconfigService extends ServiceBase { ...@@ -16,6 +16,20 @@ class SecondlevelneedconfigService extends ServiceBase {
if (!pobj.recommend_product_quantity) { if (!pobj.recommend_product_quantity) {
return system.getResultFail(-103, "推荐产品数量不能为空"); return system.getResultFail(-103, "推荐产品数量不能为空");
} }
try {
var functionName = "popularRecommendationList";
await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) {
console.log(error)
}
return system.getResultSuccess(this.dao.update(pobj)); return system.getResultSuccess(this.dao.update(pobj));
} }
} }
......
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