tourze / delivery-address-bundle
收货地址管理(实体+JSON-RPC Procedure)
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/delivery-address-bundle
Requires
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/doctrine-fixtures-bundle: ^4.0
- doctrine/orm: ^3.0
- doctrine/persistence: ^4.1
- easycorp/easyadmin-bundle: ^4
- knplabs/knp-menu: ^3.7
- psr/simple-cache: ^1.0|^2.0|^3.0
- symfony/cache: ^7.3
- symfony/config: ^7.3
- symfony/console: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/doctrine-bridge: ^7.3
- symfony/event-dispatcher: ^7.3
- symfony/framework-bundle: ^7.3
- symfony/http-kernel: ^7.3
- symfony/property-access: ^7.3
- symfony/security-bundle: ^7.3
- symfony/security-core: ^7.3
- symfony/security-http: ^7.3
- symfony/serializer: ^7.3
- symfony/string: ^7.3
- symfony/validator: ^7.3
- symfony/yaml: ^7.3
- tourze/arrayable: 1.*
- tourze/bundle-dependency: 1.*
- tourze/doctrine-indexed-bundle: 1.0.*
- tourze/doctrine-ip-bundle: 1.0.*
- tourze/doctrine-snowflake-bundle: 1.0.*
- tourze/doctrine-timestamp-bundle: 1.0.*
- tourze/doctrine-user-bundle: 1.0.*
- tourze/easy-admin-enum-field-bundle: 1.0.*
- tourze/easy-admin-menu-bundle: 1.0.*
- tourze/gb-t-2261: 1.0.*
- tourze/json-rpc-cache-bundle: 1.0.*
- tourze/json-rpc-core: 1.0.*
- tourze/json-rpc-lock-bundle: 1.0.*
- tourze/json-rpc-paginator-bundle: 1.0.*
- tourze/json-rpc-security-bundle: 1.0.*
- tourze/symfony-dependency-service-loader: 1.0.*
- tourze/user-service-contracts: 1.*
Requires (Dev)
This package is auto-updated.
Last update: 2025-11-05 08:53:22 UTC
README
A Symfony bundle for managing delivery addresses with JSON-RPC Procedures and EasyAdmin integration.
Features
- ✅ Complete delivery address entity management
- 🔌 JSON-RPC procedures for address operations
- 🔐 User-based access control
- ⭐ Default address handling
- 🎨 EasyAdmin CRUD interface
- 🧪 Comprehensive test coverage (238 tests)
- 🌐 Multi-language support (EN/CN)
- 📍 GB/T 2261 administrative division codes support
Installation
composer require tourze/delivery-address-bundle
Configuration
Add the bundle to your config/bundles.php:
return [ // ... Tourze\DeliveryAddressBundle\DeliveryAddressBundle::class => ['all' => true], ];
Run migrations to create the database tables:
php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
JSON-RPC Procedures
Address Management
GetDeliveryAddressList- Get user's address list with paginationGetDeliveryAddressDetail- Get address details by IDCreateDeliveryAddress- Create new delivery addressUpdateDeliveryAddress- Update existing addressDeleteDeliveryAddress- Delete address by ID
Default Address
SetDefaultDeliveryAddress- Set address as defaultGetDefaultDeliveryAddress- Get user's default address
Note: All procedures require authentication (
IS_AUTHENTICATED_FULLY)
Entity
DeliveryAddress
The main entity representing a delivery address:
use Tourze\DeliveryAddressBundle\Entity\DeliveryAddress; // Entity fields: // - id: Primary key (BIGINT) // - user: UserInterface relation (owner) // - sn: Unique snowflake identifier // - consignee: Recipient name (max 50 chars) // - mobile: Contact phone number (max 20 chars) // - country: Country name (optional, max 64 chars) // - province: Province/state (max 64 chars) // - provinceCode: Province code (optional, max 20 chars) // - city: City name (max 64 chars) // - cityCode: City code (optional, max 20 chars) // - district: District/county (max 64 chars) // - districtCode: District code (optional, max 20 chars) // - addressLine: Detailed address (max 255 chars) // - postalCode: Postal/ZIP code (optional, max 20 chars) // - addressTag: Address label like "home", "office" (optional, max 20 chars) // - gender: Gender enum (optional, using GB/T 2261 standard) // - isDefault: Default address flag (boolean) // - createTime/updateTime: Timestamps (auto-managed) // - createdBy/updatedBy: Blameable tracking // - createdFromIp/updatedFromIp: IP tracking
Repository
The DeliveryAddressRepository provides several query methods:
use Tourze\DeliveryAddressBundle\Repository\DeliveryAddressRepository; // Query by user object $qb = $repository->buildListQueryByUser($user); // Query by user identifier (uses UserInterface::getUserIdentifier()) $qb = $repository->buildListQueryByUserId('user123'); // Find default address $address = $repository->findDefaultByUser($user); $address = $repository->findDefaultByUserId('user123'); // Unset default for user $affectedRows = $repository->unsetDefaultForUser($user);
Important: The
buildListQueryByUserId()andfindDefaultByUserId()methods useuserIdentifierfield (Symfony 6+ standard), notusername.
Admin Interface
The bundle provides an EasyAdmin CRUD controller at /admin for address management with:
- List view with filtering and searching
- Form creation and editing
- Batch operations
- User-based data isolation
- Automatic IP and user tracking
Development
Running Tests
# Run all tests (238 tests) ./vendor/bin/phpunit packages/delivery-address-bundle/tests # Run specific test suite ./vendor/bin/phpunit packages/delivery-address-bundle/tests/Entity ./vendor/bin/phpunit packages/delivery-address-bundle/tests/Repository ./vendor/bin/phpunit packages/delivery-address-bundle/tests/Procedure
Code Quality
# PHPStan static analysis (Level 9)
php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/delivery-address-bundle/src --level=9
Architecture
Service Layer
DeliveryAddressService: Business logic layer for address operations- Handles validation, default address management, and entity lifecycle
Event Listeners
DeliveryAddressEntityListener: Doctrine entity lifecycle events- Automatic field validation and consistency checks
Data Fixtures
DeliveryAddressFixtures: Test data generation for development and testing- Uses
UserManagerInterfacefor user creation
Requirements
- PHP 8.1+
- Symfony 7.3+
- Doctrine ORM 3.0+
Dependencies
This bundle requires several other packages from the tourze/* ecosystem:
tourze/json-rpc-core: JSON-RPC server infrastructuretourze/doctrine-*-bundle: Doctrine extensions (timestamps, IP tracking, user tracking, etc.)tourze/easy-admin-*-bundle: EasyAdmin extensionstourze/user-service-contracts: User management contracts
See composer.json for the complete list.
License
MIT License. See LICENSE file for details.