39 lines
904 B
Go
39 lines
904 B
Go
package system
|
|
|
|
import (
|
|
"context"
|
|
|
|
"kra/internal/biz/system"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type autoCodePluginRepo struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
// NewAutoCodePluginRepo 创建插件仓储
|
|
func NewAutoCodePluginRepo(db *gorm.DB) system.AutoCodePluginRepo {
|
|
return &autoCodePluginRepo{db: db}
|
|
}
|
|
|
|
// GetMenusByIDs 根据ID列表获取菜单
|
|
func (r *autoCodePluginRepo) GetMenusByIDs(ctx context.Context, ids []uint) ([]system.SysBaseMenu, error) {
|
|
var menus []system.SysBaseMenu
|
|
if len(ids) == 0 {
|
|
return menus, nil
|
|
}
|
|
err := r.db.WithContext(ctx).Where("id IN ?", ids).Find(&menus).Error
|
|
return menus, err
|
|
}
|
|
|
|
// GetApisByIDs 根据ID列表获取API
|
|
func (r *autoCodePluginRepo) GetApisByIDs(ctx context.Context, ids []uint) ([]system.SysApi, error) {
|
|
var apis []system.SysApi
|
|
if len(ids) == 0 {
|
|
return apis, nil
|
|
}
|
|
err := r.db.WithContext(ctx).Where("id IN ?", ids).Find(&apis).Error
|
|
return apis, err
|
|
}
|