refactor: 将 DTO 文件从 internal/model 移动到 internal/model/dto 目录
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m22s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m22s
- 移动 17 个 DTO 文件到 internal/model/dto/ 目录 - 更新所有 DTO 文件的 package 声明从 model 改为 dto - 更新所有引用文件的 import 和类型引用 - Handler 层:admin 和 h5 所有处理器 - Service 层:所有业务服务 - Routes 层:所有路由定义 - Tests 层:单元测试和集成测试 - 清理未使用的 import 语句 - 验证:项目构建成功,测试编译通过,LSP 无错误
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/auth"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -42,7 +43,7 @@ func New(
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) Login(ctx context.Context, req *model.LoginRequest, clientIP string) (*model.LoginResponse, error) {
|
||||
func (s *Service) Login(ctx context.Context, req *dto.LoginRequest, clientIP string) (*dto.LoginResponse, error) {
|
||||
ctx = pkgGorm.SkipDataPermission(ctx)
|
||||
|
||||
account, err := s.accountStore.GetByUsernameOrPhone(ctx, req.Username)
|
||||
@@ -107,7 +108,7 @@ func (s *Service) Login(ctx context.Context, req *model.LoginRequest, clientIP s
|
||||
zap.String("ip", clientIP),
|
||||
)
|
||||
|
||||
return &model.LoginResponse{
|
||||
return &dto.LoginResponse{
|
||||
AccessToken: accessToken,
|
||||
RefreshToken: refreshToken,
|
||||
ExpiresIn: int64(constants.DefaultAccessTokenTTL.Seconds()),
|
||||
@@ -134,7 +135,7 @@ func (s *Service) RefreshToken(ctx context.Context, refreshToken string) (string
|
||||
return s.tokenManager.RefreshAccessToken(ctx, refreshToken)
|
||||
}
|
||||
|
||||
func (s *Service) GetCurrentUser(ctx context.Context, userID uint) (*model.UserInfo, []string, error) {
|
||||
func (s *Service) GetCurrentUser(ctx context.Context, userID uint) (*dto.UserInfo, []string, error) {
|
||||
account, err := s.accountStore.GetByID(ctx, userID)
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
@@ -222,7 +223,7 @@ func (s *Service) getUserPermissions(ctx context.Context, userID uint) ([]string
|
||||
return permCodes, nil
|
||||
}
|
||||
|
||||
func (s *Service) buildUserInfo(account *model.Account) model.UserInfo {
|
||||
func (s *Service) buildUserInfo(account *model.Account) dto.UserInfo {
|
||||
userTypeName := s.getUserTypeName(account.UserType)
|
||||
|
||||
var shopID, enterpriseID uint
|
||||
@@ -233,7 +234,7 @@ func (s *Service) buildUserInfo(account *model.Account) model.UserInfo {
|
||||
enterpriseID = *account.EnterpriseID
|
||||
}
|
||||
|
||||
return model.UserInfo{
|
||||
return dto.UserInfo{
|
||||
ID: account.ID,
|
||||
Username: account.Username,
|
||||
Phone: account.Phone,
|
||||
|
||||
Reference in New Issue
Block a user