unit test
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import 'package:fotodocumentation/controller/base_controller.dart';
|
||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||
|
||||
abstract interface class FotoCustomerController {
|
||||
Future<List<CustomerListDto>> getAll(String query, String startsWith);
|
||||
|
||||
Future<CustomerDto?> get({required int id});
|
||||
|
||||
Future<List<int>> export({required int customerId, int? pictureId});
|
||||
}
|
||||
|
||||
class FotoCustomerControllerImpl extends BaseController implements FotoCustomerController {
|
||||
final String path = "customer";
|
||||
|
||||
@override
|
||||
Future<List<CustomerListDto>> getAll(String query, String startsWith) async {
|
||||
String uriStr = '${uriUtils.getBaseUrl()}$path?query=$query&startsWith=$startsWith';
|
||||
return runGetListWithAuth(uriStr, (p0) {
|
||||
List<CustomerListDto> retVal = [];
|
||||
for (var elem in p0) {
|
||||
var entity = CustomerListDto.fromJson(elem);
|
||||
retVal.add(entity);
|
||||
}
|
||||
return retVal;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CustomerDto?> get({required int id}) {
|
||||
String uriStr = '${uriUtils.getBaseUrl()}$path/$id';
|
||||
return runGetWithAuth(uriStr, (json) => CustomerDto.fromJson(json));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<int>> export({required int customerId, int? pictureId}) {
|
||||
String uriStr = '${uriUtils.getBaseUrl()}$path/export/$customerId';
|
||||
if (pictureId != null) {
|
||||
uriStr += '?picture=$pictureId';
|
||||
}
|
||||
return runGetBytesWithAuth(uriStr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user