Commit faa7f91b by 兰国旗

laolan

parent c9a8a2e4
...@@ -6,6 +6,10 @@ class ProductTypeCtl extends CtlBase { ...@@ -6,6 +6,10 @@ class ProductTypeCtl extends CtlBase {
constructor() { constructor() {
super("aggregation", CtlBase.getServiceName(ProductTypeCtl)); super("aggregation", CtlBase.getServiceName(ProductTypeCtl));
} }
async findAndCountAll(obj){
var res = await this.service.findAndCountAll(obj);
return res;
}
async create(pobj, qobj, req) { async create(pobj, qobj, req) {
pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : ""; pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : "";
const up = await this.service.create(pobj); const up = await this.service.create(pobj);
......
const system=require("../../../system"); const system = require("../../../system");
const Dao=require("../../dao.base"); const Dao = require("../../dao.base");
class ProducttypeDao extends Dao{ class ProducttypeDao extends Dao {
constructor(){ constructor() {
super(Dao.getModelName(ProducttypeDao)); super(Dao.getModelName(ProducttypeDao));
} }
async refQuery(qobj) { async findAndCountAll(req) {
var w = qobj.refwhere ? qobj.refwhere : {}; var params = {
w["p_id"] = 0; // company_id: req.actionBody.company_id
if (qobj.levelinfo) { company_id: 10
w[qobj.levelinfo.levelfield] = qobj.levelinfo.level; };
} var returnRes = {
if (qobj.parentinfo) { results: {rows:[],count:[]}
w[qobj.parentinfo.parentfield] = qobj.parentinfo.parentcode; };
} var dataCount = "select count(1) as dataCount from mc_product_type where deleted_at is null and p_id = 0 and company_id = :company_id ";
//如果需要控制数据权限 var sql = "select * from mc_product_type where deleted_at is null and p_id = 0 and company_id = :company_id ";
if (qobj.datapriv) { var childData = "select *,count(1) as childCount from mc_product_type where p_id !=0 and company_id = :company_id group by p_id";
w["id"] = { [this.db.Op.in]: qobj.datapriv };
} var list = await this.customQuery(sql, params);
if (qobj.likestr) { returnRes.results.rows = list;
w[qobj.fields[0]] = { [this.db.Op.like]: "%" + qobj.likestr + "%" };
return this.model.findAll({ where: w, attributes: qobj.fields }); var tmpResultCount = await this.customQuery(dataCount, params);
} else { returnRes.results.count = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return this.model.findAll({ where: w, attributes: qobj.fields });
var childrenData = await this.customQuery(childData, params);
for(var i=0;i<childrenData.length;i++){
returnRes.results.rows[i].childCount = childrenData && childrenData[i].childCount > 0 ? childrenData[i].childCount : 0;
} }
console.log(returnRes)
return returnRes;
} }
} }
module.exports=ProducttypeDao; module.exports = ProducttypeDao;
const system = require("../../../system"); const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
const pic_type = {"1":"列表头图", "2":"首页轮播图"};
/** /**
* 轮播图表 * 轮播图表
*/ */
...@@ -25,7 +26,11 @@ module.exports = (db, DataTypes) => { ...@@ -25,7 +26,11 @@ module.exports = (db, DataTypes) => {
type: DataTypes.STRING type: DataTypes.STRING
}, },
pic_type: { pic_type: {
type: DataTypes.STRING type: DataTypes.STRING,
set: function (val) {
this.setDataValue("pic_type", val);
this.setDataValue("pic_type_name",pic_type[val]);
}
}, },
sequence: { sequence: {
type: DataTypes.INTEGER type: DataTypes.INTEGER
......
...@@ -5,6 +5,10 @@ class ProducttypeService extends ServiceBase { ...@@ -5,6 +5,10 @@ class ProducttypeService extends ServiceBase {
constructor() { constructor() {
super("aggregation", ServiceBase.getDaoName(ProducttypeService)); super("aggregation", ServiceBase.getDaoName(ProducttypeService));
} }
async findAndCountAll (obj) {
let res = await this.dao.findAndCountAll(obj);
return system.getResultSuccess(res);
}
async create(pobj) { async create(pobj) {
let code = await this.getBusUid("mmc"); let code = await this.getBusUid("mmc");
pobj.code = code; pobj.code = code;
......
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const { json } = require("sequelize");
class RotationchartService extends ServiceBase { class RotationchartService extends ServiceBase {
constructor() { constructor() {
super("aggregation", ServiceBase.getDaoName(RotationchartService)); super("aggregation", ServiceBase.getDaoName(RotationchartService));
...@@ -39,6 +40,10 @@ class RotationchartService extends ServiceBase { ...@@ -39,6 +40,10 @@ class RotationchartService extends ServiceBase {
if (!pobj.name) { if (!pobj.name) {
pobj.name = res.name; pobj.name = res.name;
} }
if (!pobj.pic_type && !pobj.pic_type_name) {
pobj.pic_type = 2;
pobj.pic_type_name = "首页轮播图";
}
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