Browse Source

cache get supply

master
daivph 5 years ago
parent
commit
329c2b8c84
3 changed files with 10 additions and 8 deletions
  1. +2
    -1
      lib/data/api/rest_client.dart
  2. +5
    -6
      lib/data/api/rest_client.g.dart
  3. +3
    -1
      lib/data/repository/repository.dart

+ 2
- 1
lib/data/api/rest_client.dart View File

@@ -38,7 +38,8 @@ abstract class RestClient {
Future<Account> updateProfile(@Body() Account account);

@GET("/api/list-supplies-in-warehouses/ALL?q={query}")
Future<List<Supply>> getSupplies({@Path() String query = ""});
Future<List<Supply>> getSupplies(
{@DioOptions() Options options, @Path() String query = ""});

//Common
@PUT("/api/update-fcmToken")

+ 5
- 6
lib/data/api/rest_client.g.dart View File

@@ -128,19 +128,18 @@ class _RestClient implements RestClient {
}

@override
getSupplies({query = ""}) async {
getSupplies({options, query = ""}) async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
queryParameters.removeWhere((k, v) => v == null);
final _data = <String, dynamic>{};
final newOptions = newRequestOptions(options);
newOptions.extra.addAll(_extra);
newOptions.headers.addAll(<String, dynamic>{});
final Response<List<dynamic>> _result = await _dio.request(
'/api/list-supplies-in-warehouses/ALL?q=$query',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
options: newOptions.merge(method: 'GET', baseUrl: baseUrl),
data: _data);
var value = _result.data
.map((dynamic i) => Supply.fromJson(i as Map<String, dynamic>))

+ 3
- 1
lib/data/repository/repository.dart View File

@@ -80,7 +80,9 @@ class Repository {

Future<List<Supply>> getSupplies({String query = ""}) async {
final client = RestClient(dio);
return client.getSupplies(query: query);
var op = buildConfigurableCacheOptions(
forceRefresh: true, maxAge: Duration(days: ConstCommon.kMaxAgeCache));
return client.getSupplies(query: query, options: op);
}

Object getInstanceClass() {

Loading…
Cancel
Save