ProgressController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Http\Controllers\V3;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Requests\V3\IndexProgressRequest;
  5. use App\Http\Resources\V3\ProgressResource;
  6. use App\Services\V3\ProgressService;
  7. class ProgressController extends Controller
  8. {
  9. public function __construct(private readonly ProgressService $progress) {}
  10. /**
  11. * 列出章节翻译进度
  12. *
  13. * 按 channel 查询各章节的翻译完成度。分页与 meta 全由框架算。
  14. *
  15. * 原来有个 `view` 参数,但它只有 `channel` 一个合法值、传别的直接 422——
  16. * 那不是业务路径开关而是噪音,已去掉(硬规范第 1 条)。
  17. *
  18. * @unauthenticated
  19. *
  20. * @queryParam channels string required channel uid 列表,**下划线分隔**(不是逗号)
  21. * @queryParam level integer 只返回该层级及以上的章节,需联查 pali_texts
  22. * @queryParam lang string 按译文语言过滤。Example: zh-Hans
  23. * @queryParam book integer 按典籍 id 过滤
  24. * @queryParam order string 排序字段,白名单内。Enum: book,para,lang,progress,title,last_chapter_completed_at,completed_at,updated_at Default: completed_at
  25. * @queryParam dir string 排序方向。Enum: asc,desc Default: desc
  26. * @queryParam page integer 页码。Default: 1
  27. * @queryParam per_page integer 每页数量,最大 200。Default: 10
  28. */
  29. public function index(IndexProgressRequest $request)
  30. {
  31. return ProgressResource::collection(
  32. $this->progress->chapters($request->validated())
  33. );
  34. }
  35. }