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
3310631d
Commit
3310631d
authored
Jun 28, 2020
by
wkliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init; 基础查询接口;
parent
4a7bf385
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
217 additions
and
5 deletions
+217
-5
engine-product/app/base/api/impl/op/product.js
+78
-0
engine-product/app/base/db/impl/product/productDao.js
+29
-0
engine-product/app/base/db/impl/product/productitemDao.js
+28
-0
engine-product/app/base/db/models/product/product.js
+19
-0
engine-product/app/base/db/models/product/productitem.js
+15
-0
engine-product/app/base/db/models/product/source.js
+14
-0
engine-product/app/base/service/impl/product/productSve.js
+28
-0
engine-product/app/config/routes/doc.js
+5
-4
engine-product/app/config/settings.js
+1
-1
engine-product/package-lock.json
+0
-0
No files found.
engine-product/app/base/api/impl/op/product.js
0 → 100644
View file @
3310631d
var
APIBase
=
require
(
"../../api.base"
);
var
system
=
require
(
"../../../system"
);
const
os
=
require
(
"os"
)
class
ProductAPI
extends
APIBase
{
constructor
()
{
super
();
this
.
productSve
=
system
.
getObject
(
"service.product.productSve"
)
}
async
etag
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
actionType
)
{
return
system
.
getResult
(
null
,
"actionType参数不能为空"
)
}
let
result
switch
(
pobj
.
actionType
)
{
case
'getPage'
:
result
=
await
this
.
productSve
.
getPage
(
pobj
.
actionBody
.
page
,
pobj
.
actionBody
.
offset
,
pobj
.
actionBody
.
type
)
return
result
case
'createOrUpdate'
:
break
case
'getAll'
:
result
=
await
this
.
productSve
.
getAllDic
(
pobj
.
actionBody
.
type
)
return
result
case
'getByIds'
:
result
=
await
this
.
productSve
.
getByIds
(
pobj
.
actionBody
.
ids
)
break
case
'getItems'
:
break
default
:
break
}
}
exam
()
{
return
`<pre><pre/>`
;
}
classDesc
()
{
return
{
groupName
:
"product"
,
groupDesc
:
"产品引擎"
,
name
:
"ProductApi"
,
desc
:
"产品相关接口"
,
exam
:
""
,
};
}
methodDescs
()
{
return
[
{
methodDesc
:
`<pre><pre/>`
,
methodName
:
"product"
,
paramdescs
:
[
{
paramDesc
:
"请求的行为,传递如:sjb"
,
paramName
:
"action_process"
,
paramType
:
"string"
,
defaultValue
:
null
,
},
{
paramDesc
:
"业务操作类型,详情见方法中的描述"
,
paramName
:
"action_type"
,
paramType
:
"string"
,
defaultValue
:
null
,
},
{
paramDesc
:
"业务操作类型的参数,action_body必须传递的参数有,times_tamp(时间戳,类型int)、sign(签名,类型string),其余的为业务需要的参数"
,
paramName
:
"action_body"
,
paramType
:
"json"
,
defaultValue
:
null
,
}
],
rtnTypeDesc
:
`<pre><pre/>`
,
rtnType
:
`<pre><pre/>`
}
];
}
}
module
.
exports
=
ProductAPI
;
\ No newline at end of file
engine-product/app/base/db/impl/product/productDao.js
0 → 100644
View file @
3310631d
const
Dao
=
require
(
"../../dao.base"
);
class
productDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
productDao
));
}
async
getPage
(
page
=
1
,
offset
=
10
,
type
=
[
0
,
1
])
{
return
await
this
.
model
.
findAndCountAll
({
where
:
{
product_type
:
{
[
this
.
db
.
Op
.
in
]:
type
}
},
limit
:
offset
,
offset
:
(
page
-
1
)
*
offset
})
}
async
getAllDic
(
type
=
[
0
,
1
])
{
// TODO: 筛选字段
return
await
this
.
model
.
findAll
({
where
:
{
product_type
:
{
[
this
.
db
.
Op
.
in
]:
type
}
}
})
}
async
getByIds
(
ids
)
{
return
await
this
.
model
.
getAll
({
where
:
{
id
:
{
[
this
.
db
.
Op
.
in
]:
ids
}
}
})
}
}
module
.
exports
=
productDao
;
\ No newline at end of file
engine-product/app/base/db/impl/product/productitemDao.js
0 → 100644
View file @
3310631d
const
Dao
=
require
(
"../../dao.base"
);
class
productItemDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
productItemDao
));
}
async
getById
(
id
)
{
return
await
this
.
model
.
findOne
(
id
)
}
async
deleteById
(
id
)
{
return
await
this
.
model
.
destroy
({
where
:
{
id
:
id
}
})
}
async
deleteByParentId
(
id
)
{
return
await
this
.
model
.
destroy
({
where
:
{
parent_id
:
id
}
})
}
}
module
.
exports
=
productItemDao
;
\ No newline at end of file
engine-product/app/base/db/models/product/product.js
0 → 100644
View file @
3310631d
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"product"
,
{
source_id
:
DataTypes
.
BIGINT
,
// 产品来源 id
product_name
:
DataTypes
.
STRING
,
// 产品名称 50字
product_type
:
DataTypes
.
TINYINT
,
// 产品类型 1: 单产品, 2: 组合产品
product_desc
:
DataTypes
.
STRING
,
// 产品描述
price
:
DataTypes
.
BIGINT
,
// 价格
cost
:
DataTypes
.
BIGINT
,
// 成本
},
{
paranoid
:
true
,
underscored
:
true
,
timestamps
:
true
,
tableName
:
'e_product'
,
version
:
true
,
freezeTableName
:
true
}
)
}
\ No newline at end of file
engine-product/app/base/db/models/product/productitem.js
0 → 100644
View file @
3310631d
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"productItem"
,
{
parent_id
:
DataTypes
.
BIGINT
,
// 父产品 id
product_id
:
DataTypes
.
BIGINT
,
// 单产品 id
},
{
paranoid
:
false
,
underscored
:
true
,
timestamps
:
true
,
tableName
:
'e_product_item'
,
version
:
true
,
freezeTableName
:
true
}
)
}
\ No newline at end of file
engine-product/app/base/db/models/product/source.js
0 → 100644
View file @
3310631d
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"source"
,
{
source_name
:
DataTypes
.
STRING
,
// 产品来源名称
},
{
paranoid
:
true
,
underscored
:
true
,
timestamps
:
true
,
tableName
:
'e_soutce'
,
version
:
true
,
freezeTableName
:
true
}
)
}
\ No newline at end of file
engine-product/app/base/service/impl/product/productSve.js
0 → 100644
View file @
3310631d
const
ServiceBase
=
require
(
"../../sve.base"
);
class
ProductService
extends
ServiceBase
{
constructor
()
{
super
(
"product"
,
ServiceBase
.
getDaoName
(
ProductService
));
}
async
getPage
(
page
,
offset
,
type
)
{
return
await
this
.
dao
.
getPage
(
page
,
offset
,
type
)
}
async
getAllDic
(
type
)
{
return
await
this
.
dao
.
getAllDic
(
type
)
}
async
getByIds
(
ids
)
{
return
await
this
.
dao
.
getByIds
(
ids
)
}
async
getItems
(
id
)
{
// TODO: relation
}
async
createOrUpdate
(
params
)
{
// TODO:
}
}
module
.
exports
=
ProductService
;
\ No newline at end of file
engine-product/app/config/routes/doc.js
View file @
3310631d
...
...
@@ -2,11 +2,12 @@
var
system
=
require
(
"../../base/system"
);
var
fs
=
require
(
'fs'
);
var
marked
=
require
(
"marked"
);
const
os
=
require
(
"os"
)
module
.
exports
=
function
(
app
)
{
app
.
get
(
'/doc'
,
function
(
req
,
res
)
{
var
path
=
process
.
cwd
()
+
"/app/front/entry/public/apidoc/README.md"
;
var
path
=
os
.
type
==
'Windows_NT'
?
process
.
cwd
()
+
"/engine-product/app/front/entry/public/apidoc/README.md"
:
process
.
cwd
()
+
"/app/front/entry/public/apidoc/README.md"
;
console
.
log
(
process
.
cwd
(),
'----------------'
);
fs
.
readFile
(
path
,
function
(
err
,
data
){
if
(
err
){
...
...
@@ -21,8 +22,7 @@ module.exports = function (app) {
});
app
.
get
(
'/doc/:forder'
,
function
(
req
,
res
)
{
var
path
=
process
.
cwd
()
+
"/app/front/entry/public/apidoc/README.md"
;
var
path
=
os
.
type
==
'Windows_NT'
?
process
.
cwd
()
+
"/engine-product/app/front/entry/public/apidoc/README.md"
:
process
.
cwd
()
+
"/app/front/entry/public/apidoc/README.md"
;
fs
.
readFile
(
path
,
function
(
err
,
data
){
if
(
err
){
console
.
log
(
err
);
...
...
@@ -38,7 +38,8 @@ module.exports = function (app) {
app
.
get
(
'/doc/:forder/:fileName'
,
function
(
req
,
res
)
{
var
forder
=
req
.
params
[
"forder"
];
var
fileName
=
req
.
params
[
"fileName"
]
||
"README.md"
;
var
path
=
process
.
cwd
()
+
"/app/front/entry/public/apidoc"
;
var
path
=
os
.
type
==
'Windows_NT'
?
process
.
cwd
()
+
"/engine-product/app/front/entry/public/apidoc"
:
process
.
cwd
()
+
"/app/front/entry/public/apidoc"
;
if
(
forder
)
{
path
=
path
+
"/"
+
forder
+
"/"
+
fileName
;
}
else
{
...
...
engine-product/app/config/settings.js
View file @
3310631d
...
...
@@ -21,7 +21,7 @@ var settings = {
cacheprefix
:
"sjb"
,
usertimeout
:
3600
,
//单位秒
basepath
:
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
)),
port
:
process
.
env
.
NODE_PORT
||
330
0
,
port
:
process
.
env
.
NODE_PORT
||
330
1
,
defaultPassWord
:
"987456"
,
paasUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
...
...
engine-product/package-lock.json
View file @
3310631d
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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