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:
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"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/constants"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||
@@ -46,7 +47,7 @@ func New(
|
||||
}
|
||||
|
||||
// GetCommissionSummary 获取我的佣金概览
|
||||
func (s *Service) GetCommissionSummary(ctx context.Context) (*model.MyCommissionSummaryResp, error) {
|
||||
func (s *Service) GetCommissionSummary(ctx context.Context) (*dto.MyCommissionSummaryResp, error) {
|
||||
userType := middleware.GetUserTypeFromContext(ctx)
|
||||
if userType != constants.UserTypeAgent {
|
||||
return nil, errors.New(errors.CodeForbidden, "仅代理商用户可访问")
|
||||
@@ -66,7 +67,7 @@ func (s *Service) GetCommissionSummary(ctx context.Context) (*model.MyCommission
|
||||
wallet, err := s.walletStore.GetShopCommissionWallet(ctx, shopID)
|
||||
if err != nil {
|
||||
// 钱包不存在时返回空数据
|
||||
return &model.MyCommissionSummaryResp{
|
||||
return &dto.MyCommissionSummaryResp{
|
||||
ShopID: shopID,
|
||||
ShopName: shop.ShopName,
|
||||
}, nil
|
||||
@@ -82,7 +83,7 @@ func (s *Service) GetCommissionSummary(ctx context.Context) (*model.MyCommission
|
||||
|
||||
totalCommission := wallet.Balance + wallet.FrozenBalance + totalWithdrawn
|
||||
|
||||
return &model.MyCommissionSummaryResp{
|
||||
return &dto.MyCommissionSummaryResp{
|
||||
ShopID: shopID,
|
||||
ShopName: shop.ShopName,
|
||||
TotalCommission: totalCommission,
|
||||
@@ -95,7 +96,7 @@ func (s *Service) GetCommissionSummary(ctx context.Context) (*model.MyCommission
|
||||
}
|
||||
|
||||
// CreateWithdrawalRequest 发起提现申请
|
||||
func (s *Service) CreateWithdrawalRequest(ctx context.Context, req *model.CreateMyWithdrawalReq) (*model.CreateMyWithdrawalResp, error) {
|
||||
func (s *Service) CreateWithdrawalRequest(ctx context.Context, req *dto.CreateMyWithdrawalReq) (*dto.CreateMyWithdrawalResp, error) {
|
||||
userType := middleware.GetUserTypeFromContext(ctx)
|
||||
if userType != constants.UserTypeAgent {
|
||||
return nil, errors.New(errors.CodeForbidden, "仅代理商用户可访问")
|
||||
@@ -216,7 +217,7 @@ func (s *Service) CreateWithdrawalRequest(ctx context.Context, req *model.Create
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &model.CreateMyWithdrawalResp{
|
||||
return &dto.CreateMyWithdrawalResp{
|
||||
ID: withdrawalRequest.ID,
|
||||
WithdrawalNo: withdrawalRequest.WithdrawalNo,
|
||||
Amount: withdrawalRequest.Amount,
|
||||
@@ -230,7 +231,7 @@ func (s *Service) CreateWithdrawalRequest(ctx context.Context, req *model.Create
|
||||
}
|
||||
|
||||
// ListMyWithdrawalRequests 查询我的提现记录
|
||||
func (s *Service) ListMyWithdrawalRequests(ctx context.Context, req *model.MyWithdrawalListReq) (*model.WithdrawalRequestPageResult, error) {
|
||||
func (s *Service) ListMyWithdrawalRequests(ctx context.Context, req *dto.MyWithdrawalListReq) (*dto.WithdrawalRequestPageResult, error) {
|
||||
userType := middleware.GetUserTypeFromContext(ctx)
|
||||
if userType != constants.UserTypeAgent {
|
||||
return nil, errors.New(errors.CodeForbidden, "仅代理商用户可访问")
|
||||
@@ -274,12 +275,12 @@ func (s *Service) ListMyWithdrawalRequests(ctx context.Context, req *model.MyWit
|
||||
return nil, fmt.Errorf("查询提现记录失败: %w", err)
|
||||
}
|
||||
|
||||
items := make([]model.WithdrawalRequestItem, 0, len(requests))
|
||||
items := make([]dto.WithdrawalRequestItem, 0, len(requests))
|
||||
for _, r := range requests {
|
||||
// 解析账户信息
|
||||
accountName, accountNumber := parseAccountInfo(r.AccountInfo)
|
||||
|
||||
items = append(items, model.WithdrawalRequestItem{
|
||||
items = append(items, dto.WithdrawalRequestItem{
|
||||
ID: r.ID,
|
||||
WithdrawalNo: r.WithdrawalNo,
|
||||
ShopID: r.ShopID,
|
||||
@@ -296,7 +297,7 @@ func (s *Service) ListMyWithdrawalRequests(ctx context.Context, req *model.MyWit
|
||||
})
|
||||
}
|
||||
|
||||
return &model.WithdrawalRequestPageResult{
|
||||
return &dto.WithdrawalRequestPageResult{
|
||||
Items: items,
|
||||
Total: total,
|
||||
Page: page,
|
||||
@@ -305,7 +306,7 @@ func (s *Service) ListMyWithdrawalRequests(ctx context.Context, req *model.MyWit
|
||||
}
|
||||
|
||||
// ListMyCommissionRecords 查询我的佣金明细
|
||||
func (s *Service) ListMyCommissionRecords(ctx context.Context, req *model.MyCommissionRecordListReq) (*model.MyCommissionRecordPageResult, error) {
|
||||
func (s *Service) ListMyCommissionRecords(ctx context.Context, req *dto.MyCommissionRecordListReq) (*dto.MyCommissionRecordPageResult, error) {
|
||||
userType := middleware.GetUserTypeFromContext(ctx)
|
||||
if userType != constants.UserTypeAgent {
|
||||
return nil, errors.New(errors.CodeForbidden, "仅代理商用户可访问")
|
||||
@@ -343,9 +344,9 @@ func (s *Service) ListMyCommissionRecords(ctx context.Context, req *model.MyComm
|
||||
return nil, fmt.Errorf("查询佣金记录失败: %w", err)
|
||||
}
|
||||
|
||||
items := make([]model.MyCommissionRecordItem, 0, len(records))
|
||||
items := make([]dto.MyCommissionRecordItem, 0, len(records))
|
||||
for _, r := range records {
|
||||
items = append(items, model.MyCommissionRecordItem{
|
||||
items = append(items, dto.MyCommissionRecordItem{
|
||||
ID: r.ID,
|
||||
ShopID: r.ShopID,
|
||||
OrderID: r.OrderID,
|
||||
@@ -357,7 +358,7 @@ func (s *Service) ListMyCommissionRecords(ctx context.Context, req *model.MyComm
|
||||
})
|
||||
}
|
||||
|
||||
return &model.MyCommissionRecordPageResult{
|
||||
return &dto.MyCommissionRecordPageResult{
|
||||
Items: items,
|
||||
Total: total,
|
||||
Page: page,
|
||||
|
||||
Reference in New Issue
Block a user