Skip to content

Commit

Permalink
feat: 更改取得Object的方式
Browse files Browse the repository at this point in the history
style: var to let
  • Loading branch information
Chinlinlee committed Sep 1, 2021
1 parent bc09fb2 commit c7bd7c9
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions routes/api/Course_Search/controller/get_Place.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const _ = require('lodash');
const data_log = require("../../../../models/common/data.js");

module.exports = async function(req ,res)
{
var queryParams = req.query;
let queryParams = req.query;
Object.keys(queryParams).forEach(element =>
{
if (!queryParams[element])
Expand All @@ -14,34 +15,34 @@ module.exports = async function(req ,res)
queryParams[element] = [queryParams[element]];
}
});
if (queryParams['IsRootPart'] == undefined && queryParams['IsCityPart'] == undefined)
if (!_.get(queryParams , "IsRootPart") && !_.get(queryParams , "IsCityPart"))
{
queryParams['IsRootPart'] = new Array("true");
queryParams['IsCityPart'] = new Array("true");
}
if ((queryParams['IsRootPart'][0] == "true" && queryParams['IsCityPart'][0] == "true" ) || (queryParams['IsRootPart'][0] == "false" && queryParams['IsCityPart'][0] == "false"))
if (_.get(queryParams , "IsRootPart.0") == _.get(queryParams , "IsCityPart.0"))
{
delete queryParams['IsRootPart'];
delete queryParams['IsCityPart'];
}
else if (queryParams['IsRootPart'][0] == "true")
else if (_.get(queryParams , "IsRootPart.0") == "true")
{
delete queryParams['IsRootPart'];
delete queryParams['IsCityPart'];
var City = new RegExp("城區");
let City = new RegExp("城區");
queryParams['Course_Other'] = {"$not":City};
}
else if (queryParams['IsCityPart'][0] == "true")
else if (_.get(queryParams , "IsCityPart.0") == "true")
{
delete queryParams['IsRootPart'];
delete queryParams['IsCityPart'];
var City = new RegExp("城區");
let City = new RegExp("城區");
queryParams['Course_Other'] = {"$in":[City]};
}
Promise.all(await data_log.Getdata("All_Courses" , queryParams)).then(
value=>
{
var Result = [];
let Result = [];
value.forEach(item=>
{
if (item.Course_Place !="")
Expand All @@ -60,7 +61,7 @@ module.exports = async function(req ,res)
}
}
});
var output = Array.from(new Set(Result));
let output = Array.from(new Set(Result));
res.send(output);
});
}

0 comments on commit c7bd7c9

Please sign in to comment.