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
73a67ab8
Commit
73a67ab8
authored
Apr 15, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
e13f3b99
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
5 deletions
+106
-5
search_history.js
app/controller/house/search_history.js
+22
-0
house.js
app/router/house.js
+1
-0
search_history.js
app/service/house/search_history.js
+53
-5
search_history.js
app/service/house_common/search_history.js
+30
-0
No files found.
app/controller/house/search_history.js
View file @
73a67ab8
...
...
@@ -21,6 +21,28 @@ class searchHistoryController extends Controller {
}
/**
* 清除搜索记录
*/
async
cleanSearchHistory
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
params
;
const
rule
=
{
type
:
{
type
:
'string'
,
required
:
true
,
}
};
ctx
.
validate
(
rule
,
inputParams
);
if
(
!
[
'new_house'
,
'rental_house'
].
includes
(
inputParams
.
type
))
{
ctx
.
failed
(
'error type'
);
}
let
type
=
inputParams
.
type
===
'new_house'
?
1
:
2
;
let
ret
=
await
ctx
.
service
.
house
.
searchHistory
.
cleanSearchHistory
(
type
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
searchHistoryController
;
app/router/house.js
View file @
73a67ab8
...
...
@@ -32,6 +32,7 @@ module.exports = app => {
//搜索历史
router
.
get
(
'/search_history'
,
'house.searchHistory.getsearchHistory'
);
//收藏列表
router
.
put
(
'/search_history/:type'
,
'house.searchHistory.cleanSearchHistory'
);
//用户点击清除搜索记录
//足迹
router
.
get
(
'/foot_print/list'
,
'house.footPrint.getFootPrintList'
);
//用户浏览记录列表
...
...
app/service/house/search_history.js
View file @
73a67ab8
...
...
@@ -55,11 +55,11 @@ class searchHistoryService extends Service {
value
:
ctx
.
userId
,
operator
:
"equal"
},
//
{
//
key: "createdAt",
//
value: endDate,
//
operator: "greater"
//
},
{
key
:
"createdAt"
,
value
:
endDate
,
operator
:
"greater"
},
],
orderConditions
:
[{
key
:
'createdAt'
,
...
...
@@ -92,6 +92,54 @@ class searchHistoryService extends Service {
return
ret
;
}
/**
* 用户点击清除搜索记录
*/
async
cleanSearchHistory
(
type
)
{
const
{
ctx
,
service
}
=
this
;
let
ret
=
{
status
:
true
};
if
(
!
ctx
.
appUserId
||
!
ctx
.
deviceId
||
!
ctx
.
deviceLoginId
||
!
ctx
.
userId
)
{
//如果没有登录就不做处理
return
ret
;
}
let
filter
=
{
pageIndex
:
1
,
pageSize
:
50
,
queryConditions
:
[{
key
:
"state"
,
value
:
1
,
operator
:
"equal"
},
{
key
:
"userId"
,
value
:
ctx
.
userId
,
operator
:
"equal"
},
{
key
:
"houseStyle"
,
value
:
type
,
operator
:
"equal"
}],
orderConditions
:
[],
}
let
searchHistoryList
=
await
service
.
houseCommon
.
searchHistory
.
all
(
filter
);
if
(
searchHistoryList
.
rowCount
>
0
)
{
let
taskList
=
[];
for
(
let
i
in
searchHistoryList
.
results
)
{
taskList
[
i
]
=
service
.
houseCommon
.
searchHistory
.
delete
(
searchHistoryList
.
results
[
i
].
id
);
}
await
Promise
.
all
(
taskList
).
then
(
result
=>
{
return
result
;
}).
catch
(
error
=>
{
ctx
.
failed
(
error
);
});
}
return
ret
;
}
}
module
.
exports
=
searchHistoryService
;
app/service/house_common/search_history.js
View file @
73a67ab8
...
...
@@ -19,6 +19,36 @@ class SearchHistoryService extends Service {
return
result
.
data
;
}
async
edit
(
id
,
data
)
{
const
{
ctx
}
=
this
;
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/searchhistory/'
+
id
,
data
,
{
method
:
'PUT'
});
if
(
result
.
status
!==
200
)
{
let
err
=
''
;
if
(
typeof
(
result
.
data
)
!==
'string'
)
{
err
=
JSON
.
stringify
(
result
.
data
);
}
else
{
err
=
result
.
data
;
}
ctx
.
failed
(
err
);
}
return
result
.
data
;
}
async
delete
(
id
)
{
const
{
ctx
}
=
this
;
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/searchhistory/'
+
id
,
{},
{
method
:
'DELETE'
});
if
(
result
.
status
!==
200
)
{
let
err
=
''
;
if
(
typeof
(
result
.
data
)
!==
'string'
)
{
err
=
JSON
.
stringify
(
result
.
data
);
}
else
{
err
=
result
.
data
;
}
ctx
.
failed
(
err
);
}
return
result
.
data
;
}
async
all
(
data
)
{
const
{
ctx
}
=
this
;
const
queryConditions
=
data
.
queryConditions
;
...
...
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