TipitakaContentController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\DTO\Search\HitItemDTO;
  4. use App\Http\Api\ChannelApi;
  5. use App\Services\OpenSearchService;
  6. use Illuminate\Http\Request;
  7. class TipitakaContentController extends Controller
  8. {
  9. /**
  10. * Display a listing of the resource.
  11. */
  12. public function index()
  13. {
  14. //
  15. }
  16. /**
  17. * Store a newly created resource in storage.
  18. */
  19. public function store(Request $request)
  20. {
  21. //
  22. }
  23. /**
  24. * Display the specified resource.
  25. */
  26. public function show(Request $request, string $id)
  27. {
  28. //
  29. $channelId = $request->input('channel', ChannelApi::getSysChannel('_System_Pali_VRI_'));
  30. $openSearchId = "tipitaka_chapter_{$id}_{$channelId}";
  31. try {
  32. $doc = HitItemDTO::fromArray(app(OpenSearchService::class)->get($openSearchId))->toArray();
  33. } catch (\Throwable $th) {
  34. return $this->error('resouce invalid'.$th->getMessage());
  35. }
  36. $display = $doc['display'] ?? '';
  37. return $this->ok($display);
  38. }
  39. /**
  40. * Update the specified resource in storage.
  41. */
  42. public function update(Request $request, string $id)
  43. {
  44. //
  45. }
  46. /**
  47. * Remove the specified resource from storage.
  48. */
  49. public function destroy(string $id)
  50. {
  51. //
  52. }
  53. }