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
20816fa1
Commit
20816fa1
authored
Jul 21, 2020
by
xuxu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加推荐业务逻辑
parent
95cc0e54
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
5 deletions
+51
-5
quality-doctor/common/sql_utils.py
+7
-0
quality-doctor/dao/recommend_product_dao.py
+19
-0
quality-doctor/main.py
+2
-2
quality-doctor/service/recommend_info.py
+23
-3
No files found.
quality-doctor/common/sql_utils.py
0 → 100644
View file @
20816fa1
# -*- coding:UTF-8 -*-
# 数组转换成逗号分割字符串
def
to_sql_in
(
data_list
):
return
','
.
join
([
"'
%
s'"
%
item
for
item
in
data_list
])
\ No newline at end of file
quality-doctor/dao/recommend_product_dao.py
0 → 100644
View file @
20816fa1
from
db.mod_db
import
Database
from
common.sql_utils
import
to_sql_in
class
qualificationsProductDao
:
def
__init__
(
self
,
db
=
None
):
if
db
is
None
:
self
.
dataBase
=
Database
()
else
:
self
.
dataBase
=
db
def
get_recommend
(
self
,
product_list
):
print
(
"select * from ent_recommend_product join ent_product_comments on "
"ent_recommend_product.recommendation_business_code = ent_product_comments.product where qualification_comments in (
%
s)"
%
to_sql_in
(
product_list
))
return
self
.
dataBase
.
sqlResult
(
"select * from ent_recommend_product join ent_product_comments on "
"ent_recommend_product.recommendation_business = ent_product_comments.product where qualification_comments in (
%
s)"
%
to_sql_in
(
product_list
))
def
random_recommend
(
self
):
return
self
.
dataBase
.
sqlResult
(
"select * from ent_product_comments where status = 1 order by rand() limit 4"
)
\ No newline at end of file
quality-doctor/main.py
View file @
20816fa1
...
...
@@ -32,4 +32,4 @@ def RecommendationBusinessMain():
return
result
if
__name__
==
'__main__'
:
server
.
run
(
debug
=
True
,
host
=
'0.0.0.0'
,
port
=
8080
)
\ No newline at end of file
server
.
run
(
debug
=
True
,
host
=
'0.0.0.0'
,
port
=
8081
)
\ No newline at end of file
quality-doctor/service/recommend_info.py
View file @
20816fa1
from
dao.ent_qualification
import
qualificationsDao
from
dao.recommend_product_dao
import
qualificationsProductDao
qualificationsdao
=
qualificationsDao
()
qualificationsproductdao
=
qualificationsProductDao
()
def
recommend_function
(
select_data
):
isImports
=
select_data
[
'isImports'
]
if
isImports
:
...
...
@@ -38,16 +40,34 @@ def recommend_function(select_data):
have_use
.
append
(
nust_use_item
)
print
(
"have_use============"
,
have_use
)
product_result
=
[]
result_data
=
{
"isPass"
:
False
,
"recommend"
:
[]}
#检测不通过
if
len
(
have_use
)
!=
0
:
result_data
[
'isPass'
]
=
False
product_result_data
=
qualificationsproductdao
.
get_recommend
(
have_use
)
for
product_item
in
product_result_data
:
data
=
{
"id"
:
product_item
[
'product_id'
],
"name"
:
product_item
[
'product'
],
"describe"
:
product_item
[
'product_describe'
],
"price"
:
product_item
[
'product_price'
]
}
product_result
.
append
(
data
)
result_data
[
'recommend'
]
=
product_result
#检测通过
if
len
(
have_use
)
==
0
:
result_data
[
'isPass'
]
=
True
product_result_data
=
qualificationsproductdao
.
random_recommend
()
for
product_item
in
product_result_data
:
data
=
{
"id"
:
product_item
[
'product_id'
],
"name"
:
product_item
[
'product'
],
"describe"
:
product_item
[
'product_describe'
],
"price"
:
product_item
[
'product_price'
]
}
product_result
.
append
(
data
)
result_data
[
'recommend'
]
=
product_result
return
result_data
...
...
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