Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tj_tool
Overview
Overview
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
牟俊洁
tj_tool
Commits
60294d82
Commit
60294d82
authored
Nov 04, 2025
by
白满斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
周边
parent
0534b2b3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
10 deletions
+139
-10
SchoolController.php
app/Http/Controllers/SchoolController.php
+11
-1
SchoolService.php
app/Http/Services/SchoolService.php
+97
-3
PlaceAroundModel.php
app/Models/PlaceAroundModel.php
+24
-0
api.php
routes/api.php
+7
-6
No files found.
app/Http/Controllers/SchoolController.php
View file @
60294d82
...
...
@@ -26,6 +26,9 @@ class SchoolController extends BaseController{
public
function
getConfig
(
Request
$request
){
$examid
=
(
int
)
$request
->
input
(
'exam_id'
,
0
);
if
(
empty
(
$examid
))
{
return
$this
->
respondError
(
10001
,
'exam_id参数错误'
);
}
$result
=
$this
->
schoolService
->
selectConfigService
(
$examid
);
return
$this
->
respond
(
$result
);
}
...
...
@@ -33,7 +36,14 @@ class SchoolController extends BaseController{
//获取考点列表
public
function
getPlaceInfo
(
Request
$request
){
$placeid
=
(
int
)
$request
->
input
(
'place_id'
,
0
);
$result
=
$this
->
schoolService
->
getPlaceInfoService
(
$placeid
);
$aroundName
=
$request
->
input
(
'around_name'
,
''
);
if
(
empty
(
$placeid
))
{
return
$this
->
respondError
(
10001
,
'place_id参数错误'
);
}
if
(
empty
(
$aroundName
))
{
return
$this
->
respondError
(
10001
,
'around_name参数错误'
);
}
$result
=
$this
->
schoolService
->
getPlaceInfoService
(
$placeid
,
$aroundName
);
return
$this
->
respond
(
$result
);
}
...
...
app/Http/Services/SchoolService.php
View file @
60294d82
...
...
@@ -24,10 +24,65 @@ use App\Models\SchoolMajorScore;
use
App\Models\SchoolPlanBefore
;
use
App\Models\PlaceModel
;
use
App\Models\ExamModel
;
use
App\Models\PlaceAroundModel
;
use
Illuminate\Support\Facades\Http
;
class
SchoolService
extends
BaseService
{
public
static
$local
=
'https://restapi.amap.com/v3/geocode/geo?'
;
public
static
$localAround
=
'https://restapi.amap.com/v5/place/around?'
;
public
static
$around
=
[
'美食'
=>
'050000'
,
'住宿'
=>
'100000'
,
'文具'
=>
'060000'
,
'打印'
=>
'070000'
,
'充电'
=>
'010000'
,
'公厕'
=>
'200300'
,
'交通'
=>
'150104|150200'
,
];
public
static
function
sendGet
(
$url
){
try
{
//专业对应检索条件
$response
=
Http
::
get
(
$url
);
$bodyData
=
$response
->
json
();
// 如果响应是 JSON 格式,解析为数组或对象
if
(
$bodyData
[
'status'
]
==
0
){
return
[
'code'
=>
20001
,
'msg'
=>
'地图数据请求失败'
,
'data'
=>
$bodyData
];
}
if
(
$bodyData
[
'info'
]
!=
'OK'
){
return
[
'code'
=>
20001
,
'msg'
=>
'地图信息获取失败'
,
'data'
=>
$bodyData
];
}
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$bodyData
[
'geocodes'
]];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
20009
,
'msg'
=>
$e
->
getMessage
(),
'data'
=>
[]];
}
}
public
static
function
sendGetAround
(
$url
){
try
{
//专业对应检索条件
$response
=
Http
::
get
(
$url
);
$bodyData
=
$response
->
json
();
// 如果响应是 JSON 格式,解析为数组或对象
if
(
$bodyData
[
'status'
]
==
0
){
return
[
'code'
=>
20001
,
'msg'
=>
'地图数据请求失败'
,
'data'
=>
$bodyData
];
}
if
(
$bodyData
[
'info'
]
!=
'OK'
){
return
[
'code'
=>
20001
,
'msg'
=>
'地图信息获取失败'
,
'data'
=>
$bodyData
];
}
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$bodyData
[
'pois'
]];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
20009
,
'msg'
=>
$e
->
getMessage
(),
'data'
=>
[]];
}
}
public
function
selectExamService
(){
$ExamModel
=
new
ExamModel
();
...
...
@@ -50,11 +105,12 @@ class SchoolService extends BaseService{
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
array_values
(
$data
)];
}
public
function
getPlaceInfoService
(
$placeid
){
public
function
getPlaceInfoService
(
$placeid
,
$aroundName
){
$PlaceAroundModel
=
new
PlaceAroundModel
();
$PlaceModel
=
new
PlaceModel
();
$res
=
$PlaceModel
->
findData
([
'id'
=>
$placeid
]);
$gdKey
=
env
(
'GD_KEY'
);
$data
=
[
'id'
=>
$res
[
'id'
],
'name'
=>
$res
[
'name'
],
...
...
@@ -62,12 +118,50 @@ class SchoolService extends BaseService{
'area'
=>
$res
[
'area'
],
'img'
=>
'/uploads/tianjin/'
.
$res
[
'img'
],
];
$location
=
$res
[
'location'
];
//获取周边信息,美食、住宿、文具、打印、充电、公厕、交通
if
(
$res
[
'location'
]
==
""
){
$url
=
self
::
$local
.
'key='
.
$gdKey
.
'&address='
.
$res
[
'addr'
]
.
'&city='
.
$res
[
'p_code'
];
$requestRet
=
self
::
sendGet
(
$url
);
if
(
$requestRet
[
'code'
]
!=
0
){
return
$requestRet
;
}
if
(
empty
(
$requestRet
[
'data'
])){
return
[
'code'
=>
10001
,
'msg'
=>
'暂未获取到地址信息'
,
'data'
=>
[]];
}
$location
=
$requestRet
[
'data'
][
0
][
'location'
];
if
(
empty
(
$location
)){
return
[
'code'
=>
10002
,
'msg'
=>
'位置获取失败'
,
'data'
=>
[]];
}
$PlaceModel
->
updateData
([
'id'
=>
$placeid
],
[
'location'
=>
$location
]);
}
$data
[
'location'
]
=
$location
;
$data
[
'around_name'
]
=
$aroundName
;
if
(
!
isset
(
self
::
$around
[
$aroundName
])){
return
[
'code'
=>
10002
,
'msg'
=>
'请传入正确的周边名称'
,
'data'
=>
[]];
}
//获取周边:
$aroundData
=
$PlaceAroundModel
->
findData
([
'place_id'
=>
$placeid
,
'name'
=>
$aroundName
]);
if
(
!
empty
(
$aroundData
)){
$data
[
'around'
]
=
json_decode
(
$aroundData
[
'data'
],
true
);
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$data
];
}
//么有就去获取
$aroundUrl
=
self
::
$localAround
.
'key='
.
$gdKey
.
'&keywords='
.
$aroundName
.
'&types='
.
self
::
$around
[
$aroundName
]
.
'&location='
.
$location
.
'&radius=20000®ion='
.
$res
[
'p_code'
]
.
'&city_limit=true'
;
$requestRetAround
=
self
::
sendGetAround
(
$aroundUrl
);
$aroundData
=
[
'place_id'
=>
$placeid
,
'name'
=>
$aroundName
,
'data'
=>
json_encode
(
$requestRetAround
[
'data'
])
];
$PlaceAroundModel
->
insertData
(
$aroundData
);
$data
[
'around'
]
=
$requestRetAround
[
'data'
];
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
[]
];
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$data
];
}
public
function
listService
(
$search
,
$pageId
,
$pageSize
)
...
...
app/Models/PlaceAroundModel.php
0 → 100755
View file @
60294d82
<?php
/**
* Created by PhpStorm.
* User: bmb369
* Date: 2024-05-07
* Time: 14:20
*/
namespace
App\Models
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Support\Facades\DB
;
class
PlaceAroundModel
extends
Base
{
protected
$table
=
'gz_place_around'
;
use
SoftDeletes
;
protected
$dates
=
[
'deleted_at'
];
protected
$primaryKey
=
'id'
;
}
\ No newline at end of file
routes/api.php
View file @
60294d82
...
...
@@ -38,12 +38,13 @@ Route::group(['prefix'=> 'student'], function () {
Route
::
group
([
'prefix'
=>
'school'
],
function
()
{
Route
::
get
(
'exam_list'
,
[
'uses'
=>
'SchoolController@selectExam'
,
'label'
=>
'列表'
,]);
Route
::
get
(
'place_list'
,
[
'uses'
=>
'SchoolController@getConfig'
,
'label'
=>
'列表'
,]);
Route
::
get
(
'list'
,
[
'uses'
=>
'SchoolController@lst'
,
'label'
=>
'列表'
,]);
Route
::
get
(
'special_list'
,
[
'uses'
=>
'SchoolController@specialList'
,
'label'
=>
'列表'
,]);
Route
::
get
(
'special_detail'
,
[
'uses'
=>
'SchoolController@specialDetail'
,
'label'
=>
'列表'
,]);
Route
::
get
(
'score_province'
,
[
'uses'
=>
'SchoolController@specialProvince'
,
'label'
=>
'院校分数线'
,]);
Route
::
get
(
'score_major_province'
,
[
'uses'
=>
'SchoolController@specialMajorProvince'
,
'label'
=>
'专业分数线'
,]);
Route
::
get
(
'plan_before'
,
[
'uses'
=>
'SchoolController@planBefore'
,
'label'
=>
'招生信息'
,]);
Route
::
get
(
'place_info'
,
[
'uses'
=>
'SchoolController@getPlaceInfo'
,
'label'
=>
'列表'
,]);
// Route::get('list', ['uses' => 'SchoolController@lst', 'label' => '列表',]);
// Route::get('special_list', ['uses' => 'SchoolController@specialList', 'label' => '列表',]);
// Route::get('special_detail', ['uses' => 'SchoolController@specialDetail', 'label' => '列表',]);
// Route::get('score_province', ['uses' => 'SchoolController@specialProvince', 'label' => '院校分数线',]);
// Route::get('score_major_province', ['uses' => 'SchoolController@specialMajorProvince', 'label' => '专业分数线',]);
// Route::get('plan_before', ['uses' => 'SchoolController@planBefore', 'label' => '招生信息',]);
});
...
...
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