refactor: 将 DTO 文件从 internal/model 移动到 internal/model/dto 目录
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:
2026-01-22 10:15:04 +08:00
parent 23be0a7d3e
commit 46e4e5f4f1
73 changed files with 531 additions and 501 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -17,39 +18,39 @@ func registerAccountRoutes(api fiber.Router, h *admin.AccountHandler, doc *opena
Register(accounts, doc, groupPath, "POST", "", h.Create, RouteSpec{
Summary: "创建账号",
Tags: []string{"账号相关"},
Input: new(model.CreateAccountRequest),
Output: new(model.AccountResponse),
Input: new(dto.CreateAccountRequest),
Output: new(dto.AccountResponse),
Auth: true,
})
Register(accounts, doc, groupPath, "GET", "", h.List, RouteSpec{
Summary: "账号列表",
Tags: []string{"账号相关"},
Input: new(model.AccountListRequest),
Output: new(model.AccountPageResult),
Input: new(dto.AccountListRequest),
Output: new(dto.AccountPageResult),
Auth: true,
})
Register(accounts, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
Summary: "获取账号详情",
Tags: []string{"账号相关"},
Input: new(model.IDReq),
Output: new(model.AccountResponse),
Input: new(dto.IDReq),
Output: new(dto.AccountResponse),
Auth: true,
})
Register(accounts, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
Summary: "更新账号",
Tags: []string{"账号相关"},
Input: new(model.UpdateAccountParams),
Output: new(model.AccountResponse),
Input: new(dto.UpdateAccountParams),
Output: new(dto.AccountResponse),
Auth: true,
})
Register(accounts, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
Summary: "删除账号",
Tags: []string{"账号相关"},
Input: new(model.IDReq),
Input: new(dto.IDReq),
Output: nil,
Auth: true,
})
@@ -58,14 +59,14 @@ func registerAccountRoutes(api fiber.Router, h *admin.AccountHandler, doc *opena
Register(accounts, doc, groupPath, "POST", "/:id/roles", h.AssignRoles, RouteSpec{
Summary: "分配角色",
Tags: []string{"账号相关"},
Input: new(model.AssignRolesParams),
Input: new(dto.AssignRolesParams),
Output: nil, // TODO: Define AccountRole response DTO
})
Register(accounts, doc, groupPath, "GET", "/:id/roles", h.GetRoles, RouteSpec{
Summary: "获取账号角色",
Tags: []string{"账号相关"},
Input: new(model.IDReq),
Input: new(dto.IDReq),
Output: new([]model.Role),
Auth: true,
})
@@ -73,7 +74,7 @@ func registerAccountRoutes(api fiber.Router, h *admin.AccountHandler, doc *opena
Register(accounts, doc, groupPath, "DELETE", "/:account_id/roles/:role_id", h.RemoveRole, RouteSpec{
Summary: "移除角色",
Tags: []string{"账号相关"},
Input: new(model.RemoveRoleParams),
Input: new(dto.RemoveRoleParams),
Output: nil,
Auth: true,
})
@@ -88,39 +89,39 @@ func registerPlatformAccountRoutes(api fiber.Router, h *admin.AccountHandler, do
Register(platformAccounts, doc, groupPath, "GET", "", h.ListPlatformAccounts, RouteSpec{
Summary: "平台账号列表",
Tags: []string{"平台账号"},
Input: new(model.PlatformAccountListRequest),
Output: new(model.AccountPageResult),
Input: new(dto.PlatformAccountListRequest),
Output: new(dto.AccountPageResult),
Auth: true,
})
Register(platformAccounts, doc, groupPath, "POST", "", h.Create, RouteSpec{
Summary: "新增平台账号",
Tags: []string{"平台账号"},
Input: new(model.CreateAccountRequest),
Output: new(model.AccountResponse),
Input: new(dto.CreateAccountRequest),
Output: new(dto.AccountResponse),
Auth: true,
})
Register(platformAccounts, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
Summary: "获取平台账号详情",
Tags: []string{"平台账号"},
Input: new(model.IDReq),
Output: new(model.AccountResponse),
Input: new(dto.IDReq),
Output: new(dto.AccountResponse),
Auth: true,
})
Register(platformAccounts, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
Summary: "编辑平台账号",
Tags: []string{"平台账号"},
Input: new(model.UpdateAccountParams),
Output: new(model.AccountResponse),
Input: new(dto.UpdateAccountParams),
Output: new(dto.AccountResponse),
Auth: true,
})
Register(platformAccounts, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
Summary: "删除平台账号",
Tags: []string{"平台账号"},
Input: new(model.IDReq),
Input: new(dto.IDReq),
Output: nil,
Auth: true,
})
@@ -128,7 +129,7 @@ func registerPlatformAccountRoutes(api fiber.Router, h *admin.AccountHandler, do
Register(platformAccounts, doc, groupPath, "PUT", "/:id/password", h.UpdatePassword, RouteSpec{
Summary: "修改密码",
Tags: []string{"平台账号"},
Input: new(model.UpdatePasswordParams),
Input: new(dto.UpdatePasswordParams),
Output: nil,
Auth: true,
})
@@ -136,7 +137,7 @@ func registerPlatformAccountRoutes(api fiber.Router, h *admin.AccountHandler, do
Register(platformAccounts, doc, groupPath, "PUT", "/:id/status", h.UpdateStatus, RouteSpec{
Summary: "启用/禁用账号",
Tags: []string{"平台账号"},
Input: new(model.UpdateStatusParams),
Input: new(dto.UpdateStatusParams),
Output: nil,
Auth: true,
})
@@ -144,7 +145,7 @@ func registerPlatformAccountRoutes(api fiber.Router, h *admin.AccountHandler, do
Register(platformAccounts, doc, groupPath, "POST", "/:id/roles", h.AssignRoles, RouteSpec{
Summary: "分配角色",
Tags: []string{"平台账号"},
Input: new(model.AssignRolesParams),
Input: new(dto.AssignRolesParams),
Output: nil,
Auth: true,
})
@@ -152,7 +153,7 @@ func registerPlatformAccountRoutes(api fiber.Router, h *admin.AccountHandler, do
Register(platformAccounts, doc, groupPath, "GET", "/:id/roles", h.GetRoles, RouteSpec{
Summary: "获取账号角色",
Tags: []string{"平台账号"},
Input: new(model.IDReq),
Input: new(dto.IDReq),
Output: new([]model.Role),
Auth: true,
})
@@ -160,7 +161,7 @@ func registerPlatformAccountRoutes(api fiber.Router, h *admin.AccountHandler, do
Register(platformAccounts, doc, groupPath, "DELETE", "/:account_id/roles/:role_id", h.RemoveRole, RouteSpec{
Summary: "移除角色",
Tags: []string{"平台账号"},
Input: new(model.RemoveRoleParams),
Input: new(dto.RemoveRoleParams),
Output: nil,
Auth: true,
})

View File

@@ -4,7 +4,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -66,16 +66,16 @@ func registerAdminAuthRoutes(router fiber.Router, handler interface{}, authMiddl
Register(router, doc, basePath, "POST", "/login", h.Login, RouteSpec{
Summary: "后台登录",
Tags: []string{"认证"},
Input: new(model.LoginRequest),
Output: new(model.LoginResponse),
Input: new(dto.LoginRequest),
Output: new(dto.LoginResponse),
Auth: false,
})
Register(router, doc, basePath, "POST", "/refresh-token", h.RefreshToken, RouteSpec{
Summary: "刷新 Token",
Tags: []string{"认证"},
Input: new(model.RefreshTokenRequest),
Output: new(model.RefreshTokenResponse),
Input: new(dto.RefreshTokenRequest),
Output: new(dto.RefreshTokenResponse),
Auth: false,
})
@@ -93,14 +93,14 @@ func registerAdminAuthRoutes(router fiber.Router, handler interface{}, authMiddl
Summary: "获取当前用户信息",
Tags: []string{"认证"},
Input: nil,
Output: new(model.UserInfo),
Output: new(dto.UserInfo),
Auth: true,
})
Register(authGroup, doc, basePath, "PUT", "/password", h.ChangePassword, RouteSpec{
Summary: "修改密码",
Tags: []string{"认证"},
Input: new(model.ChangePasswordRequest),
Input: new(dto.ChangePasswordRequest),
Output: nil,
Auth: true,
})

View File

@@ -4,7 +4,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -15,24 +15,24 @@ func registerCommissionWithdrawalRoutes(router fiber.Router, handler *admin.Comm
Register(commission, doc, groupPath, "GET", "/withdrawal-requests", handler.ListWithdrawalRequests, RouteSpec{
Summary: "提现申请列表",
Tags: []string{"佣金提现审批"},
Input: new(model.WithdrawalRequestListReq),
Output: new(model.WithdrawalRequestPageResult),
Input: new(dto.WithdrawalRequestListReq),
Output: new(dto.WithdrawalRequestPageResult),
Auth: true,
})
Register(commission, doc, groupPath, "POST", "/withdrawal-requests/:id/approve", handler.ApproveWithdrawal, RouteSpec{
Summary: "审批通过提现申请",
Tags: []string{"佣金提现审批"},
Input: new(model.ApproveWithdrawalReq),
Output: new(model.WithdrawalApprovalResp),
Input: new(dto.ApproveWithdrawalReq),
Output: new(dto.WithdrawalApprovalResp),
Auth: true,
})
Register(commission, doc, groupPath, "POST", "/withdrawal-requests/:id/reject", handler.RejectWithdrawal, RouteSpec{
Summary: "拒绝提现申请",
Tags: []string{"佣金提现审批"},
Input: new(model.RejectWithdrawalReq),
Output: new(model.WithdrawalApprovalResp),
Input: new(dto.RejectWithdrawalReq),
Output: new(dto.WithdrawalApprovalResp),
Auth: true,
})
}
@@ -45,16 +45,16 @@ func registerCommissionWithdrawalSettingRoutes(router fiber.Router, handler *adm
Register(commission, doc, groupPath, "POST", "/withdrawal-settings", handler.Create, RouteSpec{
Summary: "新增提现配置",
Tags: []string{"提现配置管理"},
Input: new(model.CreateWithdrawalSettingReq),
Output: new(model.WithdrawalSettingItem),
Input: new(dto.CreateWithdrawalSettingReq),
Output: new(dto.WithdrawalSettingItem),
Auth: true,
})
Register(commission, doc, groupPath, "GET", "/withdrawal-settings", handler.List, RouteSpec{
Summary: "提现配置列表",
Tags: []string{"提现配置管理"},
Input: new(model.WithdrawalSettingListReq),
Output: new(model.WithdrawalSettingPageResult),
Input: new(dto.WithdrawalSettingListReq),
Output: new(dto.WithdrawalSettingPageResult),
Auth: true,
})
@@ -62,7 +62,7 @@ func registerCommissionWithdrawalSettingRoutes(router fiber.Router, handler *adm
Summary: "获取当前生效的提现配置",
Tags: []string{"提现配置管理"},
Input: nil,
Output: new(model.WithdrawalSettingItem),
Output: new(dto.WithdrawalSettingItem),
Auth: true,
})
}

View File

@@ -4,7 +4,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -15,31 +15,31 @@ func registerCustomerAccountRoutes(router fiber.Router, handler *admin.CustomerA
Register(accounts, doc, groupPath, "GET", "", handler.List, RouteSpec{
Summary: "客户账号列表",
Tags: []string{"客户账号管理"},
Input: new(model.CustomerAccountListReq),
Output: new(model.CustomerAccountPageResult),
Input: new(dto.CustomerAccountListReq),
Output: new(dto.CustomerAccountPageResult),
Auth: true,
})
Register(accounts, doc, groupPath, "POST", "", handler.Create, RouteSpec{
Summary: "新增代理商账号",
Tags: []string{"客户账号管理"},
Input: new(model.CreateCustomerAccountReq),
Output: new(model.CustomerAccountItem),
Input: new(dto.CreateCustomerAccountReq),
Output: new(dto.CustomerAccountItem),
Auth: true,
})
Register(accounts, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
Summary: "编辑账号",
Tags: []string{"客户账号管理"},
Input: new(model.UpdateCustomerAccountReq),
Output: new(model.CustomerAccountItem),
Input: new(dto.UpdateCustomerAccountReq),
Output: new(dto.CustomerAccountItem),
Auth: true,
})
Register(accounts, doc, groupPath, "PUT", "/:id/password", handler.UpdatePassword, RouteSpec{
Summary: "修改账号密码",
Tags: []string{"客户账号管理"},
Input: new(model.UpdateCustomerAccountPasswordReq),
Input: new(dto.UpdateCustomerAccountPasswordReq),
Output: nil,
Auth: true,
})
@@ -47,7 +47,7 @@ func registerCustomerAccountRoutes(router fiber.Router, handler *admin.CustomerA
Register(accounts, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
Summary: "修改账号状态",
Tags: []string{"客户账号管理"},
Input: new(model.UpdateCustomerAccountStatusReq),
Input: new(dto.UpdateCustomerAccountStatusReq),
Output: nil,
Auth: true,
})

View File

@@ -4,7 +4,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -15,31 +15,31 @@ func registerEnterpriseRoutes(router fiber.Router, handler *admin.EnterpriseHand
Register(enterprises, doc, groupPath, "POST", "", handler.Create, RouteSpec{
Summary: "新增企业客户",
Tags: []string{"企业客户管理"},
Input: new(model.CreateEnterpriseReq),
Output: new(model.CreateEnterpriseResp),
Input: new(dto.CreateEnterpriseReq),
Output: new(dto.CreateEnterpriseResp),
Auth: true,
})
Register(enterprises, doc, groupPath, "GET", "", handler.List, RouteSpec{
Summary: "查询企业客户列表",
Tags: []string{"企业客户管理"},
Input: new(model.EnterpriseListReq),
Output: new(model.EnterprisePageResult),
Input: new(dto.EnterpriseListReq),
Output: new(dto.EnterprisePageResult),
Auth: true,
})
Register(enterprises, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
Summary: "编辑企业信息",
Tags: []string{"企业客户管理"},
Input: new(model.UpdateEnterpriseReq),
Output: new(model.EnterpriseItem),
Input: new(dto.UpdateEnterpriseReq),
Output: new(dto.EnterpriseItem),
Auth: true,
})
Register(enterprises, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
Summary: "启用/禁用企业",
Tags: []string{"企业客户管理"},
Input: new(model.UpdateEnterpriseStatusReq),
Input: new(dto.UpdateEnterpriseStatusReq),
Output: nil,
Auth: true,
})
@@ -47,7 +47,7 @@ func registerEnterpriseRoutes(router fiber.Router, handler *admin.EnterpriseHand
Register(enterprises, doc, groupPath, "PUT", "/:id/password", handler.UpdatePassword, RouteSpec{
Summary: "修改企业账号密码",
Tags: []string{"企业客户管理"},
Input: new(model.UpdateEnterprisePasswordReq),
Input: new(dto.UpdateEnterprisePasswordReq),
Output: nil,
Auth: true,
})

View File

@@ -4,7 +4,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -15,39 +15,39 @@ func registerEnterpriseCardRoutes(router fiber.Router, handler *admin.Enterprise
Register(enterprises, doc, groupPath, "POST", "/:id/allocate-cards/preview", handler.AllocateCardsPreview, RouteSpec{
Summary: "卡授权预检",
Tags: []string{"企业卡授权"},
Input: new(model.AllocateCardsPreviewReq),
Output: new(model.AllocateCardsPreviewResp),
Input: new(dto.AllocateCardsPreviewReq),
Output: new(dto.AllocateCardsPreviewResp),
Auth: true,
})
Register(enterprises, doc, groupPath, "POST", "/:id/allocate-cards", handler.AllocateCards, RouteSpec{
Summary: "授权卡给企业",
Tags: []string{"企业卡授权"},
Input: new(model.AllocateCardsReq),
Output: new(model.AllocateCardsResp),
Input: new(dto.AllocateCardsReq),
Output: new(dto.AllocateCardsResp),
Auth: true,
})
Register(enterprises, doc, groupPath, "POST", "/:id/recall-cards", handler.RecallCards, RouteSpec{
Summary: "回收卡授权",
Tags: []string{"企业卡授权"},
Input: new(model.RecallCardsReq),
Output: new(model.RecallCardsResp),
Input: new(dto.RecallCardsReq),
Output: new(dto.RecallCardsResp),
Auth: true,
})
Register(enterprises, doc, groupPath, "GET", "/:id/cards", handler.ListCards, RouteSpec{
Summary: "企业卡列表",
Tags: []string{"企业卡授权"},
Input: new(model.EnterpriseCardListReq),
Output: new(model.EnterpriseCardPageResult),
Input: new(dto.EnterpriseCardListReq),
Output: new(dto.EnterpriseCardPageResult),
Auth: true,
})
Register(enterprises, doc, groupPath, "POST", "/:id/cards/:card_id/suspend", handler.SuspendCard, RouteSpec{
Summary: "停机卡",
Tags: []string{"企业卡授权"},
Input: new(model.SuspendCardReq),
Input: new(dto.SuspendCardReq),
Output: nil,
Auth: true,
})
@@ -55,7 +55,7 @@ func registerEnterpriseCardRoutes(router fiber.Router, handler *admin.Enterprise
Register(enterprises, doc, groupPath, "POST", "/:id/cards/:card_id/resume", handler.ResumeCard, RouteSpec{
Summary: "复机卡",
Tags: []string{"企业卡授权"},
Input: new(model.ResumeCardReq),
Input: new(dto.ResumeCardReq),
Output: nil,
Auth: true,
})

View File

@@ -4,7 +4,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -27,16 +27,16 @@ func registerH5AuthRoutes(router fiber.Router, handler interface{}, authMiddlewa
Register(router, doc, basePath, "POST", "/login", h.Login, RouteSpec{
Summary: "H5 登录",
Tags: []string{"H5 认证"},
Input: new(model.LoginRequest),
Output: new(model.LoginResponse),
Input: new(dto.LoginRequest),
Output: new(dto.LoginResponse),
Auth: false,
})
Register(router, doc, basePath, "POST", "/refresh-token", h.RefreshToken, RouteSpec{
Summary: "刷新 Token",
Tags: []string{"H5 认证"},
Input: new(model.RefreshTokenRequest),
Output: new(model.RefreshTokenResponse),
Input: new(dto.RefreshTokenRequest),
Output: new(dto.RefreshTokenResponse),
Auth: false,
})
@@ -54,14 +54,14 @@ func registerH5AuthRoutes(router fiber.Router, handler interface{}, authMiddlewa
Summary: "获取当前用户信息",
Tags: []string{"H5 认证"},
Input: nil,
Output: new(model.UserInfo),
Output: new(dto.UserInfo),
Auth: true,
})
Register(authGroup, doc, basePath, "PUT", "/password", h.ChangePassword, RouteSpec{
Summary: "修改密码",
Tags: []string{"H5 认证"},
Input: new(model.ChangePasswordRequest),
Input: new(dto.ChangePasswordRequest),
Output: nil,
Auth: true,
})

View File

@@ -4,7 +4,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -16,31 +16,31 @@ func registerMyCommissionRoutes(router fiber.Router, handler *admin.MyCommission
Summary: "我的佣金概览",
Tags: []string{"我的佣金"},
Input: nil,
Output: new(model.MyCommissionSummaryResp),
Output: new(dto.MyCommissionSummaryResp),
Auth: true,
})
Register(my, doc, groupPath, "POST", "/withdrawal-requests", handler.CreateWithdrawal, RouteSpec{
Summary: "发起提现申请",
Tags: []string{"我的佣金"},
Input: new(model.CreateMyWithdrawalReq),
Output: new(model.CreateMyWithdrawalResp),
Input: new(dto.CreateMyWithdrawalReq),
Output: new(dto.CreateMyWithdrawalResp),
Auth: true,
})
Register(my, doc, groupPath, "GET", "/withdrawal-requests", handler.ListWithdrawals, RouteSpec{
Summary: "我的提现记录",
Tags: []string{"我的佣金"},
Input: new(model.MyWithdrawalListReq),
Output: new(model.WithdrawalRequestPageResult),
Input: new(dto.MyWithdrawalListReq),
Output: new(dto.WithdrawalRequestPageResult),
Auth: true,
})
Register(my, doc, groupPath, "GET", "/commission-records", handler.ListRecords, RouteSpec{
Summary: "我的佣金明细",
Tags: []string{"我的佣金"},
Input: new(model.MyCommissionRecordListReq),
Output: new(model.MyCommissionRecordPageResult),
Input: new(dto.MyCommissionRecordListReq),
Output: new(dto.MyCommissionRecordPageResult),
Auth: true,
})
}

View File

@@ -4,7 +4,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -17,16 +17,16 @@ func registerPermissionRoutes(api fiber.Router, h *admin.PermissionHandler, doc
Register(permissions, doc, groupPath, "POST", "", h.Create, RouteSpec{
Summary: "创建权限",
Tags: []string{"权限"},
Input: new(model.CreatePermissionRequest),
Output: new(model.PermissionResponse),
Input: new(dto.CreatePermissionRequest),
Output: new(dto.PermissionResponse),
Auth: true,
})
Register(permissions, doc, groupPath, "GET", "", h.List, RouteSpec{
Summary: "权限列表",
Tags: []string{"权限"},
Input: new(model.PermissionListRequest),
Output: new(model.PermissionPageResult),
Input: new(dto.PermissionListRequest),
Output: new(dto.PermissionPageResult),
Auth: true,
})
@@ -34,30 +34,30 @@ func registerPermissionRoutes(api fiber.Router, h *admin.PermissionHandler, doc
Summary: "获取权限树",
Tags: []string{"权限"},
Input: nil, // 无参数或 Query 参数
Output: new([]*model.PermissionTreeNode),
Output: new([]*dto.PermissionTreeNode),
Auth: true,
})
Register(permissions, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
Summary: "获取权限详情",
Tags: []string{"权限"},
Input: new(model.IDReq),
Output: new(model.PermissionResponse),
Input: new(dto.IDReq),
Output: new(dto.PermissionResponse),
Auth: true,
})
Register(permissions, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
Summary: "更新权限",
Tags: []string{"权限"},
Input: new(model.UpdatePermissionParams),
Output: new(model.PermissionResponse),
Input: new(dto.UpdatePermissionParams),
Output: new(dto.PermissionResponse),
Auth: true,
})
Register(permissions, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
Summary: "删除权限",
Tags: []string{"权限"},
Input: new(model.IDReq),
Input: new(dto.IDReq),
Output: nil,
Auth: true,
})

View File

@@ -5,6 +5,7 @@ import (
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -17,39 +18,39 @@ func registerRoleRoutes(api fiber.Router, h *admin.RoleHandler, doc *openapi.Gen
Register(roles, doc, groupPath, "POST", "", h.Create, RouteSpec{
Summary: "创建角色",
Tags: []string{"角色"},
Input: new(model.CreateRoleRequest),
Output: new(model.RoleResponse),
Input: new(dto.CreateRoleRequest),
Output: new(dto.RoleResponse),
Auth: true,
})
Register(roles, doc, groupPath, "GET", "", h.List, RouteSpec{
Summary: "角色列表",
Tags: []string{"角色"},
Input: new(model.RoleListRequest),
Output: new(model.RolePageResult),
Input: new(dto.RoleListRequest),
Output: new(dto.RolePageResult),
Auth: true,
})
Register(roles, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
Summary: "获取角色详情",
Tags: []string{"角色"},
Input: new(model.IDReq),
Output: new(model.RoleResponse),
Input: new(dto.IDReq),
Output: new(dto.RoleResponse),
Auth: true,
})
Register(roles, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
Summary: "更新角色",
Tags: []string{"角色"},
Input: new(model.UpdateRoleParams),
Output: new(model.RoleResponse),
Input: new(dto.UpdateRoleParams),
Output: new(dto.RoleResponse),
Auth: true,
})
Register(roles, doc, groupPath, "PUT", "/:id/status", h.UpdateStatus, RouteSpec{
Summary: "更新角色状态",
Tags: []string{"角色"},
Input: new(model.UpdateRoleStatusParams),
Input: new(dto.UpdateRoleStatusParams),
Output: nil,
Auth: true,
})
@@ -57,7 +58,7 @@ func registerRoleRoutes(api fiber.Router, h *admin.RoleHandler, doc *openapi.Gen
Register(roles, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
Summary: "删除角色",
Tags: []string{"角色"},
Input: new(model.IDReq),
Input: new(dto.IDReq),
Output: nil,
Auth: true,
})
@@ -66,7 +67,7 @@ func registerRoleRoutes(api fiber.Router, h *admin.RoleHandler, doc *openapi.Gen
Register(roles, doc, groupPath, "POST", "/:id/permissions", h.AssignPermissions, RouteSpec{
Summary: "分配权限",
Tags: []string{"角色"},
Input: new(model.AssignPermissionsParams),
Input: new(dto.AssignPermissionsParams),
Output: nil,
Auth: true,
})
@@ -74,7 +75,7 @@ func registerRoleRoutes(api fiber.Router, h *admin.RoleHandler, doc *openapi.Gen
Register(roles, doc, groupPath, "GET", "/:id/permissions", h.GetPermissions, RouteSpec{
Summary: "获取角色权限",
Tags: []string{"角色"},
Input: new(model.IDReq),
Input: new(dto.IDReq),
Output: new([]model.Permission),
Auth: true,
})
@@ -82,7 +83,7 @@ func registerRoleRoutes(api fiber.Router, h *admin.RoleHandler, doc *openapi.Gen
Register(roles, doc, groupPath, "DELETE", "/:role_id/permissions/:perm_id", h.RemovePermission, RouteSpec{
Summary: "移除权限",
Tags: []string{"角色"},
Input: new(model.RemovePermissionParams),
Input: new(dto.RemovePermissionParams),
Output: nil,
Auth: true,
})

View File

@@ -4,7 +4,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
@@ -15,31 +15,31 @@ func registerShopRoutes(router fiber.Router, handler *admin.ShopHandler, doc *op
Register(shops, doc, groupPath, "GET", "", handler.List, RouteSpec{
Summary: "店铺列表",
Tags: []string{"店铺管理"},
Input: new(model.ShopListRequest),
Output: new(model.ShopPageResult),
Input: new(dto.ShopListRequest),
Output: new(dto.ShopPageResult),
Auth: true,
})
Register(shops, doc, groupPath, "POST", "", handler.Create, RouteSpec{
Summary: "创建店铺",
Tags: []string{"店铺管理"},
Input: new(model.CreateShopRequest),
Output: new(model.ShopResponse),
Input: new(dto.CreateShopRequest),
Output: new(dto.ShopResponse),
Auth: true,
})
Register(shops, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
Summary: "更新店铺",
Tags: []string{"店铺管理"},
Input: new(model.UpdateShopParams),
Output: new(model.ShopResponse),
Input: new(dto.UpdateShopParams),
Output: new(dto.ShopResponse),
Auth: true,
})
Register(shops, doc, groupPath, "DELETE", "/:id", handler.Delete, RouteSpec{
Summary: "删除店铺",
Tags: []string{"店铺管理"},
Input: new(model.IDReq),
Input: new(dto.IDReq),
Output: nil,
Auth: true,
})
@@ -52,31 +52,31 @@ func registerShopAccountRoutes(router fiber.Router, handler *admin.ShopAccountHa
Register(shopAccounts, doc, groupPath, "GET", "", handler.List, RouteSpec{
Summary: "代理账号列表",
Tags: []string{"代理账号管理"},
Input: new(model.ShopAccountListRequest),
Output: new(model.ShopAccountPageResult),
Input: new(dto.ShopAccountListRequest),
Output: new(dto.ShopAccountPageResult),
Auth: true,
})
Register(shopAccounts, doc, groupPath, "POST", "", handler.Create, RouteSpec{
Summary: "创建代理账号",
Tags: []string{"代理账号管理"},
Input: new(model.CreateShopAccountRequest),
Output: new(model.ShopAccountResponse),
Input: new(dto.CreateShopAccountRequest),
Output: new(dto.ShopAccountResponse),
Auth: true,
})
Register(shopAccounts, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
Summary: "更新代理账号",
Tags: []string{"代理账号管理"},
Input: new(model.UpdateShopAccountParams),
Output: new(model.ShopAccountResponse),
Input: new(dto.UpdateShopAccountParams),
Output: new(dto.ShopAccountResponse),
Auth: true,
})
Register(shopAccounts, doc, groupPath, "PUT", "/:id/password", handler.UpdatePassword, RouteSpec{
Summary: "重置代理账号密码",
Tags: []string{"代理账号管理"},
Input: new(model.UpdateShopAccountPasswordParams),
Input: new(dto.UpdateShopAccountPasswordParams),
Output: nil,
Auth: true,
})
@@ -84,7 +84,7 @@ func registerShopAccountRoutes(router fiber.Router, handler *admin.ShopAccountHa
Register(shopAccounts, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
Summary: "启用/禁用代理账号",
Tags: []string{"代理账号管理"},
Input: new(model.UpdateShopAccountStatusParams),
Input: new(dto.UpdateShopAccountStatusParams),
Output: nil,
Auth: true,
})
@@ -97,24 +97,24 @@ func registerShopCommissionRoutes(router fiber.Router, handler *admin.ShopCommis
Register(shops, doc, groupPath, "GET", "/commission-summary", handler.ListCommissionSummary, RouteSpec{
Summary: "代理商佣金列表",
Tags: []string{"代理商佣金管理"},
Input: new(model.ShopCommissionSummaryListReq),
Output: new(model.ShopCommissionSummaryPageResult),
Input: new(dto.ShopCommissionSummaryListReq),
Output: new(dto.ShopCommissionSummaryPageResult),
Auth: true,
})
Register(shops, doc, groupPath, "GET", "/:shop_id/withdrawal-requests", handler.ListWithdrawalRequests, RouteSpec{
Summary: "代理商提现记录",
Tags: []string{"代理商佣金管理"},
Input: new(model.ShopWithdrawalRequestListReq),
Output: new(model.ShopWithdrawalRequestPageResult),
Input: new(dto.ShopWithdrawalRequestListReq),
Output: new(dto.ShopWithdrawalRequestPageResult),
Auth: true,
})
Register(shops, doc, groupPath, "GET", "/:shop_id/commission-records", handler.ListCommissionRecords, RouteSpec{
Summary: "代理商佣金明细",
Tags: []string{"代理商佣金管理"},
Input: new(model.ShopCommissionRecordListReq),
Output: new(model.ShopCommissionRecordPageResult),
Input: new(dto.ShopCommissionRecordListReq),
Output: new(dto.ShopCommissionRecordPageResult),
Auth: true,
})
}

View File

@@ -3,7 +3,7 @@ package routes
import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
"github.com/break/junhong_cmp_fiber/pkg/response"
)
@@ -26,7 +26,7 @@ func registerTaskRoutes(api fiber.Router, doc *openapi.Generator, basePath strin
}, RouteSpec{
Summary: "查询任务状态",
Tags: []string{"任务管理"},
Input: new(model.IDReq),
Input: new(dto.IDReq),
Output: new(TaskStatusResponse),
Auth: true,
})