package service import ( "backend/services/user-svc/internal/domain" "backend/services/user-svc/internal/repository" "backend/shared/pkg/errors" ) type UserService struct { repo *repository.UserRepository } func NewUserService(repo *repository.UserRepository) *UserService { return &UserService{repo: repo} } // Register 用户注册 func (s *UserService) Register(req *domain.RegisterRequest) (*domain.RegisterResponse, error) { // 验证请求参数 if req.Account == "" { return nil, errors.ErrInvalidInput } if len(req.Password) < 6 { return nil, errors.ErrInvalidInput } // 调用仓库层注册用户 return s.repo.Register(req) } // GetUserByAccount 根据账号获取用户信息 func (s *UserService) GetUserByAccount(account string) (*domain.User, *domain.UserLoginAccount, *domain.UserLoginPassword, error) { if account == "" { return nil, nil, nil, errors.ErrInvalidInput } return s.repo.GetUserByAccount(account) }