CoachLocationController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace App\Http\Controllers\Client;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\Client\CoachLocationService;
  5. use Illuminate\Http\Request;
  6. /**
  7. * @group 用户端-技师定位管理
  8. *
  9. * 技师定位相关的API接口
  10. */
  11. class CoachLocationController extends Controller
  12. {
  13. protected $coachLocationService;
  14. /**
  15. * CoachLocationController constructor.
  16. */
  17. public function __construct(CoachLocationService $coachLocationService)
  18. {
  19. $this->coachLocationService = $coachLocationService;
  20. }
  21. /**
  22. * 获取定位列表
  23. *
  24. * @authenticated
  25. *
  26. * @response {
  27. * "code": 200,
  28. * "message": "获取成功",
  29. * "data": [
  30. * {
  31. * "id": 1,
  32. * "type": "home",
  33. * "latitude": 34.0522,
  34. * "longitude": -118.2437,
  35. * "city": "Los Angeles",
  36. * "district": "Downtown",
  37. * "location": "123 Main St",
  38. * "area_code": "90001"
  39. * }
  40. * ]
  41. * }
  42. */
  43. public function index()
  44. {
  45. return $this->coachLocationService->getAllLocations();
  46. }
  47. /**
  48. * 创建定位
  49. *
  50. * @authenticated
  51. *
  52. * @bodyParam type string required 类型. Example: home
  53. * @bodyParam latitude float required 纬度. Example: 34.0522
  54. * @bodyParam longitude float required 经度. Example: -118.2437
  55. * @bodyParam city string required 市. Example: Los Angeles
  56. * @bodyParam district string required 区. Example: Downtown
  57. * @bodyParam location string required 详细地址. Example: 123 Main St
  58. * @bodyParam area_code string required 区域编码. Example: 90001
  59. *
  60. * @response {
  61. * "code": 200,
  62. * "message": "创建成功",
  63. * "data": {
  64. * "id": 1,
  65. * "type": "home",
  66. * "latitude": 34.0522,
  67. * "longitude": -118.2437,
  68. * "city": "Los Angeles",
  69. * "district": "Downtown",
  70. * "location": "123 Main St",
  71. * "area_code": "90001"
  72. * }
  73. * }
  74. */
  75. public function store(Request $request)
  76. {
  77. return $this->coachLocationService->createLocation($request->all());
  78. }
  79. /**
  80. * 删除定位
  81. *
  82. * @authenticated
  83. *
  84. * @bodyParam coach_id int required 技师ID. Example: 1
  85. * @bodyParam type string required 类型. Example: home
  86. *
  87. * @response {
  88. * "code": 200,
  89. * "message": "删除成功",
  90. * "data": null
  91. * }
  92. */
  93. public function destroy(Request $request)
  94. {
  95. $type = $request->type;
  96. $coachId = $request->coach_id;
  97. return $this->coachLocationService->deleteLocation($coachId, $type);
  98. }
  99. }