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
64ce6b73
Commit
64ce6b73
authored
Aug 13, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addd
parent
dcfa1339
Pipeline
#12192
passed with stage
in 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
+34
-5
tool.js
app/controller/house/v2/tool.js
+34
-5
No files found.
app/controller/house/v2/tool.js
View file @
64ce6b73
...
...
@@ -398,12 +398,41 @@ class ToolController extends Controller {
let
ret
=
[];
if
(
cityCode
!==
undefined
&&
cityCode
.
length
>
0
)
{
let
cityCodes
=
_
.
uniq
(
_
.
map
(
cityCode
,
'id'
));
let
cityFilter
=
{
attributes
:
[
'name'
,
'code'
],
where
:
{
code
:
{
$in
:
cityCodes
}
}
// let cityFilter = {
// attributes: ['name', 'code'],
// where: { code: { $in: cityCodes } }
// }
// let cityName = await ctx.blockModel.City.findAll(cityFilter);
// ret = cityName !== undefined ? cityName : [];
const
city_list_ret
=
await
ctx
.
blockModel
.
City
.
all
({
where
:
{
code
:
{
$in
:
cityCodes
}
}
});
const
city_list
=
[];
for
(
let
i
in
city_list_ret
)
{
let
city
=
city_list_ret
[
i
];
if
(
city
.
name
.
indexOf
(
'市辖区'
)
!==
-
1
)
{
city
=
await
ctx
.
blockModel
.
City
.
one
({
where
:
{
id
:
city
.
parent
}
});
if
(
!
city
||
!
city
.
id
)
{
continue
;
}
}
city_list
.
push
({
id
:
city
.
id
,
name
:
city
.
name
,
code
:
city
.
code
,
letter
:
city
.
fword
.
toUpperCase
(),
});
}
const
cities_ids
=
R
.
pluck
(
'code'
,
city_list
);
const
districts
=
await
ctx
.
blockModel
.
HouseDistrict
.
all
({
where
:
{
city_id
:
{
$in
:
cities_ids
}
}
});
const
ret
=
[];
for
(
let
i
in
city_list
)
{
const
city
=
city_list
[
i
];
const
children
=
districts
.
filter
(
item
=>
{
return
(
parseInt
(
item
.
city_id
)
===
parseInt
(
city
.
code
))
?
true
:
false
});
city
.
_children
=
children
.
map
(
item
=>
{
return
{
id
:
item
.
id
,
name
:
item
.
name
,
code
:
item
.
id
}
});
// city._children.unshift({ id: -1, name: '全部', code: 0 });
ret
.
push
(
city
);
}
let
cityName
=
await
ctx
.
blockModel
.
City
.
findAll
(
cityFilter
);
ret
=
cityName
!==
undefined
?
cityName
:
[];
}
ctx
.
success
(
ret
);
}
...
...
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