gorm wire

This commit is contained in:
2025-05-07 14:12:53 +08:00
parent 461531c308
commit 68606c76f9
111 changed files with 1726 additions and 5809 deletions

View File

@@ -12,22 +12,22 @@ import (
"management/internal/erpserver/model/form"
"management/internal/erpserver/model/system"
"management/internal/erpserver/model/view"
"management/internal/erpserver/service"
v1 "management/internal/erpserver/service/v1"
"management/internal/pkg/convertor"
"management/internal/pkg/database"
"management/internal/pkg/know"
"management/internal/pkg/redis"
)
type roleService struct {
*service.Service
repo system.RoleRepository
}
var _ v1.RoleService = (*roleService)(nil)
func NewRoleService(repo system.RoleRepository) *roleService {
func NewRoleService(service *service.Service, repo system.RoleRepository) v1.RoleService {
return &roleService{
repo: repo,
Service: service,
repo: repo,
}
}
@@ -111,7 +111,7 @@ func (s *roleService) Get(ctx context.Context, id int32) (*system.Role, error) {
func (s *roleService) All(ctx context.Context) ([]*system.Role, error) {
key := know.GetManageKey(ctx, know.AllRoles)
bs, err := redis.GetBytes(ctx, key)
bs, err := s.Redis.GetBytes(ctx, key)
if err == nil {
var res []*system.Role
if err := json.Unmarshal(bs, &res); err == nil {
@@ -129,7 +129,7 @@ func (s *roleService) All(ctx context.Context) ([]*system.Role, error) {
return nil, err
}
_ = redis.Set(ctx, key, bs, time.Hour*6)
_ = s.Redis.Set(ctx, key, bs, time.Hour*6)
return res, nil
}
@@ -149,7 +149,7 @@ func (s *roleService) RefreshCache(ctx context.Context) error {
return err
}
_ = redis.Set(ctx, key, b, time.Hour*6)
_ = s.Redis.Set(ctx, key, b, time.Hour*6)
return nil
}