优化结构
This commit is contained in:
@@ -3,16 +3,15 @@ package system
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"kra/internal/biz/system"
|
||||
"time"
|
||||
|
||||
"kra/internal/biz"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type permissionRepo struct{ data Provider }
|
||||
|
||||
func NewPermissionRepo(data Provider) biz.PermissionRepo { return &permissionRepo{data: data} }
|
||||
func NewPermissionRepo(data Provider) system.PermissionRepo { return &permissionRepo{data: data} }
|
||||
|
||||
type menuButtonPO struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
@@ -34,12 +33,12 @@ type authorityButtonPO struct {
|
||||
|
||||
func (authorityButtonPO) TableName() string { return "sys_authority_btns" }
|
||||
|
||||
func (r *permissionRepo) Buttons(ctx context.Context, menuID uint) ([]*biz.MenuButton, error) {
|
||||
func (r *permissionRepo) Buttons(ctx context.Context, menuID uint) ([]*system.MenuButton, error) {
|
||||
var pos []menuButtonPO
|
||||
if err := r.data.DB().WithContext(ctx).Where("sys_base_menu_id = ?", menuID).Find(&pos).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]*biz.MenuButton, 0, len(pos))
|
||||
out := make([]*system.MenuButton, 0, len(pos))
|
||||
for _, po := range pos {
|
||||
out = append(out, menuButtonFromPO(po))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user