update address

This commit is contained in:
Phuoc Nguyen
2025-11-18 17:04:00 +07:00
parent a5eb95fa64
commit 0dda402246
33 changed files with 4250 additions and 232 deletions

View File

@@ -0,0 +1,59 @@
# City and Ward API Implementation - Complete Guide
## Files Created ✅
1.`lib/features/account/domain/entities/city.dart`
2.`lib/features/account/domain/entities/ward.dart`
3.`lib/features/account/data/models/city_model.dart`
4.`lib/features/account/data/models/ward_model.dart`
5. ✅ Updated `lib/core/constants/storage_constants.dart`
- Added `cityBox` and `wardBox`
- Added `cityModel = 31` and `wardModel = 32`
- Shifted all enum IDs by +2
## Implementation Status
### Completed:
- ✅ Domain entities (City, Ward)
- ✅ Hive models with type adapters
- ✅ Storage constants updated
- ✅ Build runner generated .g.dart files
### Remaining (Need to implement):
1. **Remote Datasource** - `lib/features/account/data/datasources/location_remote_datasource.dart`
2. **Local Datasource** - `lib/features/account/data/datasources/location_local_datasource.dart`
3. **Repository Interface** - `lib/features/account/domain/repositories/location_repository.dart`
4. **Repository Implementation** - `lib/features/account/data/repositories/location_repository_impl.dart`
5. **Providers** - `lib/features/account/presentation/providers/location_provider.dart`
6. **Update AddressFormPage** to use the providers
## API Endpoints (from docs/auth.sh)
### Get Cities:
```bash
POST /api/method/frappe.client.get_list
Body: {
"doctype": "City",
"fields": ["city_name","name","code"],
"limit_page_length": 0
}
```
### Get Wards (filtered by city):
```bash
POST /api/method/frappe.client.get_list
Body: {
"doctype": "Ward",
"fields": ["ward_name","name","code"],
"filters": {"city": "96"},
"limit_page_length": 0
}
```
## Offline-First Strategy
1. **Cities**: Cache in Hive, refresh from API periodically
2. **Wards**: Load from API when city selected, cache per city
Would you like me to generate the remaining implementation files now?