优化结构

This commit is contained in:
Yvan
2026-08-22 12:13:16 +08:00
parent d987244d0e
commit b27a66e9d3
200 changed files with 1794 additions and 1715 deletions
+7 -7
View File
@@ -2,32 +2,32 @@ package service
import (
"context"
"kra/internal/biz/system"
"kra/internal/biz"
"kra/internal/service/dto"
)
type AuthService struct {
uc *biz.AuthenticationUsecase
uc *system.AuthenticationUsecase
}
func NewAuthService(uc *biz.AuthenticationUsecase) *AuthService {
func NewAuthService(uc *system.AuthenticationUsecase) *AuthService {
return &AuthService{uc: uc}
}
func loginResult(value *biz.AuthenticationResult) *dto.LoginResponse {
func loginResult(value *system.AuthenticationResult) *dto.LoginResponse {
return &dto.LoginResponse{User: convertUser(value.User), Token: value.Token, ExpiresAt: value.ExpiresAt.UnixMilli(), NeedChangePassword: value.NeedChangePassword}
}
func (s *AuthService) Login(ctx context.Context, req *dto.LoginRequest, ip, agent string) (*dto.LoginResponse, error) {
value, err := s.uc.Login(ctx, &biz.LoginAttempt{Username: req.Username, Password: req.Password, CaptchaID: req.CaptchaID, Captcha: req.Captcha, IP: ip, Agent: agent})
value, err := s.uc.Login(ctx, &system.LoginAttempt{Username: req.Username, Password: req.Password, CaptchaID: req.CaptchaID, Captcha: req.Captcha, IP: ip, Agent: agent})
if err != nil {
return nil, err
}
return loginResult(value), nil
}
func (s *AuthService) SwitchAuthority(ctx context.Context, claims *biz.AuthClaims, authorityID uint) (*dto.LoginResponse, error) {
func (s *AuthService) SwitchAuthority(ctx context.Context, claims *system.AuthClaims, authorityID uint) (*dto.LoginResponse, error) {
value, err := s.uc.SwitchAuthority(ctx, claims, authorityID)
if err != nil {
return nil, err
@@ -35,6 +35,6 @@ func (s *AuthService) SwitchAuthority(ctx context.Context, claims *biz.AuthClaim
return loginResult(value), nil
}
func (s *AuthService) AuthenticateToken(ctx context.Context, token string) (*biz.TokenAuthentication, error) {
func (s *AuthService) AuthenticateToken(ctx context.Context, token string) (*system.TokenAuthentication, error) {
return s.uc.AuthenticateToken(ctx, token)
}