Commit 5ca72763 authored by Hsinli's avatar Hsinli

addd

parent 20f825dc
Pipeline #8909 passed with stage
in 4 seconds
'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;
...@@ -34,8 +34,6 @@ class searchHistoryService extends Service { ...@@ -34,8 +34,6 @@ class searchHistoryService extends Service {
*/ */
async getSearchHistoryList(condition) { async getSearchHistoryList(condition) {
const { ctx } = this; const { ctx } = this;
let type = condition.type;
let cityCode = condition.city_code;
let ret = { let ret = {
hot_search: { hot_search: {
results: [], results: [],
...@@ -47,28 +45,17 @@ class searchHistoryService extends Service { ...@@ -47,28 +45,17 @@ class searchHistoryService extends Service {
} }
}; };
//不管有没有登录获取城市相关的热门搜索 //不管有没有登录获取城市相关的热门搜索
let hotFilter = { let hotList = await ctx.service.house.v2.hotSearch.getHotSearch(condition);
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 });
ret.hot_search = { ret.hot_search = {
results: hotList, results: hotList,
count: hotList.length count: hotList.length
} }
if (!ctx.appUserId || !ctx.deviceId || !ctx.deviceLoginId || !ctx.userId) { if (!ctx.appUserId || !ctx.userId) {
//如果没有登录就返回 //如果没有登录就返回
return ret; return ret;
} }
//用户的搜索记录 //用户的搜索记录
let list = await this.getSearchHistory(type); let list = await this.getSearchHistory(condition.type);
ret.search_history = { ret.search_history = {
results: list, results: list,
count: list.length count: list.length
......
...@@ -17,7 +17,7 @@ module.exports = appInfo => { ...@@ -17,7 +17,7 @@ module.exports = appInfo => {
domainWhiteList: [], domainWhiteList: [],
}; };
// config.middleware = [ 'errorHandler', 'deviceLogin', 'deviceInit', 'responseSet' ]; config.middleware = ['errorHandler', 'deviceLogin', 'deviceInit', 'responseSet'];
exports.multipart = { exports.multipart = {
// 不用steam用file // 不用steam用file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment