Commit 5706edb2 by 蒋勇

d

parent e9b42913
...@@ -27,6 +27,10 @@ class UserCtl extends CtlBase { ...@@ -27,6 +27,10 @@ class UserCtl extends CtlBase {
await this.service.updateByWhere({isEnabled:!pobj.isEnabled},{company_id:pobj.company_id}) await this.service.updateByWhere({isEnabled:!pobj.isEnabled},{company_id:pobj.company_id})
return system.getResult({}); return system.getResult({});
} }
async allowOrNotToOne(pobj, qobj, req){
await this.service.updateByWhere({isEnabled:!pobj.isEnabled},{id:pobj.curid})
return system.getResult({});
}
async initNewInstance(queryobj, req) { async initNewInstance(queryobj, req) {
var rtn = {}; var rtn = {};
rtn.roles = []; rtn.roles = [];
......
...@@ -17,7 +17,7 @@ class UserCache extends CacheBase{ ...@@ -17,7 +17,7 @@ class UserCache extends CacheBase{
} }
async buildCacheVal(cachekey,inputkey, val, ex, ...items) { async buildCacheVal(cachekey,inputkey, val, ex, ...items) {
const configValue = await this.userDao.model.findAll({ const configValue = await this.userDao.model.findAll({
where: { userName: inputkey, app_id: settings.pmappid }, where: { userName: inputkey, app_id: settings.pmappid,isEnabled:true},
attributes: ['id','userName', 'nickName','headUrl','jwtkey','jwtsecret','created_at','isSuper','isAdmin','mail','opath','ptags'], attributes: ['id','userName', 'nickName','headUrl','jwtkey','jwtsecret','created_at','isSuper','isAdmin','mail','opath','ptags'],
include: [ include: [
{ model: this.db.models.company,attributes:['id','name','companykey','appids'],raw:true}, { model: this.db.models.company,attributes:['id','name','companykey','appids'],raw:true},
......
...@@ -70,9 +70,11 @@ class DbFactory{ ...@@ -70,9 +70,11 @@ class DbFactory{
//产品相关 //产品相关
this.db.models.productprice.belongsTo(this.db.models.product,{constraints: false,}); this.db.models.productprice.belongsTo(this.db.models.product,{constraints: false,});
this.db.models.product.hasMany(this.db.models.productprice,{as:"skus",constraints: false,}); this.db.models.product.hasMany(this.db.models.productprice,{as:"skus",constraints: false,});
this.db.models.product.belongsTo(this.db.models.company,{constraints: false,});
//产品价格引用定价策略 //产品价格引用定价策略
this.db.models.productprice.belongsTo(this.db.models.pricestrategy,{constraints: false,}); this.db.models.productprice.belongsTo(this.db.models.pricestrategy,{constraints: false,});
this.db.models.productprice.belongsTo(this.db.models.company,{constraints: false,});
//成本项目属于productprice //成本项目属于productprice
this.db.models.productcost.belongsTo(this.db.models.productprice,{constraints: false,}); this.db.models.productcost.belongsTo(this.db.models.productprice,{constraints: false,});
......
...@@ -4,6 +4,20 @@ class ProductDao extends Dao { ...@@ -4,6 +4,20 @@ class ProductDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(ProductDao)); super(Dao.getModelName(ProductDao));
} }
extraWhere(obj,w,qc,linkAttrs){
if(obj.bizpath && obj.bizpath!=""){
if(obj.bizpath.indexOf("productdef")>0){//说明是租户查询自己创建的应用
w["company_id"]= obj.company_id;
}
}
if(linkAttrs.length>0){
var search=obj.search;
var lnkKey=linkAttrs[0];
var strq="$"+lnkKey.replace("~",".")+"$";
w[strq]= {[this.db.Op.like]:"%"+search[lnkKey]+"%"};
}
return w;
}
extraModelFilter() { extraModelFilter() {
//return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]}; //return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]};
return { return {
......
...@@ -4,6 +4,20 @@ class ProductpriceDao extends Dao{ ...@@ -4,6 +4,20 @@ class ProductpriceDao extends Dao{
constructor(){ constructor(){
super(Dao.getModelName(ProductpriceDao)); super(Dao.getModelName(ProductpriceDao));
} }
extraWhere(obj,w,qc,linkAttrs){
if(obj.bizpath && obj.bizpath!=""){
if(obj.bizpath.indexOf("platformprice")>0){//说明是租户查询自己创建的应用
w["company_id"]= obj.company_id;
}
}
if(linkAttrs.length>0){
var search=obj.search;
var lnkKey=linkAttrs[0];
var strq="$"+lnkKey.replace("~",".")+"$";
w[strq]= {[this.db.Op.like]:"%"+search[lnkKey]+"%"};
}
return w;
}
extraModelFilter(){ extraModelFilter(){
//return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]}; //return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]};
return {"key":"include","value":[ return {"key":"include","value":[
......
...@@ -21,7 +21,7 @@ module.exports = (db, DataTypes) => { ...@@ -21,7 +21,7 @@ module.exports = (db, DataTypes) => {
allowNull: false, allowNull: false,
}//和user的from相同,在注册user时,去创建 }//和user的from相同,在注册user时,去创建
}, { }, {
paranoid: false,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
......
...@@ -17,7 +17,7 @@ module.exports = (db, DataTypes) => { ...@@ -17,7 +17,7 @@ module.exports = (db, DataTypes) => {
allowNull: false, allowNull: false,
}//和user的from相同,在注册user时,去创建 }//和user的from相同,在注册user时,去创建
}, { }, {
paranoid: false,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
......
...@@ -25,7 +25,7 @@ module.exports = (db, DataTypes) => { ...@@ -25,7 +25,7 @@ module.exports = (db, DataTypes) => {
allowNull: false, allowNull: false,
},//和user的from },//和user的from
}, { }, {
paranoid: false,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
......
...@@ -21,7 +21,7 @@ module.exports = (db, DataTypes) => { ...@@ -21,7 +21,7 @@ module.exports = (db, DataTypes) => {
allowNull: true allowNull: true
}, },
}, { }, {
paranoid: false,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
......
...@@ -42,7 +42,7 @@ module.exports = (db, DataTypes) => { ...@@ -42,7 +42,7 @@ module.exports = (db, DataTypes) => {
defaultValue: false defaultValue: false
} }
}, { }, {
paranoid: false,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
......
...@@ -31,7 +31,8 @@ class ProductService extends ServiceBase { ...@@ -31,7 +31,8 @@ class ProductService extends ServiceBase {
product_id: pnew.id, product_id: pnew.id,
pricestrategy_id: stragetyid, pricestrategy_id: stragetyid,
pname:p.name, pname:p.name,
strategyitems:tmpdic[stragetyid+''] strategyitems:tmpdic[stragetyid+''],
company_id:p.company_id
} }
productprices.push(pps) productprices.push(pps)
}) })
...@@ -83,7 +84,8 @@ class ProductService extends ServiceBase { ...@@ -83,7 +84,8 @@ class ProductService extends ServiceBase {
product_id: p.id, product_id: p.id,
pricestrategy_id: stragetyid, pricestrategy_id: stragetyid,
pname:p.name, pname:p.name,
strategyitems:tmpdic[stragetyid+''] strategyitems:tmpdic[stragetyid+''],
company_id:p.company_id
} }
productprices.push(pps) productprices.push(pps)
}) })
......
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