This commit is contained in:
2026-08-16 09:02:39 +08:00
parent c554152f4f
commit f7f6db8695
105 changed files with 2535 additions and 948 deletions
+10 -10
View File
@@ -63,7 +63,10 @@ func (s *APIService) AllAPI(ctx context.Context, strict bool) ([]*dto.APIRespons
}
func (s *APIService) Groups(ctx context.Context) ([]string, map[string]string, error) {
items, err := s.AllAPI(ctx, false)
// The compatible group endpoint uses an unqualified Find, whose natural order is
// the primary-key ascending order. GetAllApis intentionally uses id DESC,
// so do not reuse it here or the group/dropdown order changes.
items, _, err := s.uc.ListAPIs(ctx, 0, 0, &biz.API{OrderKey: "id"})
if err != nil {
return nil, nil, err
}
@@ -133,15 +136,9 @@ func (s *APIService) SyncAPIResponses(ctx context.Context, routes []dto.APIReque
items := make([]*biz.API, 0, len(routes))
for i := range routes {
routes[i].Path = s.NormalizeRoutePath(routes[i].Path)
if routes[i].APIGroup == "" || routes[i].Description == "" {
group, description := routeMetadata(routes[i].Method, routes[i].Path)
if routes[i].APIGroup == "" {
routes[i].APIGroup = group
}
if routes[i].Description == "" {
routes[i].Description = description
}
}
// The compatible sync endpoint compares Gin's route table directly, so newly
// discovered routes carry only path and method. Group/description are
// intentionally left empty for the operator to fill in the sync dialog.
items = append(items, apiDomain(&routes[i]))
}
return s.SyncAPIs(ctx, items)
@@ -150,6 +147,9 @@ func (s *APIService) SyncAPIResponses(ctx context.Context, routes []dto.APIReque
func (s *APIService) DeleteAPIs(ctx context.Context, ids []uint) error {
return s.uc.DeleteAPIs(ctx, ids)
}
func (s *APIService) DeleteAPI(ctx context.Context, id uint) error {
return s.uc.DeleteAPI(ctx, id)
}
func (s *APIService) APIRoleIDs(ctx context.Context, path, method string) ([]uint, error) {
return s.uc.APIRoleIDs(ctx, path, method)
}