Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
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
hujun
tl_estate
Commits
c96e0a61
Commit
c96e0a61
authored
Jan 25, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商圈获取省市区封装
parent
d5913d9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
14 deletions
+26
-14
BusinessDistrict.php
application/index/controller/BusinessDistrict.php
+3
-13
Regions.php
application/model/Regions.php
+23
-1
No files found.
application/index/controller/BusinessDistrict.php
View file @
c96e0a61
...
...
@@ -116,20 +116,9 @@ class BusinessDistrict extends Basic
* @throws \think\exception\DbException
*/
public
function
regions
()
{
$code
=
$this
->
request
->
get
(
'code'
);
$parent_code
=
$this
->
request
->
get
(
'parent_code'
);
$params
=
$this
->
request
->
param
();
$regions
=
new
Regions
();
if
(
$code
)
{
$where
=
'code = '
.
$code
;
}
elseif
(
$parent_code
)
{
$where
=
'parentCode = '
.
$parent_code
;
}
else
{
$type
=
$this
->
request
->
get
(
'type'
)
?
$this
->
request
->
get
(
'type'
)
:
1
;
$where
=
'type = '
.
$type
;
}
$fields
=
'code,parentCode,name'
;
$data
=
$regions
->
field
(
$fields
)
->
where
(
$where
)
->
select
();
$data
=
$regions
->
getRegions
(
$params
[
'code'
],
$params
[
'parent_code'
],
$params
[
'type'
]);
return
$this
->
response
(
200
,
''
,
$data
);
}
}
\ No newline at end of file
application/model/Regions.php
View file @
c96e0a61
...
...
@@ -6,5 +6,27 @@ use think\Model;
class
Regions
extends
Model
{
//
/**
* 根据code或parent_code获取省市区
*
* @param $code
* @param string $parent_code
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getRegions
(
$code
,
$parent_code
=
''
,
$type
=
1
){
if
(
$code
)
{
$where
=
'code = '
.
$code
;
}
elseif
(
$parent_code
)
{
$where
=
'parentCode = '
.
$parent_code
;
}
else
{
$type
=
$type
?
$type
:
1
;
$where
=
'type = '
.
$type
;
}
$fields
=
'code,parentCode,name'
;
$data
=
$this
->
field
(
$fields
)
->
where
(
$where
)
->
select
();
return
$data
;
}
}
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