Commit faa7f91b by 兰国旗

laolan

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