TermImportResource.php 995 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Resources\V3;
  3. use App\Services\V3\TermExchangeService;
  4. use Illuminate\Http\Request;
  5. /**
  6. * 一次术语导入的结果({@see TermExchangeService})。部分成功:出错的行跳过,`errors` 逐行给出原因(`row` 是表格行号)。
  7. * `reindexed` 为 false 表示改动较多,搜索索引等每周的全量重建补上。
  8. */
  9. class TermImportResource extends BaseResource
  10. {
  11. /**
  12. * @return array{
  13. * created: int,
  14. * updated: int,
  15. * unchanged: int,
  16. * reindexed: bool,
  17. * errors: list<array{row: int, message: string}>
  18. * }
  19. */
  20. public function toArray(Request $request): array
  21. {
  22. return [
  23. 'created' => $this->resource['created'],
  24. 'updated' => $this->resource['updated'],
  25. 'unchanged' => $this->resource['unchanged'],
  26. 'reindexed' => $this->resource['reindexed'],
  27. 'errors' => $this->resource['errors'],
  28. ];
  29. }
  30. }