Commit 20f825dc authored by Hsinli's avatar Hsinli

addd

parent cf35a54d
Pipeline #8900 passed with stage
in 13 seconds
...@@ -35,6 +35,11 @@ class searchHistoryController extends Controller { ...@@ -35,6 +35,11 @@ class searchHistoryController extends Controller {
async cleanSearchHistory() { async cleanSearchHistory() {
const { ctx } = this; const { ctx } = this;
let inputParams = ctx.params; let inputParams = ctx.params;
const cfg = {
new_house: 1,
rental_house: 2,
hot_question: 3,
}
const rule = { const rule = {
type: { type: {
type: 'string', type: 'string',
...@@ -42,10 +47,10 @@ class searchHistoryController extends Controller { ...@@ -42,10 +47,10 @@ class searchHistoryController extends Controller {
} }
}; };
ctx.validate(rule, inputParams); ctx.validate(rule, inputParams);
if (!['new_house', 'rental_house'].includes(inputParams.type)) { if (!cfg.hasOwnProperty(inputParams.type)) {
ctx.failed('error type'); ctx.failed('error type');
} }
let type = inputParams.type === 'new_house' ? 1 : 2; let type = cfg[inputParams.type];
let ret = await ctx.service.house.v2.searchHistory.cleanSearchHistory(type); let ret = await ctx.service.house.v2.searchHistory.cleanSearchHistory(type);
ctx.success(ret); ctx.success(ret);
} }
......
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