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 {
*/
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
......
......@@ -17,7 +17,7 @@ module.exports = appInfo => {
domainWhiteList: [],
};
// config.middleware = [ 'errorHandler', 'deviceLogin', 'deviceInit', 'responseSet' ];
config.middleware = ['errorHandler', 'deviceLogin', 'deviceInit', 'responseSet'];
exports.multipart = {
// 不用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