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
8355b4c7
Commit
8355b4c7
authored
Jul 01, 2020
by
王昆
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'engine-product' of gitlab.gongsibao.com:jiangyong/zhichan into engine-product
parents
20ddbb1d
425b3d82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
20 deletions
+32
-20
engine-product/app/base/api/impl/op/product.js
+3
-3
engine-product/app/base/db/impl/product/productDao.js
+2
-9
engine-product/app/base/service/impl/product/productSve.js
+25
-6
engine-product/app/front/entry/public/apidoc/product/product.md
+2
-2
No files found.
engine-product/app/base/api/impl/op/product.js
View file @
8355b4c7
...
@@ -18,13 +18,13 @@ class ProductAPI extends APIBase {
...
@@ -18,13 +18,13 @@ class ProductAPI extends APIBase {
pobj
.
action_body
.
types
,
pobj
.
action_body
.
keywords
)
pobj
.
action_body
.
types
,
pobj
.
action_body
.
keywords
)
return
system
.
getResultSuccess
(
result
)
return
system
.
getResultSuccess
(
result
)
case
'createOrUpdate'
:
case
'createOrUpdate'
:
if
(
pobj
.
action_body
.
product_type
==
0
&&
pobj
.
action_body
.
items
)
{
if
(
pobj
.
action_body
.
product_type
==
1
&&
pobj
.
action_body
.
items
)
{
return
system
.
getResult
(
null
,
'单产品不能有子产品'
)
return
system
.
getResult
(
null
,
'单产品不能有子产品'
)
}
}
if
(
pobj
.
action_body
.
product_type
==
1
&&
(
!
pobj
.
action_body
.
items
||
pobj
.
action_body
.
items
.
length
==
0
))
{
if
(
pobj
.
action_body
.
product_type
==
2
&&
(
!
pobj
.
action_body
.
items
||
pobj
.
action_body
.
items
.
length
==
0
))
{
return
system
.
getResult
(
null
,
'未选择子产品'
)
return
system
.
getResult
(
null
,
'未选择子产品'
)
}
}
if
(
pobj
.
action_body
.
product_type
==
1
)
{
if
(
pobj
.
action_body
.
product_type
==
2
)
{
let
checkRes
=
await
this
.
productSve
.
checkSitem
(
pobj
.
action_body
.
items
)
let
checkRes
=
await
this
.
productSve
.
checkSitem
(
pobj
.
action_body
.
items
)
if
(
!
checkRes
)
{
if
(
!
checkRes
)
{
return
system
.
getResult
(
null
,
'不能选择组合产品为子产品'
)
return
system
.
getResult
(
null
,
'不能选择组合产品为子产品'
)
...
...
engine-product/app/base/db/impl/product/productDao.js
View file @
8355b4c7
...
@@ -4,7 +4,7 @@ class productDao extends Dao {
...
@@ -4,7 +4,7 @@ class productDao extends Dao {
super
(
Dao
.
getModelName
(
productDao
));
super
(
Dao
.
getModelName
(
productDao
));
}
}
async
getPage
(
page
=
1
,
limit
=
10
,
type
=
[
0
,
1
],
keywords
)
{
async
getPage
(
page
=
1
,
limit
=
10
,
type
=
[
1
,
2
],
keywords
)
{
let
params
=
{
let
params
=
{
where
:
{
product_type
:
{
[
this
.
db
.
Op
.
in
]:
type
},
source_id
:
10001
},
where
:
{
product_type
:
{
[
this
.
db
.
Op
.
in
]:
type
},
source_id
:
10001
},
limit
:
limit
,
limit
:
limit
,
...
@@ -16,14 +16,7 @@ class productDao extends Dao {
...
@@ -16,14 +16,7 @@ class productDao extends Dao {
return
await
this
.
model
.
findAndCountAll
(
params
)
return
await
this
.
model
.
findAndCountAll
(
params
)
}
}
async
getAllDic
(
type
=
[
0
,
1
])
{
async
getByIds
(
ids
,
type
=
[
1
,
2
])
{
return
await
this
.
model
.
findAll
({
where
:
{
product_type
:
{
[
this
.
db
.
Op
.
in
]:
type
},
source_id
:
10001
},
attributes
:
[
'id'
,
'product_type'
,
'product_name'
]
})
}
async
getByIds
(
ids
,
type
=
[
0
,
1
])
{
return
await
this
.
model
.
findAll
({
return
await
this
.
model
.
findAll
({
where
:
{
id
:
{
[
this
.
db
.
Op
.
in
]:
ids
},
source_id
:
10001
,
product_type
:
{
[
this
.
db
.
Op
.
in
]:
type
}
}
where
:
{
id
:
{
[
this
.
db
.
Op
.
in
]:
ids
},
source_id
:
10001
,
product_type
:
{
[
this
.
db
.
Op
.
in
]:
type
}
}
})
})
...
...
engine-product/app/base/service/impl/product/productSve.js
View file @
8355b4c7
...
@@ -10,8 +10,27 @@ class ProductService extends ServiceBase {
...
@@ -10,8 +10,27 @@ class ProductService extends ServiceBase {
return
await
this
.
dao
.
getPage
(
page
,
limit
,
type
,
keywords
)
return
await
this
.
dao
.
getPage
(
page
,
limit
,
type
,
keywords
)
}
}
async
getAllDic
(
type
)
{
async
getAllDic
(
type
=
[
1
,
2
])
{
return
await
this
.
dao
.
getAllDic
(
type
)
let
query
=
{
where
:
{
product_type
:
{
[
this
.
db
.
Op
.
in
]:
type
},
source_id
:
10001
},
attributes
:
[
'id'
,
'product_type'
,
'product_name'
,
'price'
],
include
:
[{
model
:
this
.
itemDao
.
model
,
attributes
:
[[
'product_id'
,
'id'
]],
require
:
false
,
raw
:
true
}],
}
this
.
dao
.
model
.
hasMany
(
this
.
itemDao
.
model
,
{
foreignKey
:
'parent_id'
})
let
result
=
await
this
.
dao
.
model
.
findAll
(
query
)
for
(
let
i
in
result
)
{
let
res
=
[]
res
=
result
[
i
].
dataValues
.
productitems
.
map
((
data
)
=>
{
return
data
.
id
})
result
[
i
].
setDataValue
(
"ids"
,
res
)
}
return
result
}
}
async
getByIds
(
ids
)
{
async
getByIds
(
ids
)
{
...
@@ -33,8 +52,8 @@ class ProductService extends ServiceBase {
...
@@ -33,8 +52,8 @@ class ProductService extends ServiceBase {
return
result
return
result
}
}
async
checkSitem
(
ids
)
{
async
checkSitem
(
ids
)
{
let
res
=
await
this
.
dao
.
getByIds
(
ids
,
[
0
])
let
res
=
await
this
.
dao
.
getByIds
(
ids
,
[
1
])
let
arr
=
[]
let
arr
=
[]
for
(
let
i
of
res
)
{
for
(
let
i
of
res
)
{
arr
.
push
(
i
.
id
)
arr
.
push
(
i
.
id
)
...
@@ -56,7 +75,7 @@ class ProductService extends ServiceBase {
...
@@ -56,7 +75,7 @@ class ProductService extends ServiceBase {
async
create
(
params
)
{
async
create
(
params
)
{
let
items
let
items
if
(
params
.
product_type
==
1
)
{
if
(
params
.
product_type
==
2
)
{
items
=
JSON
.
parse
(
JSON
.
stringify
(
params
.
items
))
items
=
JSON
.
parse
(
JSON
.
stringify
(
params
.
items
))
delete
params
.
items
delete
params
.
items
}
}
...
@@ -74,7 +93,7 @@ class ProductService extends ServiceBase {
...
@@ -74,7 +93,7 @@ class ProductService extends ServiceBase {
async
update
(
params
)
{
async
update
(
params
)
{
let
items
let
items
if
(
params
.
product_type
==
1
)
{
if
(
params
.
product_type
==
2
)
{
items
=
JSON
.
parse
(
JSON
.
stringify
(
params
.
items
))
items
=
JSON
.
parse
(
JSON
.
stringify
(
params
.
items
))
delete
params
.
items
delete
params
.
items
}
}
...
...
engine-product/app/front/entry/public/apidoc/product/product.md
View file @
8355b4c7
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
| -------- | -------- | ------ | -------------------- |
| -------- | -------- | ------ | -------------------- |
| page | number | 可选 | 页数 默认 1 |
| page | number | 可选 | 页数 默认 1 |
| limit | number | 可选 | 每页条数 默认 10 |
| limit | number | 可选 | 每页条数 默认 10 |
| types | list | 可选 | 所选类别 默认
[
0, 1
]
|
| types | list | 可选 | 所选类别 默认
[
1, 2
]
|
| keywords | string | 可选 | 关键字 |
| keywords | string | 可选 | 关键字 |
#### 参数示例
#### 参数示例
...
@@ -81,7 +81,7 @@
...
@@ -81,7 +81,7 @@
| 参数名 | 参数类型 | 必选项 | 备注 |
| 参数名 | 参数类型 | 必选项 | 备注 |
| ------ | -------- | ------ | -------------------- |
| ------ | -------- | ------ | -------------------- |
| types | list | 可选 | 所选类别 默认
[
0, 1
]
|
| types | list | 可选 | 所选类别 默认
[
1, 2
]
|
#### 参数示例
#### 参数示例
...
...
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