tourze / wechat-work-staff-bundle
企业微信员工管理模块
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/wechat-work-staff-bundle
Requires
- php: ^8.1
- doctrine/collections: ^2.3
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4
- league/flysystem: ^3.10
- monolog/monolog: ^3.1
- psr/log: ^3|^2|^1
- symfony/config: ^6.4
- symfony/console: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/doctrine-bridge: ^6.4
- symfony/event-dispatcher: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
- symfony/http-kernel: ^6.4
- symfony/messenger: ^6.4
- symfony/property-access: ^6.4
- symfony/routing: ^6.4
- symfony/security-core: ^6.4
- symfony/security-http: ^6.4
- symfony/serializer: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/access-token-bundle: 0.0.*
- tourze/doctrine-indexed-bundle: 0.0.*
- tourze/doctrine-ip-bundle: 0.0.*
- tourze/doctrine-resolve-target-entity-bundle: 0.0.*
- tourze/doctrine-snowflake-bundle: 0.1.*
- tourze/doctrine-timestamp-bundle: 0.0.*
- tourze/doctrine-track-bundle: 0.1.*
- tourze/doctrine-user-bundle: 0.0.*
- tourze/easy-admin-attribute: 0.1.*
- tourze/http-client-bundle: 0.1.*
- tourze/json-rpc-core: 0.0.*
- tourze/json-rpc-lock-bundle: 0.1.*
- tourze/json-rpc-log-bundle: 0.1.*
- tourze/symfony-cron-job-bundle: 0.1.*
- tourze/user-service-contracts: 0.0.*
- tourze/wechat-work-bundle: 0.1.*
- tourze/wechat-work-contracts: 0.0.*
- tourze/wechat-work-external-contact-model: 0.0.*
- tourze/weui-bundle: 0.0.*
- twig/twig: ^3.13|^4.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-11-01 19:34:04 UTC
README
A Symfony Bundle for enterprise WeChat (DingTalk) staff management, providing comprehensive APIs for user, department, and tag management.
Features
- User Management: Create, update, delete, and sync enterprise WeChat users
- Department Management: Handle department structure and hierarchies
- Tag Management: Create and manage user tags for organization
- Avatar Management: Automatic user avatar synchronization and storage
- Authentication: OAuth integration with enterprise WeChat
- Cron Jobs: Automated data synchronization tasks
- JSON-RPC API: RESTful API endpoints for external integration
Installation
composer require tourze/wechat-work-staff-bundle
Quick Start
Basic Configuration
<?php // config/packages/wechat_work_staff.yaml wechat_work_staff: # Configuration will be loaded from other bundles
User Management
<?php use WechatWorkStaffBundle\Service\BizUserService; use WechatWorkStaffBundle\Repository\UserRepository; // Inject the service public function __construct( private BizUserService $userService, private UserRepository $userRepository ) {} // Get user by ID $user = $this->userRepository->findByUserId('user123'); // Sync user data from WeChat Work $this->userService->syncUserData($agentId);
Console Commands
The bundle provides several console commands for data synchronization:
User Management Commands
# Sync user list for specific agent php bin/console wechat-work:sync-user-list <agentId> # Check and update user avatars (runs automatically every 8 hours) php bin/console wechat-work:check-user-avatar
Tag Management Commands
# Sync user tags (runs automatically every 8 hours) php bin/console wechat-work:sync-user-tags # Sync users associated with tags (runs automatically every 20 minutes) php bin/console wechat-work:sync-tag-users
API Endpoints
The bundle provides several controller endpoints:
- Authentication:
/wechat-work/auth/*- OAuth flow handling - User Connection:
/wechat-work/connect/*- User account linking - Testing Endpoints: Various test endpoints for development
JSON-RPC Procedures
Available JSON-RPC procedures:
GetWechatWorkDepartmentTree- Retrieve department hierarchyGetWechatWorkUserByAuthCode- Get user information by auth code
Entities
- User: Enterprise WeChat user entity
- Department: Department/organization structure
- UserTag: User categorization tags
- AgentUser: Association between agents and users
Advanced Usage
Cron Jobs
Automated tasks (configured via AsCronTask attribute):
- Avatar Check: Every 8 hours at minute 14
- Tag Sync: Every 8 hours at minute 30
- Tag Users Sync: Every 20 minutes
Custom Event Listeners
The bundle dispatches events that you can listen to:
<?php use WechatWorkStaffBundle\EventSubscriber\UserTagListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class CustomUserTagListener implements EventSubscriberInterface { // Your custom logic }
Dependencies
This bundle requires:
- PHP 8.1 or higher
- Symfony 6.4 or higher
- Doctrine ORM
- Bundle Dependency Bundle
- HTTP Client Bundle
- WeChat Work Contracts Bundle
- League Flysystem (for avatar storage)
Contributing
Please see CONTRIBUTING.md for details.
Security
Security Considerations
- All external API calls include audit logging
- User data is properly validated and sanitized
- OAuth flows follow security best practices
- Sensitive information is properly encrypted
Reporting Security Issues
Please report security vulnerabilities to security@example.com.
License
The MIT License (MIT). Please see License File for more information.