This commit is contained in:
2025-04-14 15:28:51 +08:00
parent f100427f8b
commit 371b89ee8d
93 changed files with 3757 additions and 1038 deletions

View File

@@ -0,0 +1,44 @@
package system
import (
"context"
"management/internal/erpserver/model/system"
"gorm.io/gorm"
)
type RoleStore interface {
Create(ctx context.Context, obj *system.Role) error
Update(ctx context.Context, obj *system.Role) error
Get(ctx context.Context, id int32) (*system.Role, error)
}
type roleStore struct {
db *gorm.DB
}
var _ RoleStore = (*roleStore)(nil)
func NewRoleStore(db *gorm.DB) *roleStore {
return &roleStore{
db: db,
}
}
func (s *roleStore) Create(ctx context.Context, obj *system.Role) error {
return s.db.WithContext(ctx).Create(obj).Error
}
func (s *roleStore) Update(ctx context.Context, obj *system.Role) error {
return s.db.WithContext(ctx).Save(obj).Error
}
func (s *roleStore) Get(ctx context.Context, id int32) (*system.Role, error) {
var role system.Role
err := s.db.WithContext(ctx).Where("id =?", id).First(&role).Error
if err != nil {
return nil, err
}
return &role, nil
}