|
@@ -6,7 +6,9 @@ namespace App\Http\Controllers\Api;
|
|
|
|
|
|
use App\Services\GeohashService;
|
|
use App\Services\GeohashService;
|
|
use App\Services\HomeService;
|
|
use App\Services\HomeService;
|
|
|
|
+use App\Services\RedisService;
|
|
use http\Env\Response;
|
|
use http\Env\Response;
|
|
|
|
+use Illuminate\Filesystem\Cache;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use PHPUnit\Util\Exception;
|
|
use PHPUnit\Util\Exception;
|
|
|
|
|
|
@@ -22,6 +24,7 @@ class HomeController extends Controller
|
|
* 获取位置信息,经纬度
|
|
* 获取位置信息,经纬度
|
|
*/
|
|
*/
|
|
public function get_location(Request $request){
|
|
public function get_location(Request $request){
|
|
|
|
+ dd(RedisService::redis()->get('user_location_'.$request->uniqueID));
|
|
try {
|
|
try {
|
|
if(!isset($request->latitude) || $request->latitude==""){
|
|
if(!isset($request->latitude) || $request->latitude==""){
|
|
throw new Exception("参数错误");
|
|
throw new Exception("参数错误");
|
|
@@ -29,9 +32,12 @@ class HomeController extends Controller
|
|
if(!isset($request->longitude) || $request->longitude==""){
|
|
if(!isset($request->longitude) || $request->longitude==""){
|
|
throw new Exception("参数错误");
|
|
throw new Exception("参数错误");
|
|
}
|
|
}
|
|
|
|
+ if(!isset($request->uniqueID) || $request->uniqueID==""){
|
|
|
|
+ throw new Exception("参数错误");
|
|
|
|
+ }
|
|
$user = auth('api')->user();
|
|
$user = auth('api')->user();
|
|
if(!$user){
|
|
if(!$user){
|
|
-
|
|
|
|
|
|
+ RedisService::redis()->SETEX('user_location_' . $request->uniqueID, 600, json_encode(['latitude' => $request->latitude, 'longitude' => $request->longitude]));
|
|
}
|
|
}
|
|
}catch (\Exception $exception){
|
|
}catch (\Exception $exception){
|
|
return $this->response->errorForbidden($exception->getMessage());
|
|
return $this->response->errorForbidden($exception->getMessage());
|
|
@@ -50,6 +56,8 @@ class HomeController extends Controller
|
|
$param['nearby'] = $request->post('nearby',1);//附近
|
|
$param['nearby'] = $request->post('nearby',1);//附近
|
|
$param['online'] = $request->post('online',1);//在线
|
|
$param['online'] = $request->post('online',1);//在线
|
|
$param['new'] = $request->post('new',1);//新人
|
|
$param['new'] = $request->post('new',1);//新人
|
|
|
|
+ $param['latitude'] = $request->post('latitude','30.663436');//纬度
|
|
|
|
+ $param['longitude'] = $request->post('longitude','104.072224');//经度
|
|
$res = $this->homeService->get_list($param);
|
|
$res = $this->homeService->get_list($param);
|
|
}catch (\Exception $exception){
|
|
}catch (\Exception $exception){
|
|
return $this->response->errorForbidden($exception->getMessage());
|
|
return $this->response->errorForbidden($exception->getMessage());
|