Skip to content

Commit

Permalink
[PDA-44] feat: 비품 추가 및 수정 후 비품 화면 새로 고침
Browse files Browse the repository at this point in the history
  • Loading branch information
chayoosang committed Dec 3, 2023
1 parent cdb545b commit 5e66d88
Show file tree
Hide file tree
Showing 8 changed files with 605 additions and 399 deletions.
7 changes: 7 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ PODS:
- nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1)
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- PromisesObjC (2.3.1)
- Toast (4.0.0)
- url_launcher_ios (0.0.1):
Expand All @@ -80,6 +83,7 @@ DEPENDENCIES:
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

SPEC REPOS:
Expand Down Expand Up @@ -110,6 +114,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/fluttertoast/ios"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

Expand All @@ -129,6 +135,7 @@ SPEC CHECKSUMS:
GoogleUtilities: 202e7a9f5128accd11160fb9c19612de1911aa19
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
url_launcher_ios: 68d46cc9766d0c41dbdc884310529557e3cd7a86
Expand Down
4 changes: 2 additions & 2 deletions lib/Model/network/api_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class APIManager {
options: defaultOptions, queryParameters: queryParameters);
}

// print('api + $response');
// print('api + ${response.data}');
print('api + $response');
print('api + ${response.data}');

return response.data;
}
Expand Down
56 changes: 53 additions & 3 deletions lib/Presenter/equipment/equipment_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:frontend/Model/model/general_model.dart';
import 'package:frontend/Model/network/api_manager.dart';

class EquipmentService {
final equipmentGetURL = '/equipments?cond=';
final equipmentGetURL = '/equipments?size=200&cond=';
final equipmentPostURL = '/equipments';
final equipmentCategoryURL = "/equipments/categories";
final bukitURL =
Expand All @@ -22,9 +22,9 @@ class EquipmentService {
return _equipmentService;
}

Future<dynamic> getEquipment() async {
Future<dynamic> getEquipment(String cond) async {
final response = APIManager()
.request(RequestType.get, equipmentGetURL, null, null, null);
.request(RequestType.get, equipmentGetURL + cond, null, null, null);
return response;
}

Expand Down Expand Up @@ -84,4 +84,54 @@ class EquipmentService {
}
}
}

Future<dynamic> editEquipment(
int equipmentId,
String category,
String? description,
String? imgKey,
String? location,
String name,
String quantity) async {
try {
final body = EquipmentAddRequest(
category: category,
description: description,
imgKey: imgKey,
location: location,
name: name,
quantity: quantity)
.toJson();

var response = APIManager().request(RequestType.patch,
"$equipmentPostURL/$equipmentId", null, null, body);
if (response != null) {
return true;
}
} on DioError catch (e) {
final response = e.response;
if (response != null) {
final error =
GeneralModel.fromJson(response.data as Map<String, dynamic>);
return error.message;
}
}
}

Future<dynamic> deleteEquipment(int equipmentId) async {
try {
var response = APIManager().request(RequestType.delete,
"$equipmentPostURL/$equipmentId", null, null, null);
if (response != null) {
return true;
}
} on DioError catch (e) {
final response = e.response;
if (response != null) {
final error =
GeneralModel.fromJson(response.data as Map<String, dynamic>);
return error.message;
}
}
}
}
Loading

0 comments on commit 5e66d88

Please sign in to comment.