Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
5ca72763
Commit
5ca72763
authored
Jun 13, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addd
parent
20f825dc
Pipeline
#8909
passed with stage
in 4 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
17 deletions
+42
-17
hot_search.js
app/service/house/v2/hot_search.js
+38
-0
search_history.js
app/service/house/v2/search_history.js
+3
-16
config.local.js
config/config.local.js
+1
-1
No files found.
app/service/house/v2/hot_search.js
0 → 100644
View file @
5ca72763
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
moment
=
require
(
'moment'
);
class
HotSearchService
extends
Service
{
/**
* 热门搜索的关键词允许设置10个,新房和租房的需要区分开
* @param {*} condition
*/
async
getHotSearch
(
condition
)
{
const
{
ctx
}
=
this
;
let
type
=
condition
.
type
;
let
cityCode
=
condition
.
city_code
;
let
filter
=
{
limit
:
10
,
attributes
:
[
'text'
],
where
:
{
city
:
cityCode
,
type
:
type
,
valid
:
1
},
order
:
[[
'created_at'
,
'desc'
]]
}
let
hotSearch
=
await
ctx
.
realestateModel
.
HotSearch
.
all
(
filter
);
let
hotList
=
hotSearch
.
map
(
v
=>
{
return
v
.
text
});
ret
=
{
results
:
hotList
,
count
:
hotList
.
length
}
return
ret
;
}
}
module
.
exports
=
HotSearchService
;
app/service/house/v2/search_history.js
View file @
5ca72763
...
...
@@ -34,8 +34,6 @@ class searchHistoryService extends Service {
*/
async
getSearchHistoryList
(
condition
)
{
const
{
ctx
}
=
this
;
let
type
=
condition
.
type
;
let
cityCode
=
condition
.
city_code
;
let
ret
=
{
hot_search
:
{
results
:
[],
...
...
@@ -47,28 +45,17 @@ class searchHistoryService extends Service {
}
};
//不管有没有登录获取城市相关的热门搜索
let
hotFilter
=
{
limit
:
10
,
attributes
:
[
'text'
],
where
:
{
city
:
cityCode
,
type
:
type
,
valid
:
1
},
order
:
[[
'created_at'
,
'desc'
]]
}
let
hotSearch
=
await
ctx
.
realestateModel
.
HotSearch
.
all
(
hotFilter
);
let
hotList
=
hotSearch
.
map
(
v
=>
{
return
v
.
text
});
let
hotList
=
await
ctx
.
service
.
house
.
v2
.
hotSearch
.
getHotSearch
(
condition
);
ret
.
hot_search
=
{
results
:
hotList
,
count
:
hotList
.
length
}
if
(
!
ctx
.
appUserId
||
!
ctx
.
deviceId
||
!
ctx
.
deviceLoginId
||
!
ctx
.
userId
)
{
if
(
!
ctx
.
appUserId
||
!
ctx
.
userId
)
{
//如果没有登录就返回
return
ret
;
}
//用户的搜索记录
let
list
=
await
this
.
getSearchHistory
(
type
);
let
list
=
await
this
.
getSearchHistory
(
condition
.
type
);
ret
.
search_history
=
{
results
:
list
,
count
:
list
.
length
...
...
config/config.local.js
View file @
5ca72763
...
...
@@ -17,7 +17,7 @@ module.exports = appInfo => {
domainWhiteList
:
[],
};
// config.middleware = [ 'errorHandler', 'deviceLogin', 'deviceInit', 'responseSet'
];
config
.
middleware
=
[
'errorHandler'
,
'deviceLogin'
,
'deviceInit'
,
'responseSet'
];
exports
.
multipart
=
{
// 不用steam用file
...
...
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