CoachLocationController.php 2.6 KB

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