Commit a7cd5183 by 蒋勇

d

parent b54ed38c
...@@ -66,6 +66,13 @@ class DbFactory{ ...@@ -66,6 +66,13 @@ class DbFactory{
//渠道和渠道路径方法映射 //渠道和渠道路径方法映射
this.db.models.pathtomethod.belongsTo(this.db.models.channel,{constraints: false,}); this.db.models.pathtomethod.belongsTo(this.db.models.channel,{constraints: false,});
this.db.models.channel.hasMany(this.db.models.pathtomethod,{as:"pts",constraints: false,}); this.db.models.channel.hasMany(this.db.models.pathtomethod,{as:"pts",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.productprice.belongsTo(this.db.models.pricestrategy,{constraints: false,});
} }
//async getCon(){,用于使用替换table模型内字段数据使用 //async getCon(){,用于使用替换table模型内字段数据使用
getCon(){ getCon(){
......
...@@ -9,22 +9,22 @@ const md5 = require("MD5"); ...@@ -9,22 +9,22 @@ const md5 = require("MD5");
var dbf = system.getObject("db.common.connection"); var dbf = system.getObject("db.common.connection");
var db = dbf.getCon(); var db = dbf.getCon();
db.sync({ force: true }).then(async () => { db.sync({ force: true }).then(async () => {
const apps = await system.getObject("service.common.appSve"); // const apps = await system.getObject("service.common.appSve");
const usS = await system.getObject("service.auth.userSve"); // const usS = await system.getObject("service.auth.userSve");
let appnew = await apps.create({ // let appnew = await apps.create({
"name": "center-app", // "name": "center-app",
"domainName": "t9.com", // "domainName": "t9.com",
"backend": "192.168.1.148", // "backend": "192.168.1.148",
"isSystem": true, // "isSystem": true,
"title": "center-app" // "title": "center-app"
}); // });
let Role = db.models["role"]; // let Role = db.models["role"];
await Role.create({ code: "ta", name: "租户", isSystem: true, app_id: appnew.id, company_id: settings.pmcompanyid }) // await Role.create({ code: "ta", name: "租户", isSystem: true, app_id: appnew.id, company_id: settings.pmcompanyid })
await Role.create({ code: "pr", name: "个人", isSystem: true, app_id: appnew.id, company_id: settings.pmcompanyid }) // await Role.create({ code: "pr", name: "个人", isSystem: true, app_id: appnew.id, company_id: settings.pmcompanyid })
let usuper = await usS.pmregister({ userName: "sm", password: "951753", isSuper: true, isAdmin: true, isSystem: true, isEnabled: true, nickName: "superman", app_id: appnew.id, company_id: settings.id }) // let usuper = await usS.pmregister({ userName: "sm", password: "951753", isSuper: true, isAdmin: true, isSystem: true, isEnabled: true, nickName: "superman", app_id: appnew.id, company_id: settings.id })
appnew.creator_id = usuper.user.id // appnew.creator_id = usuper.user.id
await appnew.save() // await appnew.save()
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
//定价类型
return db.define("product", {
code:{
type: DataTypes.STRING,
allowNull: false,
},
regionpath:{
type: DataTypes.STRING,
allowNull: false,
},
productcatpath:{
type: DataTypes.STRING,
allowNull: false,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
desc: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_product',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
//定价类型
return db.define("productprice", {
lowpriceref:{
type: DataTypes.DECIMAL(10, 2) ,
allowNull: false,
},
hignpriceref:{
type: DataTypes.DECIMAL(10, 2) ,
allowNull: false,
},
deliverfile:{
type: DataTypes.STRING,
allowNull: false,
},
extrafile: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
desc: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from
isEnabled:{
type:DataTypes.BOOLEAN,
defaultValue: false
}
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_productprice',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
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