优化结构

This commit is contained in:
Yvan
2026-08-22 12:13:16 +08:00
parent d987244d0e
commit b27a66e9d3
200 changed files with 1794 additions and 1715 deletions
+5 -6
View File
@@ -2,20 +2,19 @@ package system
import (
"context"
"kra/internal/biz"
"kra/internal/biz/system"
"gorm.io/gorm"
)
func (r *apiRepo) IgnoredAPIs(ctx context.Context) ([]*biz.API, error) {
func (r *apiRepo) IgnoredAPIs(ctx context.Context) ([]*system.API, error) {
var pos []ignoredAPIPO
if err := r.data.DB().WithContext(ctx).Find(&pos).Error; err != nil {
return nil, err
}
out := make([]*biz.API, 0, len(pos))
out := make([]*system.API, 0, len(pos))
for _, po := range pos {
out = append(out, &biz.API{Path: po.Path, Method: po.Method})
out = append(out, &system.API{Path: po.Path, Method: po.Method})
}
return out, nil
}
@@ -28,7 +27,7 @@ func (r *apiRepo) SetAPIIgnored(ctx context.Context, path, method string, ignore
}
return r.data.DB().WithContext(ctx).Unscoped().Where("path = ? AND method = ?", po.Path, po.Method).Delete(&ignoredAPIPO{}).Error
}
func (r *apiRepo) ApplyAPISync(ctx context.Context, added, deleted []*biz.API) error {
func (r *apiRepo) ApplyAPISync(ctx context.Context, added, deleted []*system.API) error {
return r.data.DB().WithContext(ctx).Transaction(func(tx *gorm.DB) error {
if len(added) > 0 {
pos := make([]apiPO, 0, len(added))