This commit is contained in:
2025-06-18 17:44:49 +08:00
parent b171122a32
commit 0878a4e6de
66 changed files with 2841 additions and 1423 deletions

View File

@@ -22,22 +22,25 @@ import (
type userService struct {
*v1.Service
repo system.UserRepository
roleService v1.RoleService
loginLogService v1.LoginLogService
repo system.UserRepository
roleService v1.RoleService
departmentService v1.DepartmentService
loginLogService v1.LoginLogService
}
func NewUserService(
service *v1.Service,
repo system.UserRepository,
roleService v1.RoleService,
departmentService v1.DepartmentService,
loginLogService v1.LoginLogService,
) v1.UserService {
return &userService{
Service: service,
repo: repo,
roleService: roleService,
loginLogService: loginLogService,
Service: service,
repo: repo,
roleService: roleService,
departmentService: departmentService,
loginLogService: loginLogService,
}
}
@@ -111,7 +114,22 @@ func (s *userService) All(ctx context.Context) ([]*system.User, error) {
}
func (s *userService) List(ctx context.Context, q dto.SearchDto) ([]*system.User, int64, error) {
return s.repo.List(ctx, q)
count, err := s.repo.Count(ctx, q)
if err != nil {
return nil, 0, err
}
res, err := s.repo.List(ctx, q)
if err != nil {
return nil, 0, err
}
for _, user := range res {
user.Role, _ = s.roleService.Get(ctx, user.RoleID)
user.Department, _ = s.departmentService.Get(ctx, user.DepartmentID)
}
return res, count, nil
}
func (s *userService) Get(ctx context.Context, id int32) (*system.User, error) {