Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
a7cd5183
Commit
a7cd5183
authored
Jun 07, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
b54ed38c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
166 additions
and
15 deletions
+166
-15
center-manage/app/base/db/impl/common/connection.js
+7
-0
center-manage/app/base/db/impl/product/pricecatDao.js
+0
-0
center-manage/app/base/db/initData.js
+15
-15
center-manage/app/base/db/models/product/product.js
+70
-0
center-manage/app/base/db/models/product/productprice.js
+74
-0
No files found.
center-manage/app/base/db/impl/common/connection.js
View file @
a7cd5183
...
@@ -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
(){
...
...
center-manage/app/base/db/impl/
common
/pricecatDao.js
→
center-manage/app/base/db/impl/
product
/pricecatDao.js
View file @
a7cd5183
File moved
center-manage/app/base/db/initData.js
View file @
a7cd5183
...
@@ -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()
...
...
center-manage/app/base/db/models/product/product.js
0 → 100644
View file @
a7cd5183
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}]
// }
]
});
}
center-manage/app/base/db/models/product/productprice.js
0 → 100644
View file @
a7cd5183
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}]
// }
]
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment