고객사 목록 쿼리스트링 연동 및 공통 JSON 파서 도입
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import 'package:superport_v2/core/common/utils/json_utils.dart';
|
||||
|
||||
import '../../domain/entities/group.dart';
|
||||
|
||||
@@ -52,16 +53,16 @@ class GroupDto {
|
||||
);
|
||||
|
||||
static PaginatedResult<Group> parsePaginated(Map<String, dynamic>? json) {
|
||||
final items = (json?['items'] as List<dynamic>? ?? [])
|
||||
.whereType<Map<String, dynamic>>()
|
||||
final rawItems = JsonUtils.extractList(json, keys: const ['items']);
|
||||
final items = rawItems
|
||||
.map(GroupDto.fromJson)
|
||||
.map((dto) => dto.toEntity())
|
||||
.toList();
|
||||
.toList(growable: false);
|
||||
return PaginatedResult<Group>(
|
||||
items: items,
|
||||
page: json?['page'] as int? ?? 1,
|
||||
pageSize: json?['page_size'] as int? ?? items.length,
|
||||
total: json?['total'] as int? ?? items.length,
|
||||
page: JsonUtils.readInt(json, 'page', fallback: 1),
|
||||
pageSize: JsonUtils.readInt(json, 'page_size', fallback: items.length),
|
||||
total: JsonUtils.readInt(json, 'total', fallback: items.length),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user