You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gofaster/internal/auth/repository"
|
|
|
|
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RouteSyncService 路由同步服务
|
|
|
|
type RouteSyncService struct {
|
|
|
|
authResourcesRepo *repository.AuthResourcesRepository
|
|
|
|
log *zap.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewRouteSyncService 创建路由同步服务实例
|
|
|
|
func NewRouteSyncService(
|
|
|
|
authResourcesRepo *repository.AuthResourcesRepository,
|
|
|
|
log *zap.Logger,
|
|
|
|
) *RouteSyncService {
|
|
|
|
return &RouteSyncService{
|
|
|
|
authResourcesRepo: authResourcesRepo,
|
|
|
|
log: log,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSyncStatus 获取同步状态
|
|
|
|
func (s *RouteSyncService) GetSyncStatus() (map[string]interface{}, error) {
|
|
|
|
// 获取数据库中的路由映射总数
|
|
|
|
totalMappings, err := s.authResourcesRepo.List()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// 统计各模块的路由数量
|
|
|
|
moduleStats := make(map[string]int)
|
|
|
|
for _, mapping := range totalMappings {
|
|
|
|
moduleStats[mapping.Module]++
|
|
|
|
}
|
|
|
|
|
|
|
|
return map[string]interface{}{
|
|
|
|
"total_mappings": len(totalMappings),
|
|
|
|
"module_stats": moduleStats,
|
|
|
|
"last_sync": "前台同步",
|
|
|
|
}, nil
|
|
|
|
}
|