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:
@@ -7,6 +7,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"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -37,7 +38,7 @@ func New(
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) ListShopCommissionSummary(ctx context.Context, req *model.ShopCommissionSummaryListReq) (*model.ShopCommissionSummaryPageResult, error) {
|
||||
func (s *Service) ListShopCommissionSummary(ctx context.Context, req *dto.ShopCommissionSummaryListReq) (*dto.ShopCommissionSummaryPageResult, error) {
|
||||
opts := &store.QueryOptions{
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
@@ -61,8 +62,8 @@ func (s *Service) ListShopCommissionSummary(ctx context.Context, req *model.Shop
|
||||
}
|
||||
|
||||
if len(shops) == 0 {
|
||||
return &model.ShopCommissionSummaryPageResult{
|
||||
Items: []model.ShopCommissionSummaryItem{},
|
||||
return &dto.ShopCommissionSummaryPageResult{
|
||||
Items: []dto.ShopCommissionSummaryItem{},
|
||||
Total: 0,
|
||||
Page: opts.Page,
|
||||
Size: opts.PageSize,
|
||||
@@ -101,7 +102,7 @@ func (s *Service) ListShopCommissionSummary(ctx context.Context, req *model.Shop
|
||||
}
|
||||
}
|
||||
|
||||
items := make([]model.ShopCommissionSummaryItem, 0, len(shops))
|
||||
items := make([]dto.ShopCommissionSummaryItem, 0, len(shops))
|
||||
for _, shop := range shops {
|
||||
if req.Username != "" {
|
||||
acc := accountMap[shop.ID]
|
||||
@@ -115,7 +116,7 @@ func (s *Service) ListShopCommissionSummary(ctx context.Context, req *model.Shop
|
||||
items = append(items, item)
|
||||
}
|
||||
|
||||
return &model.ShopCommissionSummaryPageResult{
|
||||
return &dto.ShopCommissionSummaryPageResult{
|
||||
Items: items,
|
||||
Total: total,
|
||||
Page: opts.Page,
|
||||
@@ -123,7 +124,7 @@ func (s *Service) ListShopCommissionSummary(ctx context.Context, req *model.Shop
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) buildCommissionSummaryItem(shop *model.Shop, walletSummary *postgres.ShopCommissionSummary, withdrawnAmount, withdrawingAmount int64, account *model.Account) model.ShopCommissionSummaryItem {
|
||||
func (s *Service) buildCommissionSummaryItem(shop *model.Shop, walletSummary *postgres.ShopCommissionSummary, withdrawnAmount, withdrawingAmount int64, account *model.Account) dto.ShopCommissionSummaryItem {
|
||||
var balance, frozenBalance int64
|
||||
if walletSummary != nil {
|
||||
balance = walletSummary.Balance
|
||||
@@ -143,7 +144,7 @@ func (s *Service) buildCommissionSummaryItem(shop *model.Shop, walletSummary *po
|
||||
phone = account.Phone
|
||||
}
|
||||
|
||||
return model.ShopCommissionSummaryItem{
|
||||
return dto.ShopCommissionSummaryItem{
|
||||
ShopID: shop.ID,
|
||||
ShopName: shop.ShopName,
|
||||
ShopCode: shop.ShopCode,
|
||||
@@ -159,7 +160,7 @@ func (s *Service) buildCommissionSummaryItem(shop *model.Shop, walletSummary *po
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) ListShopWithdrawalRequests(ctx context.Context, shopID uint, req *model.ShopWithdrawalRequestListReq) (*model.ShopWithdrawalRequestPageResult, error) {
|
||||
func (s *Service) ListShopWithdrawalRequests(ctx context.Context, shopID uint, req *dto.ShopWithdrawalRequestListReq) (*dto.ShopWithdrawalRequestPageResult, error) {
|
||||
_, err := s.shopStore.GetByID(ctx, shopID)
|
||||
if err != nil {
|
||||
return nil, errors.New(errors.CodeShopNotFound, "店铺不存在")
|
||||
@@ -230,13 +231,13 @@ func (s *Service) ListShopWithdrawalRequests(ctx context.Context, shopID uint, r
|
||||
}
|
||||
}
|
||||
|
||||
items := make([]model.ShopWithdrawalRequestItem, 0, len(requests))
|
||||
items := make([]dto.ShopWithdrawalRequestItem, 0, len(requests))
|
||||
for _, r := range requests {
|
||||
item := s.buildWithdrawalRequestItem(r, shop.ShopName, shopHierarchy, applicantMap, processorMap)
|
||||
items = append(items, item)
|
||||
}
|
||||
|
||||
return &model.ShopWithdrawalRequestPageResult{
|
||||
return &dto.ShopWithdrawalRequestPageResult{
|
||||
Items: items,
|
||||
Total: total,
|
||||
Page: opts.Page,
|
||||
@@ -244,7 +245,7 @@ func (s *Service) ListShopWithdrawalRequests(ctx context.Context, shopID uint, r
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) buildWithdrawalRequestItem(r *model.CommissionWithdrawalRequest, shopName, shopHierarchy string, applicantMap, processorMap map[uint]string) model.ShopWithdrawalRequestItem {
|
||||
func (s *Service) buildWithdrawalRequestItem(r *model.CommissionWithdrawalRequest, shopName, shopHierarchy string, applicantMap, processorMap map[uint]string) dto.ShopWithdrawalRequestItem {
|
||||
var processorID *uint
|
||||
if r.ProcessorID > 0 {
|
||||
processorID = &r.ProcessorID
|
||||
@@ -274,7 +275,7 @@ func (s *Service) buildWithdrawalRequestItem(r *model.CommissionWithdrawalReques
|
||||
paidAt = r.PaidAt.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
return model.ShopWithdrawalRequestItem{
|
||||
return dto.ShopWithdrawalRequestItem{
|
||||
ID: r.ID,
|
||||
WithdrawalNo: r.WithdrawalNo,
|
||||
Amount: r.Amount,
|
||||
@@ -325,7 +326,7 @@ func (s *Service) buildShopHierarchyPath(ctx context.Context, shop *model.Shop)
|
||||
return path
|
||||
}
|
||||
|
||||
func (s *Service) ListShopCommissionRecords(ctx context.Context, shopID uint, req *model.ShopCommissionRecordListReq) (*model.ShopCommissionRecordPageResult, error) {
|
||||
func (s *Service) ListShopCommissionRecords(ctx context.Context, shopID uint, req *dto.ShopCommissionRecordListReq) (*dto.ShopCommissionRecordPageResult, error) {
|
||||
_, err := s.shopStore.GetByID(ctx, shopID)
|
||||
if err != nil {
|
||||
return nil, errors.New(errors.CodeShopNotFound, "店铺不存在")
|
||||
@@ -356,9 +357,9 @@ func (s *Service) ListShopCommissionRecords(ctx context.Context, shopID uint, re
|
||||
return nil, fmt.Errorf("查询佣金明细失败: %w", err)
|
||||
}
|
||||
|
||||
items := make([]model.ShopCommissionRecordItem, 0, len(records))
|
||||
items := make([]dto.ShopCommissionRecordItem, 0, len(records))
|
||||
for _, r := range records {
|
||||
item := model.ShopCommissionRecordItem{
|
||||
item := dto.ShopCommissionRecordItem{
|
||||
ID: r.ID,
|
||||
Amount: r.Amount,
|
||||
BalanceAfter: r.BalanceAfter,
|
||||
@@ -375,7 +376,7 @@ func (s *Service) ListShopCommissionRecords(ctx context.Context, shopID uint, re
|
||||
items = append(items, item)
|
||||
}
|
||||
|
||||
return &model.ShopCommissionRecordPageResult{
|
||||
return &dto.ShopCommissionRecordPageResult{
|
||||
Items: items,
|
||||
Total: total,
|
||||
Page: opts.Page,
|
||||
|
||||
Reference in New Issue
Block a user