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:
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
accountService "github.com/break/junhong_cmp_fiber/internal/service/account"
|
accountService "github.com/break/junhong_cmp_fiber/internal/service/account"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ func NewAccountHandler(service *accountService.Service) *AccountHandler {
|
|||||||
// Create 创建账号
|
// Create 创建账号
|
||||||
// POST /api/v1/accounts
|
// POST /api/v1/accounts
|
||||||
func (h *AccountHandler) Create(c *fiber.Ctx) error {
|
func (h *AccountHandler) Create(c *fiber.Ctx) error {
|
||||||
var req model.CreateAccountRequest
|
var req dto.CreateAccountRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ func (h *AccountHandler) Update(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateAccountRequest
|
var req dto.UpdateAccountRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ func (h *AccountHandler) Delete(c *fiber.Ctx) error {
|
|||||||
// List 查询账号列表
|
// List 查询账号列表
|
||||||
// GET /api/v1/accounts
|
// GET /api/v1/accounts
|
||||||
func (h *AccountHandler) List(c *fiber.Ctx) error {
|
func (h *AccountHandler) List(c *fiber.Ctx) error {
|
||||||
var req model.AccountListRequest
|
var req dto.AccountListRequest
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ func (h *AccountHandler) AssignRoles(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.AssignRolesRequest
|
var req dto.AssignRolesRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ func (h *AccountHandler) UpdatePassword(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdatePasswordRequest
|
var req dto.UpdatePasswordRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ func (h *AccountHandler) UpdateStatus(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateStatusRequest
|
var req dto.UpdateStatusRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -208,7 +208,7 @@ func (h *AccountHandler) UpdateStatus(c *fiber.Ctx) error {
|
|||||||
// ListPlatformAccounts 查询平台账号列表
|
// ListPlatformAccounts 查询平台账号列表
|
||||||
// GET /api/admin/platform-accounts
|
// GET /api/admin/platform-accounts
|
||||||
func (h *AccountHandler) ListPlatformAccounts(c *fiber.Ctx) error {
|
func (h *AccountHandler) ListPlatformAccounts(c *fiber.Ctx) error {
|
||||||
var req model.PlatformAccountListRequest
|
var req dto.PlatformAccountListRequest
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/auth"
|
"github.com/break/junhong_cmp_fiber/internal/service/auth"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/middleware"
|
"github.com/break/junhong_cmp_fiber/pkg/middleware"
|
||||||
@@ -26,7 +26,7 @@ func NewAuthHandler(authService *auth.Service, validator *validator.Validate) *A
|
|||||||
|
|
||||||
// Login 后台登录
|
// Login 后台登录
|
||||||
func (h *AuthHandler) Login(c *fiber.Ctx) error {
|
func (h *AuthHandler) Login(c *fiber.Ctx) error {
|
||||||
var req model.LoginRequest
|
var req dto.LoginRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ func (h *AuthHandler) Logout(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshToken := ""
|
refreshToken := ""
|
||||||
var req model.RefreshTokenRequest
|
var req dto.RefreshTokenRequest
|
||||||
if err := c.BodyParser(&req); err == nil {
|
if err := c.BodyParser(&req); err == nil {
|
||||||
refreshToken = req.RefreshToken
|
refreshToken = req.RefreshToken
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ func (h *AuthHandler) Logout(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// RefreshToken 刷新访问令牌
|
// RefreshToken 刷新访问令牌
|
||||||
func (h *AuthHandler) RefreshToken(c *fiber.Ctx) error {
|
func (h *AuthHandler) RefreshToken(c *fiber.Ctx) error {
|
||||||
var req model.RefreshTokenRequest
|
var req dto.RefreshTokenRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ func (h *AuthHandler) RefreshToken(c *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &model.RefreshTokenResponse{
|
resp := &dto.RefreshTokenResponse{
|
||||||
AccessToken: newAccessToken,
|
AccessToken: newAccessToken,
|
||||||
ExpiresIn: 86400,
|
ExpiresIn: 86400,
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ func (h *AuthHandler) ChangePassword(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeUnauthorized, "未授权访问")
|
return errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.ChangePasswordRequest
|
var req dto.ChangePasswordRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
commissionWithdrawalService "github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal"
|
commissionWithdrawalService "github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
@@ -20,7 +20,7 @@ func NewCommissionWithdrawalHandler(service *commissionWithdrawalService.Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *CommissionWithdrawalHandler) ListWithdrawalRequests(c *fiber.Ctx) error {
|
func (h *CommissionWithdrawalHandler) ListWithdrawalRequests(c *fiber.Ctx) error {
|
||||||
var req model.WithdrawalRequestListReq
|
var req dto.WithdrawalRequestListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ func (h *CommissionWithdrawalHandler) ApproveWithdrawal(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的提现申请ID")
|
return errors.New(errors.CodeInvalidParam, "无效的提现申请ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.ApproveWithdrawalReq
|
var req dto.ApproveWithdrawalReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ func (h *CommissionWithdrawalHandler) RejectWithdrawal(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的提现申请ID")
|
return errors.New(errors.CodeInvalidParam, "无效的提现申请ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.RejectWithdrawalReq
|
var req dto.RejectWithdrawalReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package admin
|
|||||||
import (
|
import (
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
commissionWithdrawalSettingService "github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal_setting"
|
commissionWithdrawalSettingService "github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal_setting"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
@@ -18,7 +18,7 @@ func NewCommissionWithdrawalSettingHandler(service *commissionWithdrawalSettingS
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *CommissionWithdrawalSettingHandler) Create(c *fiber.Ctx) error {
|
func (h *CommissionWithdrawalSettingHandler) Create(c *fiber.Ctx) error {
|
||||||
var req model.CreateWithdrawalSettingReq
|
var req dto.CreateWithdrawalSettingReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ func (h *CommissionWithdrawalSettingHandler) Create(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *CommissionWithdrawalSettingHandler) List(c *fiber.Ctx) error {
|
func (h *CommissionWithdrawalSettingHandler) List(c *fiber.Ctx) error {
|
||||||
var req model.WithdrawalSettingListReq
|
var req dto.WithdrawalSettingListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
customerAccountService "github.com/break/junhong_cmp_fiber/internal/service/customer_account"
|
customerAccountService "github.com/break/junhong_cmp_fiber/internal/service/customer_account"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
@@ -20,7 +20,7 @@ func NewCustomerAccountHandler(service *customerAccountService.Service) *Custome
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *CustomerAccountHandler) List(c *fiber.Ctx) error {
|
func (h *CustomerAccountHandler) List(c *fiber.Ctx) error {
|
||||||
var req model.CustomerAccountListReq
|
var req dto.CustomerAccountListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ func (h *CustomerAccountHandler) List(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *CustomerAccountHandler) Create(c *fiber.Ctx) error {
|
func (h *CustomerAccountHandler) Create(c *fiber.Ctx) error {
|
||||||
var req model.CreateCustomerAccountReq
|
var req dto.CreateCustomerAccountReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ func (h *CustomerAccountHandler) Update(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateCustomerAccountRequest
|
var req dto.UpdateCustomerAccountRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ func (h *CustomerAccountHandler) UpdatePassword(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateCustomerAccountPasswordRequest
|
var req dto.UpdateCustomerAccountPasswordRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ func (h *CustomerAccountHandler) UpdateStatus(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateCustomerAccountStatusRequest
|
var req dto.UpdateCustomerAccountStatusRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
enterpriseService "github.com/break/junhong_cmp_fiber/internal/service/enterprise"
|
enterpriseService "github.com/break/junhong_cmp_fiber/internal/service/enterprise"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
@@ -20,7 +20,7 @@ func NewEnterpriseHandler(service *enterpriseService.Service) *EnterpriseHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *EnterpriseHandler) Create(c *fiber.Ctx) error {
|
func (h *EnterpriseHandler) Create(c *fiber.Ctx) error {
|
||||||
var req model.CreateEnterpriseReq
|
var req dto.CreateEnterpriseReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ func (h *EnterpriseHandler) Create(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *EnterpriseHandler) List(c *fiber.Ctx) error {
|
func (h *EnterpriseHandler) List(c *fiber.Ctx) error {
|
||||||
var req model.EnterpriseListReq
|
var req dto.EnterpriseListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ func (h *EnterpriseHandler) Update(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateEnterpriseBody
|
var req dto.UpdateEnterpriseBody
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ func (h *EnterpriseHandler) UpdateStatus(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateEnterpriseStatusBody
|
var req dto.UpdateEnterpriseStatusBody
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ func (h *EnterpriseHandler) UpdatePassword(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateEnterprisePasswordBody
|
var req dto.UpdateEnterprisePasswordBody
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
enterpriseCardService "github.com/break/junhong_cmp_fiber/internal/service/enterprise_card"
|
enterpriseCardService "github.com/break/junhong_cmp_fiber/internal/service/enterprise_card"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
@@ -26,7 +26,7 @@ func (h *EnterpriseCardHandler) AllocateCardsPreview(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.AllocateCardsPreviewReq
|
var req dto.AllocateCardsPreviewReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ func (h *EnterpriseCardHandler) AllocateCards(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.AllocateCardsReq
|
var req dto.AllocateCardsReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ func (h *EnterpriseCardHandler) RecallCards(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.RecallCardsReq
|
var req dto.RecallCardsReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ func (h *EnterpriseCardHandler) ListCards(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
return errors.New(errors.CodeInvalidParam, "无效的企业ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.EnterpriseCardListReq
|
var req dto.EnterpriseCardListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package admin
|
|||||||
import (
|
import (
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
myCommissionService "github.com/break/junhong_cmp_fiber/internal/service/my_commission"
|
myCommissionService "github.com/break/junhong_cmp_fiber/internal/service/my_commission"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
@@ -27,7 +27,7 @@ func (h *MyCommissionHandler) GetSummary(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *MyCommissionHandler) CreateWithdrawal(c *fiber.Ctx) error {
|
func (h *MyCommissionHandler) CreateWithdrawal(c *fiber.Ctx) error {
|
||||||
var req model.CreateMyWithdrawalReq
|
var req dto.CreateMyWithdrawalReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ func (h *MyCommissionHandler) CreateWithdrawal(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *MyCommissionHandler) ListWithdrawals(c *fiber.Ctx) error {
|
func (h *MyCommissionHandler) ListWithdrawals(c *fiber.Ctx) error {
|
||||||
var req model.MyWithdrawalListReq
|
var req dto.MyWithdrawalListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ func (h *MyCommissionHandler) ListWithdrawals(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *MyCommissionHandler) ListRecords(c *fiber.Ctx) error {
|
func (h *MyCommissionHandler) ListRecords(c *fiber.Ctx) error {
|
||||||
var req model.MyCommissionRecordListReq
|
var req dto.MyCommissionRecordListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package admin
|
|||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
@@ -25,7 +25,7 @@ func NewPermissionHandler(service *permissionService.Service) *PermissionHandler
|
|||||||
// Create 创建权限
|
// Create 创建权限
|
||||||
// POST /api/v1/permissions
|
// POST /api/v1/permissions
|
||||||
func (h *PermissionHandler) Create(c *fiber.Ctx) error {
|
func (h *PermissionHandler) Create(c *fiber.Ctx) error {
|
||||||
var req model.CreatePermissionRequest
|
var req dto.CreatePermissionRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ func (h *PermissionHandler) Update(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的权限 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的权限 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdatePermissionRequest
|
var req dto.UpdatePermissionRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ func (h *PermissionHandler) Delete(c *fiber.Ctx) error {
|
|||||||
// List 查询权限列表
|
// List 查询权限列表
|
||||||
// GET /api/v1/permissions
|
// GET /api/v1/permissions
|
||||||
func (h *PermissionHandler) List(c *fiber.Ctx) error {
|
func (h *PermissionHandler) List(c *fiber.Ctx) error {
|
||||||
var req model.PermissionListRequest
|
var req dto.PermissionListRequest
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
roleService "github.com/break/junhong_cmp_fiber/internal/service/role"
|
roleService "github.com/break/junhong_cmp_fiber/internal/service/role"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ func NewRoleHandler(service *roleService.Service) *RoleHandler {
|
|||||||
// Create 创建角色
|
// Create 创建角色
|
||||||
// POST /api/v1/roles
|
// POST /api/v1/roles
|
||||||
func (h *RoleHandler) Create(c *fiber.Ctx) error {
|
func (h *RoleHandler) Create(c *fiber.Ctx) error {
|
||||||
var req model.CreateRoleRequest
|
var req dto.CreateRoleRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ func (h *RoleHandler) Update(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的角色 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的角色 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateRoleRequest
|
var req dto.UpdateRoleRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ func (h *RoleHandler) Delete(c *fiber.Ctx) error {
|
|||||||
// List 查询角色列表
|
// List 查询角色列表
|
||||||
// GET /api/v1/roles
|
// GET /api/v1/roles
|
||||||
func (h *RoleHandler) List(c *fiber.Ctx) error {
|
func (h *RoleHandler) List(c *fiber.Ctx) error {
|
||||||
var req model.RoleListRequest
|
var req dto.RoleListRequest
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ func (h *RoleHandler) AssignPermissions(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的角色 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的角色 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.AssignPermissionsRequest
|
var req dto.AssignPermissionsRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ func (h *RoleHandler) UpdateStatus(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的角色 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的角色 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateRoleStatusRequest
|
var req dto.UpdateRoleStatusRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
shopService "github.com/break/junhong_cmp_fiber/internal/service/shop"
|
shopService "github.com/break/junhong_cmp_fiber/internal/service/shop"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
@@ -20,7 +20,7 @@ func NewShopHandler(service *shopService.Service) *ShopHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *ShopHandler) List(c *fiber.Ctx) error {
|
func (h *ShopHandler) List(c *fiber.Ctx) error {
|
||||||
var req model.ShopListRequest
|
var req dto.ShopListRequest
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ func (h *ShopHandler) List(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *ShopHandler) Create(c *fiber.Ctx) error {
|
func (h *ShopHandler) Create(c *fiber.Ctx) error {
|
||||||
var req model.CreateShopRequest
|
var req dto.CreateShopRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ func (h *ShopHandler) Update(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的店铺 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的店铺 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateShopRequest
|
var req dto.UpdateShopRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
shopAccountService "github.com/break/junhong_cmp_fiber/internal/service/shop_account"
|
shopAccountService "github.com/break/junhong_cmp_fiber/internal/service/shop_account"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
@@ -20,7 +20,7 @@ func NewShopAccountHandler(service *shopAccountService.Service) *ShopAccountHand
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *ShopAccountHandler) List(c *fiber.Ctx) error {
|
func (h *ShopAccountHandler) List(c *fiber.Ctx) error {
|
||||||
var req model.ShopAccountListRequest
|
var req dto.ShopAccountListRequest
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ func (h *ShopAccountHandler) List(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *ShopAccountHandler) Create(c *fiber.Ctx) error {
|
func (h *ShopAccountHandler) Create(c *fiber.Ctx) error {
|
||||||
var req model.CreateShopAccountRequest
|
var req dto.CreateShopAccountRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ func (h *ShopAccountHandler) Update(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateShopAccountRequest
|
var req dto.UpdateShopAccountRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ func (h *ShopAccountHandler) UpdatePassword(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateShopAccountPasswordRequest
|
var req dto.UpdateShopAccountPasswordRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ func (h *ShopAccountHandler) UpdateStatus(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的账号 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.UpdateShopAccountStatusRequest
|
var req dto.UpdateShopAccountStatusRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
shopCommissionService "github.com/break/junhong_cmp_fiber/internal/service/shop_commission"
|
shopCommissionService "github.com/break/junhong_cmp_fiber/internal/service/shop_commission"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
@@ -20,7 +20,7 @@ func NewShopCommissionHandler(service *shopCommissionService.Service) *ShopCommi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *ShopCommissionHandler) ListCommissionSummary(c *fiber.Ctx) error {
|
func (h *ShopCommissionHandler) ListCommissionSummary(c *fiber.Ctx) error {
|
||||||
var req model.ShopCommissionSummaryListReq
|
var req dto.ShopCommissionSummaryListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ func (h *ShopCommissionHandler) ListWithdrawalRequests(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的店铺 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的店铺 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.ShopWithdrawalRequestListReq
|
var req dto.ShopWithdrawalRequestListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ func (h *ShopCommissionHandler) ListCommissionRecords(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeInvalidParam, "无效的店铺 ID")
|
return errors.New(errors.CodeInvalidParam, "无效的店铺 ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.ShopCommissionRecordListReq
|
var req dto.ShopCommissionRecordListReq
|
||||||
if err := c.QueryParser(&req); err != nil {
|
if err := c.QueryParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package h5
|
package h5
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/auth"
|
"github.com/break/junhong_cmp_fiber/internal/service/auth"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/middleware"
|
"github.com/break/junhong_cmp_fiber/pkg/middleware"
|
||||||
@@ -26,7 +26,7 @@ func NewAuthHandler(authService *auth.Service, validator *validator.Validate) *A
|
|||||||
|
|
||||||
// Login H5登录
|
// Login H5登录
|
||||||
func (h *AuthHandler) Login(c *fiber.Ctx) error {
|
func (h *AuthHandler) Login(c *fiber.Ctx) error {
|
||||||
var req model.LoginRequest
|
var req dto.LoginRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ func (h *AuthHandler) Logout(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshToken := ""
|
refreshToken := ""
|
||||||
var req model.RefreshTokenRequest
|
var req dto.RefreshTokenRequest
|
||||||
if err := c.BodyParser(&req); err == nil {
|
if err := c.BodyParser(&req); err == nil {
|
||||||
refreshToken = req.RefreshToken
|
refreshToken = req.RefreshToken
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ func (h *AuthHandler) Logout(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
// RefreshToken 刷新访问令牌
|
// RefreshToken 刷新访问令牌
|
||||||
func (h *AuthHandler) RefreshToken(c *fiber.Ctx) error {
|
func (h *AuthHandler) RefreshToken(c *fiber.Ctx) error {
|
||||||
var req model.RefreshTokenRequest
|
var req dto.RefreshTokenRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ func (h *AuthHandler) RefreshToken(c *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &model.RefreshTokenResponse{
|
resp := &dto.RefreshTokenResponse{
|
||||||
AccessToken: newAccessToken,
|
AccessToken: newAccessToken,
|
||||||
ExpiresIn: 86400,
|
ExpiresIn: 86400,
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ func (h *AuthHandler) ChangePassword(c *fiber.Ctx) error {
|
|||||||
return errors.New(errors.CodeUnauthorized, "未授权访问")
|
return errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
}
|
}
|
||||||
|
|
||||||
var req model.ChangePasswordRequest
|
var req dto.ChangePasswordRequest
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
return errors.New(errors.CodeInvalidParam, "请求参数解析失败")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// CreateAccountRequest 创建账号请求
|
// CreateAccountRequest 创建账号请求
|
||||||
type CreateAccountRequest struct {
|
type CreateAccountRequest struct {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// AccountRoleResponse 账号-角色关联响应
|
// AccountRoleResponse 账号-角色关联响应
|
||||||
type AccountRoleResponse struct {
|
type AccountRoleResponse struct {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
type LoginRequest struct {
|
type LoginRequest struct {
|
||||||
Username string `json:"username" validate:"required"`
|
Username string `json:"username" validate:"required"`
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// WithdrawalRequestListReq 提现申请列表查询请求
|
// WithdrawalRequestListReq 提现申请列表查询请求
|
||||||
type WithdrawalRequestListReq struct {
|
type WithdrawalRequestListReq struct {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
type CreateWithdrawalSettingReq struct {
|
type CreateWithdrawalSettingReq struct {
|
||||||
DailyWithdrawalLimit int `json:"daily_withdrawal_limit" validate:"required,min=1,max=100" required:"true" minimum:"1" maximum:"100" description:"每日提现次数限制"`
|
DailyWithdrawalLimit int `json:"daily_withdrawal_limit" validate:"required,min=1,max=100" required:"true" minimum:"1" maximum:"100" description:"每日提现次数限制"`
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// IDReq 通用 ID 路径参数请求
|
// IDReq 通用 ID 路径参数请求
|
||||||
type IDReq struct {
|
type IDReq struct {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
type CustomerAccountListReq struct {
|
type CustomerAccountListReq struct {
|
||||||
Page int `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"`
|
Page int `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"`
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
type AllocateCardsPreviewReq struct {
|
type AllocateCardsPreviewReq struct {
|
||||||
ID uint `json:"-" params:"id" path:"id" validate:"required" required:"true" description:"企业ID"`
|
ID uint `json:"-" params:"id" path:"id" validate:"required" required:"true" description:"企业ID"`
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
type CreateEnterpriseReq struct {
|
type CreateEnterpriseReq struct {
|
||||||
EnterpriseName string `json:"enterprise_name" validate:"required,max=100" required:"true" maximum:"100" description:"企业名称"`
|
EnterpriseName string `json:"enterprise_name" validate:"required,max=100" required:"true" maximum:"100" description:"企业名称"`
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
type MyCommissionSummaryResp struct {
|
type MyCommissionSummaryResp struct {
|
||||||
ShopID uint `json:"shop_id" description:"店铺ID"`
|
ShopID uint `json:"shop_id" description:"店铺ID"`
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// CreatePermissionRequest 创建权限请求
|
// CreatePermissionRequest 创建权限请求
|
||||||
type CreatePermissionRequest struct {
|
type CreatePermissionRequest struct {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// CreatePersonalCustomerRequest 创建个人客户请求
|
// CreatePersonalCustomerRequest 创建个人客户请求
|
||||||
type CreatePersonalCustomerRequest struct {
|
type CreatePersonalCustomerRequest struct {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// CreateRoleRequest 创建角色请求
|
// CreateRoleRequest 创建角色请求
|
||||||
type CreateRoleRequest struct {
|
type CreateRoleRequest struct {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// RolePermissionResponse 角色-权限关联响应
|
// RolePermissionResponse 角色-权限关联响应
|
||||||
type RolePermissionResponse struct {
|
type RolePermissionResponse struct {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// ShopAccountListRequest 代理商账号列表查询请求
|
// ShopAccountListRequest 代理商账号列表查询请求
|
||||||
type ShopAccountListRequest struct {
|
type ShopAccountListRequest struct {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
// 代理商佣金查询 DTO
|
// 代理商佣金查询 DTO
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package model
|
package dto
|
||||||
|
|
||||||
type ShopListRequest struct {
|
type ShopListRequest struct {
|
||||||
Page int `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"`
|
Page int `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"`
|
||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
"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{
|
Register(accounts, doc, groupPath, "POST", "", h.Create, RouteSpec{
|
||||||
Summary: "创建账号",
|
Summary: "创建账号",
|
||||||
Tags: []string{"账号相关"},
|
Tags: []string{"账号相关"},
|
||||||
Input: new(model.CreateAccountRequest),
|
Input: new(dto.CreateAccountRequest),
|
||||||
Output: new(model.AccountResponse),
|
Output: new(dto.AccountResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(accounts, doc, groupPath, "GET", "", h.List, RouteSpec{
|
Register(accounts, doc, groupPath, "GET", "", h.List, RouteSpec{
|
||||||
Summary: "账号列表",
|
Summary: "账号列表",
|
||||||
Tags: []string{"账号相关"},
|
Tags: []string{"账号相关"},
|
||||||
Input: new(model.AccountListRequest),
|
Input: new(dto.AccountListRequest),
|
||||||
Output: new(model.AccountPageResult),
|
Output: new(dto.AccountPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(accounts, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
Register(accounts, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
||||||
Summary: "获取账号详情",
|
Summary: "获取账号详情",
|
||||||
Tags: []string{"账号相关"},
|
Tags: []string{"账号相关"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: new(model.AccountResponse),
|
Output: new(dto.AccountResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(accounts, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
Register(accounts, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
||||||
Summary: "更新账号",
|
Summary: "更新账号",
|
||||||
Tags: []string{"账号相关"},
|
Tags: []string{"账号相关"},
|
||||||
Input: new(model.UpdateAccountParams),
|
Input: new(dto.UpdateAccountParams),
|
||||||
Output: new(model.AccountResponse),
|
Output: new(dto.AccountResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(accounts, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
Register(accounts, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
||||||
Summary: "删除账号",
|
Summary: "删除账号",
|
||||||
Tags: []string{"账号相关"},
|
Tags: []string{"账号相关"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
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{
|
Register(accounts, doc, groupPath, "POST", "/:id/roles", h.AssignRoles, RouteSpec{
|
||||||
Summary: "分配角色",
|
Summary: "分配角色",
|
||||||
Tags: []string{"账号相关"},
|
Tags: []string{"账号相关"},
|
||||||
Input: new(model.AssignRolesParams),
|
Input: new(dto.AssignRolesParams),
|
||||||
Output: nil, // TODO: Define AccountRole response DTO
|
Output: nil, // TODO: Define AccountRole response DTO
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(accounts, doc, groupPath, "GET", "/:id/roles", h.GetRoles, RouteSpec{
|
Register(accounts, doc, groupPath, "GET", "/:id/roles", h.GetRoles, RouteSpec{
|
||||||
Summary: "获取账号角色",
|
Summary: "获取账号角色",
|
||||||
Tags: []string{"账号相关"},
|
Tags: []string{"账号相关"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: new([]model.Role),
|
Output: new([]model.Role),
|
||||||
Auth: true,
|
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{
|
Register(accounts, doc, groupPath, "DELETE", "/:account_id/roles/:role_id", h.RemoveRole, RouteSpec{
|
||||||
Summary: "移除角色",
|
Summary: "移除角色",
|
||||||
Tags: []string{"账号相关"},
|
Tags: []string{"账号相关"},
|
||||||
Input: new(model.RemoveRoleParams),
|
Input: new(dto.RemoveRoleParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
@@ -88,39 +89,39 @@ func registerPlatformAccountRoutes(api fiber.Router, h *admin.AccountHandler, do
|
|||||||
Register(platformAccounts, doc, groupPath, "GET", "", h.ListPlatformAccounts, RouteSpec{
|
Register(platformAccounts, doc, groupPath, "GET", "", h.ListPlatformAccounts, RouteSpec{
|
||||||
Summary: "平台账号列表",
|
Summary: "平台账号列表",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.PlatformAccountListRequest),
|
Input: new(dto.PlatformAccountListRequest),
|
||||||
Output: new(model.AccountPageResult),
|
Output: new(dto.AccountPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(platformAccounts, doc, groupPath, "POST", "", h.Create, RouteSpec{
|
Register(platformAccounts, doc, groupPath, "POST", "", h.Create, RouteSpec{
|
||||||
Summary: "新增平台账号",
|
Summary: "新增平台账号",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.CreateAccountRequest),
|
Input: new(dto.CreateAccountRequest),
|
||||||
Output: new(model.AccountResponse),
|
Output: new(dto.AccountResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(platformAccounts, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
Register(platformAccounts, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
||||||
Summary: "获取平台账号详情",
|
Summary: "获取平台账号详情",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: new(model.AccountResponse),
|
Output: new(dto.AccountResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(platformAccounts, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
Register(platformAccounts, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
||||||
Summary: "编辑平台账号",
|
Summary: "编辑平台账号",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.UpdateAccountParams),
|
Input: new(dto.UpdateAccountParams),
|
||||||
Output: new(model.AccountResponse),
|
Output: new(dto.AccountResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(platformAccounts, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
Register(platformAccounts, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
||||||
Summary: "删除平台账号",
|
Summary: "删除平台账号",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
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{
|
Register(platformAccounts, doc, groupPath, "PUT", "/:id/password", h.UpdatePassword, RouteSpec{
|
||||||
Summary: "修改密码",
|
Summary: "修改密码",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.UpdatePasswordParams),
|
Input: new(dto.UpdatePasswordParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
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{
|
Register(platformAccounts, doc, groupPath, "PUT", "/:id/status", h.UpdateStatus, RouteSpec{
|
||||||
Summary: "启用/禁用账号",
|
Summary: "启用/禁用账号",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.UpdateStatusParams),
|
Input: new(dto.UpdateStatusParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
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{
|
Register(platformAccounts, doc, groupPath, "POST", "/:id/roles", h.AssignRoles, RouteSpec{
|
||||||
Summary: "分配角色",
|
Summary: "分配角色",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.AssignRolesParams),
|
Input: new(dto.AssignRolesParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
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{
|
Register(platformAccounts, doc, groupPath, "GET", "/:id/roles", h.GetRoles, RouteSpec{
|
||||||
Summary: "获取账号角色",
|
Summary: "获取账号角色",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: new([]model.Role),
|
Output: new([]model.Role),
|
||||||
Auth: true,
|
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{
|
Register(platformAccounts, doc, groupPath, "DELETE", "/:account_id/roles/:role_id", h.RemoveRole, RouteSpec{
|
||||||
Summary: "移除角色",
|
Summary: "移除角色",
|
||||||
Tags: []string{"平台账号"},
|
Tags: []string{"平台账号"},
|
||||||
Input: new(model.RemoveRoleParams),
|
Input: new(dto.RemoveRoleParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
"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"
|
"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{
|
Register(router, doc, basePath, "POST", "/login", h.Login, RouteSpec{
|
||||||
Summary: "后台登录",
|
Summary: "后台登录",
|
||||||
Tags: []string{"认证"},
|
Tags: []string{"认证"},
|
||||||
Input: new(model.LoginRequest),
|
Input: new(dto.LoginRequest),
|
||||||
Output: new(model.LoginResponse),
|
Output: new(dto.LoginResponse),
|
||||||
Auth: false,
|
Auth: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(router, doc, basePath, "POST", "/refresh-token", h.RefreshToken, RouteSpec{
|
Register(router, doc, basePath, "POST", "/refresh-token", h.RefreshToken, RouteSpec{
|
||||||
Summary: "刷新 Token",
|
Summary: "刷新 Token",
|
||||||
Tags: []string{"认证"},
|
Tags: []string{"认证"},
|
||||||
Input: new(model.RefreshTokenRequest),
|
Input: new(dto.RefreshTokenRequest),
|
||||||
Output: new(model.RefreshTokenResponse),
|
Output: new(dto.RefreshTokenResponse),
|
||||||
Auth: false,
|
Auth: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -93,14 +93,14 @@ func registerAdminAuthRoutes(router fiber.Router, handler interface{}, authMiddl
|
|||||||
Summary: "获取当前用户信息",
|
Summary: "获取当前用户信息",
|
||||||
Tags: []string{"认证"},
|
Tags: []string{"认证"},
|
||||||
Input: nil,
|
Input: nil,
|
||||||
Output: new(model.UserInfo),
|
Output: new(dto.UserInfo),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(authGroup, doc, basePath, "PUT", "/password", h.ChangePassword, RouteSpec{
|
Register(authGroup, doc, basePath, "PUT", "/password", h.ChangePassword, RouteSpec{
|
||||||
Summary: "修改密码",
|
Summary: "修改密码",
|
||||||
Tags: []string{"认证"},
|
Tags: []string{"认证"},
|
||||||
Input: new(model.ChangePasswordRequest),
|
Input: new(dto.ChangePasswordRequest),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
"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{
|
Register(commission, doc, groupPath, "GET", "/withdrawal-requests", handler.ListWithdrawalRequests, RouteSpec{
|
||||||
Summary: "提现申请列表",
|
Summary: "提现申请列表",
|
||||||
Tags: []string{"佣金提现审批"},
|
Tags: []string{"佣金提现审批"},
|
||||||
Input: new(model.WithdrawalRequestListReq),
|
Input: new(dto.WithdrawalRequestListReq),
|
||||||
Output: new(model.WithdrawalRequestPageResult),
|
Output: new(dto.WithdrawalRequestPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(commission, doc, groupPath, "POST", "/withdrawal-requests/:id/approve", handler.ApproveWithdrawal, RouteSpec{
|
Register(commission, doc, groupPath, "POST", "/withdrawal-requests/:id/approve", handler.ApproveWithdrawal, RouteSpec{
|
||||||
Summary: "审批通过提现申请",
|
Summary: "审批通过提现申请",
|
||||||
Tags: []string{"佣金提现审批"},
|
Tags: []string{"佣金提现审批"},
|
||||||
Input: new(model.ApproveWithdrawalReq),
|
Input: new(dto.ApproveWithdrawalReq),
|
||||||
Output: new(model.WithdrawalApprovalResp),
|
Output: new(dto.WithdrawalApprovalResp),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(commission, doc, groupPath, "POST", "/withdrawal-requests/:id/reject", handler.RejectWithdrawal, RouteSpec{
|
Register(commission, doc, groupPath, "POST", "/withdrawal-requests/:id/reject", handler.RejectWithdrawal, RouteSpec{
|
||||||
Summary: "拒绝提现申请",
|
Summary: "拒绝提现申请",
|
||||||
Tags: []string{"佣金提现审批"},
|
Tags: []string{"佣金提现审批"},
|
||||||
Input: new(model.RejectWithdrawalReq),
|
Input: new(dto.RejectWithdrawalReq),
|
||||||
Output: new(model.WithdrawalApprovalResp),
|
Output: new(dto.WithdrawalApprovalResp),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -45,16 +45,16 @@ func registerCommissionWithdrawalSettingRoutes(router fiber.Router, handler *adm
|
|||||||
Register(commission, doc, groupPath, "POST", "/withdrawal-settings", handler.Create, RouteSpec{
|
Register(commission, doc, groupPath, "POST", "/withdrawal-settings", handler.Create, RouteSpec{
|
||||||
Summary: "新增提现配置",
|
Summary: "新增提现配置",
|
||||||
Tags: []string{"提现配置管理"},
|
Tags: []string{"提现配置管理"},
|
||||||
Input: new(model.CreateWithdrawalSettingReq),
|
Input: new(dto.CreateWithdrawalSettingReq),
|
||||||
Output: new(model.WithdrawalSettingItem),
|
Output: new(dto.WithdrawalSettingItem),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(commission, doc, groupPath, "GET", "/withdrawal-settings", handler.List, RouteSpec{
|
Register(commission, doc, groupPath, "GET", "/withdrawal-settings", handler.List, RouteSpec{
|
||||||
Summary: "提现配置列表",
|
Summary: "提现配置列表",
|
||||||
Tags: []string{"提现配置管理"},
|
Tags: []string{"提现配置管理"},
|
||||||
Input: new(model.WithdrawalSettingListReq),
|
Input: new(dto.WithdrawalSettingListReq),
|
||||||
Output: new(model.WithdrawalSettingPageResult),
|
Output: new(dto.WithdrawalSettingPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ func registerCommissionWithdrawalSettingRoutes(router fiber.Router, handler *adm
|
|||||||
Summary: "获取当前生效的提现配置",
|
Summary: "获取当前生效的提现配置",
|
||||||
Tags: []string{"提现配置管理"},
|
Tags: []string{"提现配置管理"},
|
||||||
Input: nil,
|
Input: nil,
|
||||||
Output: new(model.WithdrawalSettingItem),
|
Output: new(dto.WithdrawalSettingItem),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
"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{
|
Register(accounts, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
||||||
Summary: "客户账号列表",
|
Summary: "客户账号列表",
|
||||||
Tags: []string{"客户账号管理"},
|
Tags: []string{"客户账号管理"},
|
||||||
Input: new(model.CustomerAccountListReq),
|
Input: new(dto.CustomerAccountListReq),
|
||||||
Output: new(model.CustomerAccountPageResult),
|
Output: new(dto.CustomerAccountPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(accounts, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
Register(accounts, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
||||||
Summary: "新增代理商账号",
|
Summary: "新增代理商账号",
|
||||||
Tags: []string{"客户账号管理"},
|
Tags: []string{"客户账号管理"},
|
||||||
Input: new(model.CreateCustomerAccountReq),
|
Input: new(dto.CreateCustomerAccountReq),
|
||||||
Output: new(model.CustomerAccountItem),
|
Output: new(dto.CustomerAccountItem),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(accounts, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
Register(accounts, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
||||||
Summary: "编辑账号",
|
Summary: "编辑账号",
|
||||||
Tags: []string{"客户账号管理"},
|
Tags: []string{"客户账号管理"},
|
||||||
Input: new(model.UpdateCustomerAccountReq),
|
Input: new(dto.UpdateCustomerAccountReq),
|
||||||
Output: new(model.CustomerAccountItem),
|
Output: new(dto.CustomerAccountItem),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(accounts, doc, groupPath, "PUT", "/:id/password", handler.UpdatePassword, RouteSpec{
|
Register(accounts, doc, groupPath, "PUT", "/:id/password", handler.UpdatePassword, RouteSpec{
|
||||||
Summary: "修改账号密码",
|
Summary: "修改账号密码",
|
||||||
Tags: []string{"客户账号管理"},
|
Tags: []string{"客户账号管理"},
|
||||||
Input: new(model.UpdateCustomerAccountPasswordReq),
|
Input: new(dto.UpdateCustomerAccountPasswordReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
@@ -47,7 +47,7 @@ func registerCustomerAccountRoutes(router fiber.Router, handler *admin.CustomerA
|
|||||||
Register(accounts, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
|
Register(accounts, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
|
||||||
Summary: "修改账号状态",
|
Summary: "修改账号状态",
|
||||||
Tags: []string{"客户账号管理"},
|
Tags: []string{"客户账号管理"},
|
||||||
Input: new(model.UpdateCustomerAccountStatusReq),
|
Input: new(dto.UpdateCustomerAccountStatusReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
"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{
|
Register(enterprises, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
||||||
Summary: "新增企业客户",
|
Summary: "新增企业客户",
|
||||||
Tags: []string{"企业客户管理"},
|
Tags: []string{"企业客户管理"},
|
||||||
Input: new(model.CreateEnterpriseReq),
|
Input: new(dto.CreateEnterpriseReq),
|
||||||
Output: new(model.CreateEnterpriseResp),
|
Output: new(dto.CreateEnterpriseResp),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(enterprises, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
Register(enterprises, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
||||||
Summary: "查询企业客户列表",
|
Summary: "查询企业客户列表",
|
||||||
Tags: []string{"企业客户管理"},
|
Tags: []string{"企业客户管理"},
|
||||||
Input: new(model.EnterpriseListReq),
|
Input: new(dto.EnterpriseListReq),
|
||||||
Output: new(model.EnterprisePageResult),
|
Output: new(dto.EnterprisePageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(enterprises, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
Register(enterprises, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
||||||
Summary: "编辑企业信息",
|
Summary: "编辑企业信息",
|
||||||
Tags: []string{"企业客户管理"},
|
Tags: []string{"企业客户管理"},
|
||||||
Input: new(model.UpdateEnterpriseReq),
|
Input: new(dto.UpdateEnterpriseReq),
|
||||||
Output: new(model.EnterpriseItem),
|
Output: new(dto.EnterpriseItem),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(enterprises, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
|
Register(enterprises, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
|
||||||
Summary: "启用/禁用企业",
|
Summary: "启用/禁用企业",
|
||||||
Tags: []string{"企业客户管理"},
|
Tags: []string{"企业客户管理"},
|
||||||
Input: new(model.UpdateEnterpriseStatusReq),
|
Input: new(dto.UpdateEnterpriseStatusReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
@@ -47,7 +47,7 @@ func registerEnterpriseRoutes(router fiber.Router, handler *admin.EnterpriseHand
|
|||||||
Register(enterprises, doc, groupPath, "PUT", "/:id/password", handler.UpdatePassword, RouteSpec{
|
Register(enterprises, doc, groupPath, "PUT", "/:id/password", handler.UpdatePassword, RouteSpec{
|
||||||
Summary: "修改企业账号密码",
|
Summary: "修改企业账号密码",
|
||||||
Tags: []string{"企业客户管理"},
|
Tags: []string{"企业客户管理"},
|
||||||
Input: new(model.UpdateEnterprisePasswordReq),
|
Input: new(dto.UpdateEnterprisePasswordReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
"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{
|
Register(enterprises, doc, groupPath, "POST", "/:id/allocate-cards/preview", handler.AllocateCardsPreview, RouteSpec{
|
||||||
Summary: "卡授权预检",
|
Summary: "卡授权预检",
|
||||||
Tags: []string{"企业卡授权"},
|
Tags: []string{"企业卡授权"},
|
||||||
Input: new(model.AllocateCardsPreviewReq),
|
Input: new(dto.AllocateCardsPreviewReq),
|
||||||
Output: new(model.AllocateCardsPreviewResp),
|
Output: new(dto.AllocateCardsPreviewResp),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(enterprises, doc, groupPath, "POST", "/:id/allocate-cards", handler.AllocateCards, RouteSpec{
|
Register(enterprises, doc, groupPath, "POST", "/:id/allocate-cards", handler.AllocateCards, RouteSpec{
|
||||||
Summary: "授权卡给企业",
|
Summary: "授权卡给企业",
|
||||||
Tags: []string{"企业卡授权"},
|
Tags: []string{"企业卡授权"},
|
||||||
Input: new(model.AllocateCardsReq),
|
Input: new(dto.AllocateCardsReq),
|
||||||
Output: new(model.AllocateCardsResp),
|
Output: new(dto.AllocateCardsResp),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(enterprises, doc, groupPath, "POST", "/:id/recall-cards", handler.RecallCards, RouteSpec{
|
Register(enterprises, doc, groupPath, "POST", "/:id/recall-cards", handler.RecallCards, RouteSpec{
|
||||||
Summary: "回收卡授权",
|
Summary: "回收卡授权",
|
||||||
Tags: []string{"企业卡授权"},
|
Tags: []string{"企业卡授权"},
|
||||||
Input: new(model.RecallCardsReq),
|
Input: new(dto.RecallCardsReq),
|
||||||
Output: new(model.RecallCardsResp),
|
Output: new(dto.RecallCardsResp),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(enterprises, doc, groupPath, "GET", "/:id/cards", handler.ListCards, RouteSpec{
|
Register(enterprises, doc, groupPath, "GET", "/:id/cards", handler.ListCards, RouteSpec{
|
||||||
Summary: "企业卡列表",
|
Summary: "企业卡列表",
|
||||||
Tags: []string{"企业卡授权"},
|
Tags: []string{"企业卡授权"},
|
||||||
Input: new(model.EnterpriseCardListReq),
|
Input: new(dto.EnterpriseCardListReq),
|
||||||
Output: new(model.EnterpriseCardPageResult),
|
Output: new(dto.EnterpriseCardPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(enterprises, doc, groupPath, "POST", "/:id/cards/:card_id/suspend", handler.SuspendCard, RouteSpec{
|
Register(enterprises, doc, groupPath, "POST", "/:id/cards/:card_id/suspend", handler.SuspendCard, RouteSpec{
|
||||||
Summary: "停机卡",
|
Summary: "停机卡",
|
||||||
Tags: []string{"企业卡授权"},
|
Tags: []string{"企业卡授权"},
|
||||||
Input: new(model.SuspendCardReq),
|
Input: new(dto.SuspendCardReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
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{
|
Register(enterprises, doc, groupPath, "POST", "/:id/cards/:card_id/resume", handler.ResumeCard, RouteSpec{
|
||||||
Summary: "复机卡",
|
Summary: "复机卡",
|
||||||
Tags: []string{"企业卡授权"},
|
Tags: []string{"企业卡授权"},
|
||||||
Input: new(model.ResumeCardReq),
|
Input: new(dto.ResumeCardReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
"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"
|
"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{
|
Register(router, doc, basePath, "POST", "/login", h.Login, RouteSpec{
|
||||||
Summary: "H5 登录",
|
Summary: "H5 登录",
|
||||||
Tags: []string{"H5 认证"},
|
Tags: []string{"H5 认证"},
|
||||||
Input: new(model.LoginRequest),
|
Input: new(dto.LoginRequest),
|
||||||
Output: new(model.LoginResponse),
|
Output: new(dto.LoginResponse),
|
||||||
Auth: false,
|
Auth: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(router, doc, basePath, "POST", "/refresh-token", h.RefreshToken, RouteSpec{
|
Register(router, doc, basePath, "POST", "/refresh-token", h.RefreshToken, RouteSpec{
|
||||||
Summary: "刷新 Token",
|
Summary: "刷新 Token",
|
||||||
Tags: []string{"H5 认证"},
|
Tags: []string{"H5 认证"},
|
||||||
Input: new(model.RefreshTokenRequest),
|
Input: new(dto.RefreshTokenRequest),
|
||||||
Output: new(model.RefreshTokenResponse),
|
Output: new(dto.RefreshTokenResponse),
|
||||||
Auth: false,
|
Auth: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -54,14 +54,14 @@ func registerH5AuthRoutes(router fiber.Router, handler interface{}, authMiddlewa
|
|||||||
Summary: "获取当前用户信息",
|
Summary: "获取当前用户信息",
|
||||||
Tags: []string{"H5 认证"},
|
Tags: []string{"H5 认证"},
|
||||||
Input: nil,
|
Input: nil,
|
||||||
Output: new(model.UserInfo),
|
Output: new(dto.UserInfo),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(authGroup, doc, basePath, "PUT", "/password", h.ChangePassword, RouteSpec{
|
Register(authGroup, doc, basePath, "PUT", "/password", h.ChangePassword, RouteSpec{
|
||||||
Summary: "修改密码",
|
Summary: "修改密码",
|
||||||
Tags: []string{"H5 认证"},
|
Tags: []string{"H5 认证"},
|
||||||
Input: new(model.ChangePasswordRequest),
|
Input: new(dto.ChangePasswordRequest),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,31 +16,31 @@ func registerMyCommissionRoutes(router fiber.Router, handler *admin.MyCommission
|
|||||||
Summary: "我的佣金概览",
|
Summary: "我的佣金概览",
|
||||||
Tags: []string{"我的佣金"},
|
Tags: []string{"我的佣金"},
|
||||||
Input: nil,
|
Input: nil,
|
||||||
Output: new(model.MyCommissionSummaryResp),
|
Output: new(dto.MyCommissionSummaryResp),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(my, doc, groupPath, "POST", "/withdrawal-requests", handler.CreateWithdrawal, RouteSpec{
|
Register(my, doc, groupPath, "POST", "/withdrawal-requests", handler.CreateWithdrawal, RouteSpec{
|
||||||
Summary: "发起提现申请",
|
Summary: "发起提现申请",
|
||||||
Tags: []string{"我的佣金"},
|
Tags: []string{"我的佣金"},
|
||||||
Input: new(model.CreateMyWithdrawalReq),
|
Input: new(dto.CreateMyWithdrawalReq),
|
||||||
Output: new(model.CreateMyWithdrawalResp),
|
Output: new(dto.CreateMyWithdrawalResp),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(my, doc, groupPath, "GET", "/withdrawal-requests", handler.ListWithdrawals, RouteSpec{
|
Register(my, doc, groupPath, "GET", "/withdrawal-requests", handler.ListWithdrawals, RouteSpec{
|
||||||
Summary: "我的提现记录",
|
Summary: "我的提现记录",
|
||||||
Tags: []string{"我的佣金"},
|
Tags: []string{"我的佣金"},
|
||||||
Input: new(model.MyWithdrawalListReq),
|
Input: new(dto.MyWithdrawalListReq),
|
||||||
Output: new(model.WithdrawalRequestPageResult),
|
Output: new(dto.WithdrawalRequestPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(my, doc, groupPath, "GET", "/commission-records", handler.ListRecords, RouteSpec{
|
Register(my, doc, groupPath, "GET", "/commission-records", handler.ListRecords, RouteSpec{
|
||||||
Summary: "我的佣金明细",
|
Summary: "我的佣金明细",
|
||||||
Tags: []string{"我的佣金"},
|
Tags: []string{"我的佣金"},
|
||||||
Input: new(model.MyCommissionRecordListReq),
|
Input: new(dto.MyCommissionRecordListReq),
|
||||||
Output: new(model.MyCommissionRecordPageResult),
|
Output: new(dto.MyCommissionRecordPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
"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{
|
Register(permissions, doc, groupPath, "POST", "", h.Create, RouteSpec{
|
||||||
Summary: "创建权限",
|
Summary: "创建权限",
|
||||||
Tags: []string{"权限"},
|
Tags: []string{"权限"},
|
||||||
Input: new(model.CreatePermissionRequest),
|
Input: new(dto.CreatePermissionRequest),
|
||||||
Output: new(model.PermissionResponse),
|
Output: new(dto.PermissionResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(permissions, doc, groupPath, "GET", "", h.List, RouteSpec{
|
Register(permissions, doc, groupPath, "GET", "", h.List, RouteSpec{
|
||||||
Summary: "权限列表",
|
Summary: "权限列表",
|
||||||
Tags: []string{"权限"},
|
Tags: []string{"权限"},
|
||||||
Input: new(model.PermissionListRequest),
|
Input: new(dto.PermissionListRequest),
|
||||||
Output: new(model.PermissionPageResult),
|
Output: new(dto.PermissionPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -34,30 +34,30 @@ func registerPermissionRoutes(api fiber.Router, h *admin.PermissionHandler, doc
|
|||||||
Summary: "获取权限树",
|
Summary: "获取权限树",
|
||||||
Tags: []string{"权限"},
|
Tags: []string{"权限"},
|
||||||
Input: nil, // 无参数或 Query 参数
|
Input: nil, // 无参数或 Query 参数
|
||||||
Output: new([]*model.PermissionTreeNode),
|
Output: new([]*dto.PermissionTreeNode),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(permissions, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
Register(permissions, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
||||||
Summary: "获取权限详情",
|
Summary: "获取权限详情",
|
||||||
Tags: []string{"权限"},
|
Tags: []string{"权限"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: new(model.PermissionResponse),
|
Output: new(dto.PermissionResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(permissions, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
Register(permissions, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
||||||
Summary: "更新权限",
|
Summary: "更新权限",
|
||||||
Tags: []string{"权限"},
|
Tags: []string{"权限"},
|
||||||
Input: new(model.UpdatePermissionParams),
|
Input: new(dto.UpdatePermissionParams),
|
||||||
Output: new(model.PermissionResponse),
|
Output: new(dto.PermissionResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(permissions, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
Register(permissions, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
||||||
Summary: "删除权限",
|
Summary: "删除权限",
|
||||||
Tags: []string{"权限"},
|
Tags: []string{"权限"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
"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{
|
Register(roles, doc, groupPath, "POST", "", h.Create, RouteSpec{
|
||||||
Summary: "创建角色",
|
Summary: "创建角色",
|
||||||
Tags: []string{"角色"},
|
Tags: []string{"角色"},
|
||||||
Input: new(model.CreateRoleRequest),
|
Input: new(dto.CreateRoleRequest),
|
||||||
Output: new(model.RoleResponse),
|
Output: new(dto.RoleResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(roles, doc, groupPath, "GET", "", h.List, RouteSpec{
|
Register(roles, doc, groupPath, "GET", "", h.List, RouteSpec{
|
||||||
Summary: "角色列表",
|
Summary: "角色列表",
|
||||||
Tags: []string{"角色"},
|
Tags: []string{"角色"},
|
||||||
Input: new(model.RoleListRequest),
|
Input: new(dto.RoleListRequest),
|
||||||
Output: new(model.RolePageResult),
|
Output: new(dto.RolePageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(roles, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
Register(roles, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
||||||
Summary: "获取角色详情",
|
Summary: "获取角色详情",
|
||||||
Tags: []string{"角色"},
|
Tags: []string{"角色"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: new(model.RoleResponse),
|
Output: new(dto.RoleResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(roles, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
Register(roles, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
||||||
Summary: "更新角色",
|
Summary: "更新角色",
|
||||||
Tags: []string{"角色"},
|
Tags: []string{"角色"},
|
||||||
Input: new(model.UpdateRoleParams),
|
Input: new(dto.UpdateRoleParams),
|
||||||
Output: new(model.RoleResponse),
|
Output: new(dto.RoleResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(roles, doc, groupPath, "PUT", "/:id/status", h.UpdateStatus, RouteSpec{
|
Register(roles, doc, groupPath, "PUT", "/:id/status", h.UpdateStatus, RouteSpec{
|
||||||
Summary: "更新角色状态",
|
Summary: "更新角色状态",
|
||||||
Tags: []string{"角色"},
|
Tags: []string{"角色"},
|
||||||
Input: new(model.UpdateRoleStatusParams),
|
Input: new(dto.UpdateRoleStatusParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
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{
|
Register(roles, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
||||||
Summary: "删除角色",
|
Summary: "删除角色",
|
||||||
Tags: []string{"角色"},
|
Tags: []string{"角色"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
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{
|
Register(roles, doc, groupPath, "POST", "/:id/permissions", h.AssignPermissions, RouteSpec{
|
||||||
Summary: "分配权限",
|
Summary: "分配权限",
|
||||||
Tags: []string{"角色"},
|
Tags: []string{"角色"},
|
||||||
Input: new(model.AssignPermissionsParams),
|
Input: new(dto.AssignPermissionsParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
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{
|
Register(roles, doc, groupPath, "GET", "/:id/permissions", h.GetPermissions, RouteSpec{
|
||||||
Summary: "获取角色权限",
|
Summary: "获取角色权限",
|
||||||
Tags: []string{"角色"},
|
Tags: []string{"角色"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: new([]model.Permission),
|
Output: new([]model.Permission),
|
||||||
Auth: true,
|
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{
|
Register(roles, doc, groupPath, "DELETE", "/:role_id/permissions/:perm_id", h.RemovePermission, RouteSpec{
|
||||||
Summary: "移除权限",
|
Summary: "移除权限",
|
||||||
Tags: []string{"角色"},
|
Tags: []string{"角色"},
|
||||||
Input: new(model.RemovePermissionParams),
|
Input: new(dto.RemovePermissionParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
"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{
|
Register(shops, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
||||||
Summary: "店铺列表",
|
Summary: "店铺列表",
|
||||||
Tags: []string{"店铺管理"},
|
Tags: []string{"店铺管理"},
|
||||||
Input: new(model.ShopListRequest),
|
Input: new(dto.ShopListRequest),
|
||||||
Output: new(model.ShopPageResult),
|
Output: new(dto.ShopPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(shops, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
Register(shops, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
||||||
Summary: "创建店铺",
|
Summary: "创建店铺",
|
||||||
Tags: []string{"店铺管理"},
|
Tags: []string{"店铺管理"},
|
||||||
Input: new(model.CreateShopRequest),
|
Input: new(dto.CreateShopRequest),
|
||||||
Output: new(model.ShopResponse),
|
Output: new(dto.ShopResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(shops, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
Register(shops, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
||||||
Summary: "更新店铺",
|
Summary: "更新店铺",
|
||||||
Tags: []string{"店铺管理"},
|
Tags: []string{"店铺管理"},
|
||||||
Input: new(model.UpdateShopParams),
|
Input: new(dto.UpdateShopParams),
|
||||||
Output: new(model.ShopResponse),
|
Output: new(dto.ShopResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(shops, doc, groupPath, "DELETE", "/:id", handler.Delete, RouteSpec{
|
Register(shops, doc, groupPath, "DELETE", "/:id", handler.Delete, RouteSpec{
|
||||||
Summary: "删除店铺",
|
Summary: "删除店铺",
|
||||||
Tags: []string{"店铺管理"},
|
Tags: []string{"店铺管理"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
@@ -52,31 +52,31 @@ func registerShopAccountRoutes(router fiber.Router, handler *admin.ShopAccountHa
|
|||||||
Register(shopAccounts, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
Register(shopAccounts, doc, groupPath, "GET", "", handler.List, RouteSpec{
|
||||||
Summary: "代理账号列表",
|
Summary: "代理账号列表",
|
||||||
Tags: []string{"代理账号管理"},
|
Tags: []string{"代理账号管理"},
|
||||||
Input: new(model.ShopAccountListRequest),
|
Input: new(dto.ShopAccountListRequest),
|
||||||
Output: new(model.ShopAccountPageResult),
|
Output: new(dto.ShopAccountPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(shopAccounts, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
Register(shopAccounts, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
||||||
Summary: "创建代理账号",
|
Summary: "创建代理账号",
|
||||||
Tags: []string{"代理账号管理"},
|
Tags: []string{"代理账号管理"},
|
||||||
Input: new(model.CreateShopAccountRequest),
|
Input: new(dto.CreateShopAccountRequest),
|
||||||
Output: new(model.ShopAccountResponse),
|
Output: new(dto.ShopAccountResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(shopAccounts, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
Register(shopAccounts, doc, groupPath, "PUT", "/:id", handler.Update, RouteSpec{
|
||||||
Summary: "更新代理账号",
|
Summary: "更新代理账号",
|
||||||
Tags: []string{"代理账号管理"},
|
Tags: []string{"代理账号管理"},
|
||||||
Input: new(model.UpdateShopAccountParams),
|
Input: new(dto.UpdateShopAccountParams),
|
||||||
Output: new(model.ShopAccountResponse),
|
Output: new(dto.ShopAccountResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(shopAccounts, doc, groupPath, "PUT", "/:id/password", handler.UpdatePassword, RouteSpec{
|
Register(shopAccounts, doc, groupPath, "PUT", "/:id/password", handler.UpdatePassword, RouteSpec{
|
||||||
Summary: "重置代理账号密码",
|
Summary: "重置代理账号密码",
|
||||||
Tags: []string{"代理账号管理"},
|
Tags: []string{"代理账号管理"},
|
||||||
Input: new(model.UpdateShopAccountPasswordParams),
|
Input: new(dto.UpdateShopAccountPasswordParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
@@ -84,7 +84,7 @@ func registerShopAccountRoutes(router fiber.Router, handler *admin.ShopAccountHa
|
|||||||
Register(shopAccounts, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
|
Register(shopAccounts, doc, groupPath, "PUT", "/:id/status", handler.UpdateStatus, RouteSpec{
|
||||||
Summary: "启用/禁用代理账号",
|
Summary: "启用/禁用代理账号",
|
||||||
Tags: []string{"代理账号管理"},
|
Tags: []string{"代理账号管理"},
|
||||||
Input: new(model.UpdateShopAccountStatusParams),
|
Input: new(dto.UpdateShopAccountStatusParams),
|
||||||
Output: nil,
|
Output: nil,
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
@@ -97,24 +97,24 @@ func registerShopCommissionRoutes(router fiber.Router, handler *admin.ShopCommis
|
|||||||
Register(shops, doc, groupPath, "GET", "/commission-summary", handler.ListCommissionSummary, RouteSpec{
|
Register(shops, doc, groupPath, "GET", "/commission-summary", handler.ListCommissionSummary, RouteSpec{
|
||||||
Summary: "代理商佣金列表",
|
Summary: "代理商佣金列表",
|
||||||
Tags: []string{"代理商佣金管理"},
|
Tags: []string{"代理商佣金管理"},
|
||||||
Input: new(model.ShopCommissionSummaryListReq),
|
Input: new(dto.ShopCommissionSummaryListReq),
|
||||||
Output: new(model.ShopCommissionSummaryPageResult),
|
Output: new(dto.ShopCommissionSummaryPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(shops, doc, groupPath, "GET", "/:shop_id/withdrawal-requests", handler.ListWithdrawalRequests, RouteSpec{
|
Register(shops, doc, groupPath, "GET", "/:shop_id/withdrawal-requests", handler.ListWithdrawalRequests, RouteSpec{
|
||||||
Summary: "代理商提现记录",
|
Summary: "代理商提现记录",
|
||||||
Tags: []string{"代理商佣金管理"},
|
Tags: []string{"代理商佣金管理"},
|
||||||
Input: new(model.ShopWithdrawalRequestListReq),
|
Input: new(dto.ShopWithdrawalRequestListReq),
|
||||||
Output: new(model.ShopWithdrawalRequestPageResult),
|
Output: new(dto.ShopWithdrawalRequestPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
Register(shops, doc, groupPath, "GET", "/:shop_id/commission-records", handler.ListCommissionRecords, RouteSpec{
|
Register(shops, doc, groupPath, "GET", "/:shop_id/commission-records", handler.ListCommissionRecords, RouteSpec{
|
||||||
Summary: "代理商佣金明细",
|
Summary: "代理商佣金明细",
|
||||||
Tags: []string{"代理商佣金管理"},
|
Tags: []string{"代理商佣金管理"},
|
||||||
Input: new(model.ShopCommissionRecordListReq),
|
Input: new(dto.ShopCommissionRecordListReq),
|
||||||
Output: new(model.ShopCommissionRecordPageResult),
|
Output: new(dto.ShopCommissionRecordPageResult),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package routes
|
|||||||
import (
|
import (
|
||||||
"github.com/gofiber/fiber/v2"
|
"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/openapi"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/response"
|
"github.com/break/junhong_cmp_fiber/pkg/response"
|
||||||
)
|
)
|
||||||
@@ -26,7 +26,7 @@ func registerTaskRoutes(api fiber.Router, doc *openapi.Generator, basePath strin
|
|||||||
}, RouteSpec{
|
}, RouteSpec{
|
||||||
Summary: "查询任务状态",
|
Summary: "查询任务状态",
|
||||||
Tags: []string{"任务管理"},
|
Tags: []string{"任务管理"},
|
||||||
Input: new(model.IDReq),
|
Input: new(dto.IDReq),
|
||||||
Output: new(TaskStatusResponse),
|
Output: new(TaskStatusResponse),
|
||||||
Auth: true,
|
Auth: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -33,7 +34,7 @@ func New(accountStore *postgres.AccountStore, roleStore *postgres.RoleStore, acc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create 创建账号
|
// Create 创建账号
|
||||||
func (s *Service) Create(ctx context.Context, req *model.CreateAccountRequest) (*model.Account, error) {
|
func (s *Service) Create(ctx context.Context, req *dto.CreateAccountRequest) (*model.Account, error) {
|
||||||
// 获取当前用户 ID
|
// 获取当前用户 ID
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
@@ -102,7 +103,7 @@ func (s *Service) Get(ctx context.Context, id uint) (*model.Account, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update 更新账号
|
// Update 更新账号
|
||||||
func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateAccountRequest) (*model.Account, error) {
|
func (s *Service) Update(ctx context.Context, id uint, req *dto.UpdateAccountRequest) (*model.Account, error) {
|
||||||
// 获取当前用户 ID
|
// 获取当前用户 ID
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
@@ -180,7 +181,7 @@ func (s *Service) Delete(ctx context.Context, id uint) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List 查询账号列表
|
// List 查询账号列表
|
||||||
func (s *Service) List(ctx context.Context, req *model.AccountListRequest) ([]*model.Account, int64, error) {
|
func (s *Service) List(ctx context.Context, req *dto.AccountListRequest) ([]*model.Account, int64, error) {
|
||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
@@ -397,7 +398,7 @@ func (s *Service) UpdateStatus(ctx context.Context, accountID uint, status int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListPlatformAccounts 查询平台账号列表(自动筛选 user_type IN (1, 2))
|
// ListPlatformAccounts 查询平台账号列表(自动筛选 user_type IN (1, 2))
|
||||||
func (s *Service) ListPlatformAccounts(ctx context.Context, req *model.PlatformAccountListRequest) ([]*model.Account, int64, error) {
|
func (s *Service) ListPlatformAccounts(ctx context.Context, req *dto.PlatformAccountListRequest) ([]*model.Account, int64, error) {
|
||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/auth"
|
"github.com/break/junhong_cmp_fiber/pkg/auth"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"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)
|
ctx = pkgGorm.SkipDataPermission(ctx)
|
||||||
|
|
||||||
account, err := s.accountStore.GetByUsernameOrPhone(ctx, req.Username)
|
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),
|
zap.String("ip", clientIP),
|
||||||
)
|
)
|
||||||
|
|
||||||
return &model.LoginResponse{
|
return &dto.LoginResponse{
|
||||||
AccessToken: accessToken,
|
AccessToken: accessToken,
|
||||||
RefreshToken: refreshToken,
|
RefreshToken: refreshToken,
|
||||||
ExpiresIn: int64(constants.DefaultAccessTokenTTL.Seconds()),
|
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)
|
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)
|
account, err := s.accountStore.GetByID(ctx, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
@@ -222,7 +223,7 @@ func (s *Service) getUserPermissions(ctx context.Context, userID uint) ([]string
|
|||||||
return permCodes, nil
|
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)
|
userTypeName := s.getUserTypeName(account.UserType)
|
||||||
|
|
||||||
var shopID, enterpriseID uint
|
var shopID, enterpriseID uint
|
||||||
@@ -233,7 +234,7 @@ func (s *Service) buildUserInfo(account *model.Account) model.UserInfo {
|
|||||||
enterpriseID = *account.EnterpriseID
|
enterpriseID = *account.EnterpriseID
|
||||||
}
|
}
|
||||||
|
|
||||||
return model.UserInfo{
|
return dto.UserInfo{
|
||||||
ID: account.ID,
|
ID: account.ID,
|
||||||
Username: account.Username,
|
Username: account.Username,
|
||||||
Phone: account.Phone,
|
Phone: account.Phone,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -42,7 +43,7 @@ func New(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) ListWithdrawalRequests(ctx context.Context, req *model.WithdrawalRequestListReq) (*model.WithdrawalRequestPageResult, error) {
|
func (s *Service) ListWithdrawalRequests(ctx context.Context, req *dto.WithdrawalRequestListReq) (*dto.WithdrawalRequestPageResult, error) {
|
||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
@@ -116,7 +117,7 @@ func (s *Service) ListWithdrawalRequests(ctx context.Context, req *model.Withdra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]model.WithdrawalRequestItem, 0, len(requests))
|
items := make([]dto.WithdrawalRequestItem, 0, len(requests))
|
||||||
for _, r := range requests {
|
for _, r := range requests {
|
||||||
shop := shopMap[r.ShopID]
|
shop := shopMap[r.ShopID]
|
||||||
shopName := ""
|
shopName := ""
|
||||||
@@ -134,7 +135,7 @@ func (s *Service) ListWithdrawalRequests(ctx context.Context, req *model.Withdra
|
|||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.WithdrawalRequestPageResult{
|
return &dto.WithdrawalRequestPageResult{
|
||||||
Items: items,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: opts.Page,
|
Page: opts.Page,
|
||||||
@@ -142,7 +143,7 @@ func (s *Service) ListWithdrawalRequests(ctx context.Context, req *model.Withdra
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Approve(ctx context.Context, id uint, req *model.ApproveWithdrawalReq) (*model.WithdrawalApprovalResp, error) {
|
func (s *Service) Approve(ctx context.Context, id uint, req *dto.ApproveWithdrawalReq) (*dto.WithdrawalApprovalResp, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -241,7 +242,7 @@ func (s *Service) Approve(ctx context.Context, id uint, req *model.ApproveWithdr
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.WithdrawalApprovalResp{
|
return &dto.WithdrawalApprovalResp{
|
||||||
ID: withdrawal.ID,
|
ID: withdrawal.ID,
|
||||||
WithdrawalNo: withdrawal.WithdrawalNo,
|
WithdrawalNo: withdrawal.WithdrawalNo,
|
||||||
Status: constants.WithdrawalStatusApproved,
|
Status: constants.WithdrawalStatusApproved,
|
||||||
@@ -250,7 +251,7 @@ func (s *Service) Approve(ctx context.Context, id uint, req *model.ApproveWithdr
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Reject(ctx context.Context, id uint, req *model.RejectWithdrawalReq) (*model.WithdrawalApprovalResp, error) {
|
func (s *Service) Reject(ctx context.Context, id uint, req *dto.RejectWithdrawalReq) (*dto.WithdrawalApprovalResp, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -312,7 +313,7 @@ func (s *Service) Reject(ctx context.Context, id uint, req *model.RejectWithdraw
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.WithdrawalApprovalResp{
|
return &dto.WithdrawalApprovalResp{
|
||||||
ID: withdrawal.ID,
|
ID: withdrawal.ID,
|
||||||
WithdrawalNo: withdrawal.WithdrawalNo,
|
WithdrawalNo: withdrawal.WithdrawalNo,
|
||||||
Status: constants.WithdrawalStatusRejected,
|
Status: constants.WithdrawalStatusRejected,
|
||||||
@@ -340,7 +341,7 @@ func (s *Service) buildShopHierarchyPath(ctx context.Context, shop *model.Shop)
|
|||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) buildWithdrawalRequestItem(r *model.CommissionWithdrawalRequest, shopName, shopHierarchy string, applicantMap, processorMap map[uint]string) model.WithdrawalRequestItem {
|
func (s *Service) buildWithdrawalRequestItem(r *model.CommissionWithdrawalRequest, shopName, shopHierarchy string, applicantMap, processorMap map[uint]string) dto.WithdrawalRequestItem {
|
||||||
var processorID *uint
|
var processorID *uint
|
||||||
if r.ProcessorID > 0 {
|
if r.ProcessorID > 0 {
|
||||||
processorID = &r.ProcessorID
|
processorID = &r.ProcessorID
|
||||||
@@ -367,7 +368,7 @@ func (s *Service) buildWithdrawalRequestItem(r *model.CommissionWithdrawalReques
|
|||||||
processedAt = r.ProcessedAt.Format("2006-01-02 15:04:05")
|
processedAt = r.ProcessedAt.Format("2006-01-02 15:04:05")
|
||||||
}
|
}
|
||||||
|
|
||||||
return model.WithdrawalRequestItem{
|
return dto.WithdrawalRequestItem{
|
||||||
ID: r.ID,
|
ID: r.ID,
|
||||||
WithdrawalNo: r.WithdrawalNo,
|
WithdrawalNo: r.WithdrawalNo,
|
||||||
Amount: r.Amount,
|
Amount: r.Amount,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -31,7 +32,7 @@ func New(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Create(ctx context.Context, req *model.CreateWithdrawalSettingReq) (*model.WithdrawalSettingItem, error) {
|
func (s *Service) Create(ctx context.Context, req *dto.CreateWithdrawalSettingReq) (*dto.WithdrawalSettingItem, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -65,7 +66,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreateWithdrawalSetting
|
|||||||
creatorName = creator.Username
|
creatorName = creator.Username
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.WithdrawalSettingItem{
|
return &dto.WithdrawalSettingItem{
|
||||||
ID: setting.ID,
|
ID: setting.ID,
|
||||||
DailyWithdrawalLimit: setting.DailyWithdrawalLimit,
|
DailyWithdrawalLimit: setting.DailyWithdrawalLimit,
|
||||||
MinWithdrawalAmount: setting.MinWithdrawalAmount,
|
MinWithdrawalAmount: setting.MinWithdrawalAmount,
|
||||||
@@ -78,7 +79,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreateWithdrawalSetting
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) List(ctx context.Context, req *model.WithdrawalSettingListReq) (*model.WithdrawalSettingPageResult, error) {
|
func (s *Service) List(ctx context.Context, req *dto.WithdrawalSettingListReq) (*dto.WithdrawalSettingPageResult, error) {
|
||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
@@ -110,9 +111,9 @@ func (s *Service) List(ctx context.Context, req *model.WithdrawalSettingListReq)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]model.WithdrawalSettingItem, 0, len(settings))
|
items := make([]dto.WithdrawalSettingItem, 0, len(settings))
|
||||||
for _, setting := range settings {
|
for _, setting := range settings {
|
||||||
items = append(items, model.WithdrawalSettingItem{
|
items = append(items, dto.WithdrawalSettingItem{
|
||||||
ID: setting.ID,
|
ID: setting.ID,
|
||||||
DailyWithdrawalLimit: setting.DailyWithdrawalLimit,
|
DailyWithdrawalLimit: setting.DailyWithdrawalLimit,
|
||||||
MinWithdrawalAmount: setting.MinWithdrawalAmount,
|
MinWithdrawalAmount: setting.MinWithdrawalAmount,
|
||||||
@@ -125,7 +126,7 @@ func (s *Service) List(ctx context.Context, req *model.WithdrawalSettingListReq)
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.WithdrawalSettingPageResult{
|
return &dto.WithdrawalSettingPageResult{
|
||||||
Items: items,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: opts.Page,
|
Page: opts.Page,
|
||||||
@@ -133,7 +134,7 @@ func (s *Service) List(ctx context.Context, req *model.WithdrawalSettingListReq)
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GetCurrent(ctx context.Context) (*model.WithdrawalSettingItem, error) {
|
func (s *Service) GetCurrent(ctx context.Context) (*dto.WithdrawalSettingItem, error) {
|
||||||
setting, err := s.commissionWithdrawalSettingStore.GetCurrent(ctx)
|
setting, err := s.commissionWithdrawalSettingStore.GetCurrent(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
@@ -147,7 +148,7 @@ func (s *Service) GetCurrent(ctx context.Context) (*model.WithdrawalSettingItem,
|
|||||||
creatorName = creator.Username
|
creatorName = creator.Username
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.WithdrawalSettingItem{
|
return &dto.WithdrawalSettingItem{
|
||||||
ID: setting.ID,
|
ID: setting.ID,
|
||||||
DailyWithdrawalLimit: setting.DailyWithdrawalLimit,
|
DailyWithdrawalLimit: setting.DailyWithdrawalLimit,
|
||||||
MinWithdrawalAmount: setting.MinWithdrawalAmount,
|
MinWithdrawalAmount: setting.MinWithdrawalAmount,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -25,7 +26,7 @@ func New(customerStore *postgres.PersonalCustomerStore) *Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create 创建个人客户
|
// Create 创建个人客户
|
||||||
func (s *Service) Create(ctx context.Context, req *model.CreatePersonalCustomerRequest) (*model.PersonalCustomer, error) {
|
func (s *Service) Create(ctx context.Context, req *dto.CreatePersonalCustomerRequest) (*model.PersonalCustomer, error) {
|
||||||
// 检查手机号唯一性
|
// 检查手机号唯一性
|
||||||
if req.Phone != "" {
|
if req.Phone != "" {
|
||||||
existing, err := s.customerStore.GetByPhone(ctx, req.Phone)
|
existing, err := s.customerStore.GetByPhone(ctx, req.Phone)
|
||||||
@@ -55,7 +56,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreatePersonalCustomerR
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update 更新个人客户信息
|
// Update 更新个人客户信息
|
||||||
func (s *Service) Update(ctx context.Context, id uint, req *model.UpdatePersonalCustomerRequest) (*model.PersonalCustomer, error) {
|
func (s *Service) Update(ctx context.Context, id uint, req *dto.UpdatePersonalCustomerRequest) (*model.PersonalCustomer, error) {
|
||||||
// 查询客户
|
// 查询客户
|
||||||
customer, err := s.customerStore.GetByID(ctx, id)
|
customer, err := s.customerStore.GetByID(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
@@ -34,7 +35,7 @@ func New(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) List(ctx context.Context, req *model.CustomerAccountListReq) (*model.CustomerAccountPageResult, error) {
|
func (s *Service) List(ctx context.Context, req *dto.CustomerAccountListReq) (*dto.CustomerAccountPageResult, error) {
|
||||||
page := req.Page
|
page := req.Page
|
||||||
pageSize := req.PageSize
|
pageSize := req.PageSize
|
||||||
if page == 0 {
|
if page == 0 {
|
||||||
@@ -106,7 +107,7 @@ func (s *Service) List(ctx context.Context, req *model.CustomerAccountListReq) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]model.CustomerAccountItem, 0, len(accounts))
|
items := make([]dto.CustomerAccountItem, 0, len(accounts))
|
||||||
for _, acc := range accounts {
|
for _, acc := range accounts {
|
||||||
shopName := ""
|
shopName := ""
|
||||||
if acc.ShopID != nil {
|
if acc.ShopID != nil {
|
||||||
@@ -116,7 +117,7 @@ func (s *Service) List(ctx context.Context, req *model.CustomerAccountListReq) (
|
|||||||
if acc.EnterpriseID != nil {
|
if acc.EnterpriseID != nil {
|
||||||
enterpriseName = enterpriseMap[*acc.EnterpriseID]
|
enterpriseName = enterpriseMap[*acc.EnterpriseID]
|
||||||
}
|
}
|
||||||
items = append(items, model.CustomerAccountItem{
|
items = append(items, dto.CustomerAccountItem{
|
||||||
ID: acc.ID,
|
ID: acc.ID,
|
||||||
Username: acc.Username,
|
Username: acc.Username,
|
||||||
Phone: acc.Phone,
|
Phone: acc.Phone,
|
||||||
@@ -132,7 +133,7 @@ func (s *Service) List(ctx context.Context, req *model.CustomerAccountListReq) (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.CustomerAccountPageResult{
|
return &dto.CustomerAccountPageResult{
|
||||||
Items: items,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: page,
|
Page: page,
|
||||||
@@ -140,7 +141,7 @@ func (s *Service) List(ctx context.Context, req *model.CustomerAccountListReq) (
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Create(ctx context.Context, req *model.CreateCustomerAccountReq) (*model.CustomerAccountItem, error) {
|
func (s *Service) Create(ctx context.Context, req *dto.CreateCustomerAccountReq) (*dto.CustomerAccountItem, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -182,7 +183,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreateCustomerAccountRe
|
|||||||
shopName = shop.ShopName
|
shopName = shop.ShopName
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.CustomerAccountItem{
|
return &dto.CustomerAccountItem{
|
||||||
ID: account.ID,
|
ID: account.ID,
|
||||||
Username: account.Username,
|
Username: account.Username,
|
||||||
Phone: account.Phone,
|
Phone: account.Phone,
|
||||||
@@ -196,7 +197,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreateCustomerAccountRe
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateCustomerAccountRequest) (*model.CustomerAccountItem, error) {
|
func (s *Service) Update(ctx context.Context, id uint, req *dto.UpdateCustomerAccountRequest) (*dto.CustomerAccountItem, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -242,7 +243,7 @@ func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateCustomer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.CustomerAccountItem{
|
return &dto.CustomerAccountItem{
|
||||||
ID: account.ID,
|
ID: account.ID,
|
||||||
Username: account.Username,
|
Username: account.Username,
|
||||||
Phone: account.Phone,
|
Phone: account.Phone,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -30,7 +31,7 @@ func New(db *gorm.DB, enterpriseStore *postgres.EnterpriseStore, shopStore *post
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Create(ctx context.Context, req *model.CreateEnterpriseReq) (*model.CreateEnterpriseResp, error) {
|
func (s *Service) Create(ctx context.Context, req *dto.CreateEnterpriseReq) (*dto.CreateEnterpriseResp, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -114,8 +115,8 @@ func (s *Service) Create(ctx context.Context, req *model.CreateEnterpriseReq) (*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.CreateEnterpriseResp{
|
return &dto.CreateEnterpriseResp{
|
||||||
Enterprise: model.EnterpriseItem{
|
Enterprise: dto.EnterpriseItem{
|
||||||
ID: enterprise.ID,
|
ID: enterprise.ID,
|
||||||
EnterpriseName: enterprise.EnterpriseName,
|
EnterpriseName: enterprise.EnterpriseName,
|
||||||
EnterpriseCode: enterprise.EnterpriseCode,
|
EnterpriseCode: enterprise.EnterpriseCode,
|
||||||
@@ -139,7 +140,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreateEnterpriseReq) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update 更新企业信息
|
// Update 更新企业信息
|
||||||
func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateEnterpriseRequest) (*model.Enterprise, error) {
|
func (s *Service) Update(ctx context.Context, id uint, req *dto.UpdateEnterpriseRequest) (*model.Enterprise, error) {
|
||||||
// 获取当前用户 ID
|
// 获取当前用户 ID
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
@@ -262,7 +263,7 @@ func (s *Service) GetByID(ctx context.Context, id uint) (*model.Enterprise, erro
|
|||||||
return enterprise, nil
|
return enterprise, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) List(ctx context.Context, req *model.EnterpriseListReq) (*model.EnterprisePageResult, error) {
|
func (s *Service) List(ctx context.Context, req *dto.EnterpriseListReq) (*dto.EnterprisePageResult, error) {
|
||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
@@ -322,13 +323,13 @@ func (s *Service) List(ctx context.Context, req *model.EnterpriseListReq) (*mode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]model.EnterpriseItem, 0, len(enterprises))
|
items := make([]dto.EnterpriseItem, 0, len(enterprises))
|
||||||
for _, e := range enterprises {
|
for _, e := range enterprises {
|
||||||
ownerShopName := ""
|
ownerShopName := ""
|
||||||
if e.OwnerShopID != nil {
|
if e.OwnerShopID != nil {
|
||||||
ownerShopName = shopMap[*e.OwnerShopID]
|
ownerShopName = shopMap[*e.OwnerShopID]
|
||||||
}
|
}
|
||||||
items = append(items, model.EnterpriseItem{
|
items = append(items, dto.EnterpriseItem{
|
||||||
ID: e.ID,
|
ID: e.ID,
|
||||||
EnterpriseName: e.EnterpriseName,
|
EnterpriseName: e.EnterpriseName,
|
||||||
EnterpriseCode: e.EnterpriseCode,
|
EnterpriseCode: e.EnterpriseCode,
|
||||||
@@ -349,7 +350,7 @@ func (s *Service) List(ctx context.Context, req *model.EnterpriseListReq) (*mode
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.EnterprisePageResult{
|
return &dto.EnterprisePageResult{
|
||||||
Items: items,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: opts.Page,
|
Page: opts.Page,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
@@ -31,7 +32,7 @@ func New(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) AllocateCardsPreview(ctx context.Context, enterpriseID uint, req *model.AllocateCardsPreviewReq) (*model.AllocateCardsPreviewResp, error) {
|
func (s *Service) AllocateCardsPreview(ctx context.Context, enterpriseID uint, req *dto.AllocateCardsPreviewReq) (*dto.AllocateCardsPreviewResp, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -84,10 +85,10 @@ func (s *Service) AllocateCardsPreview(ctx context.Context, enterpriseID uint, r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &model.AllocateCardsPreviewResp{
|
resp := &dto.AllocateCardsPreviewResp{
|
||||||
StandaloneCards: make([]model.StandaloneCard, 0),
|
StandaloneCards: make([]dto.StandaloneCard, 0),
|
||||||
DeviceBundles: make([]model.DeviceBundle, 0),
|
DeviceBundles: make([]dto.DeviceBundle, 0),
|
||||||
FailedItems: make([]model.FailedItem, 0),
|
FailedItems: make([]dto.FailedItem, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
processedDevices := make(map[uint]bool)
|
processedDevices := make(map[uint]bool)
|
||||||
@@ -95,7 +96,7 @@ func (s *Service) AllocateCardsPreview(ctx context.Context, enterpriseID uint, r
|
|||||||
for _, iccid := range req.ICCIDs {
|
for _, iccid := range req.ICCIDs {
|
||||||
card, exists := cardMap[iccid]
|
card, exists := cardMap[iccid]
|
||||||
if !exists {
|
if !exists {
|
||||||
resp.FailedItems = append(resp.FailedItems, model.FailedItem{
|
resp.FailedItems = append(resp.FailedItems, dto.FailedItem{
|
||||||
ICCID: iccid,
|
ICCID: iccid,
|
||||||
Reason: "卡不存在",
|
Reason: "卡不存在",
|
||||||
})
|
})
|
||||||
@@ -104,7 +105,7 @@ func (s *Service) AllocateCardsPreview(ctx context.Context, enterpriseID uint, r
|
|||||||
|
|
||||||
deviceID, hasDevice := cardToDevice[card.ID]
|
deviceID, hasDevice := cardToDevice[card.ID]
|
||||||
if !hasDevice {
|
if !hasDevice {
|
||||||
resp.StandaloneCards = append(resp.StandaloneCards, model.StandaloneCard{
|
resp.StandaloneCards = append(resp.StandaloneCards, dto.StandaloneCard{
|
||||||
ICCID: card.ICCID,
|
ICCID: card.ICCID,
|
||||||
IotCardID: card.ID,
|
IotCardID: card.ID,
|
||||||
MSISDN: card.MSISDN,
|
MSISDN: card.MSISDN,
|
||||||
@@ -123,10 +124,10 @@ func (s *Service) AllocateCardsPreview(ctx context.Context, enterpriseID uint, r
|
|||||||
}
|
}
|
||||||
|
|
||||||
bundleCardIDs := deviceCards[deviceID]
|
bundleCardIDs := deviceCards[deviceID]
|
||||||
bundle := model.DeviceBundle{
|
bundle := dto.DeviceBundle{
|
||||||
DeviceID: deviceID,
|
DeviceID: deviceID,
|
||||||
DeviceNo: device.DeviceNo,
|
DeviceNo: device.DeviceNo,
|
||||||
BundleCards: make([]model.DeviceBundleCard, 0),
|
BundleCards: make([]dto.DeviceBundleCard, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, bundleCardID := range bundleCardIDs {
|
for _, bundleCardID := range bundleCardIDs {
|
||||||
@@ -135,13 +136,13 @@ func (s *Service) AllocateCardsPreview(ctx context.Context, enterpriseID uint, r
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if bundleCard.ID == card.ID {
|
if bundleCard.ID == card.ID {
|
||||||
bundle.TriggerCard = model.DeviceBundleCard{
|
bundle.TriggerCard = dto.DeviceBundleCard{
|
||||||
ICCID: bundleCard.ICCID,
|
ICCID: bundleCard.ICCID,
|
||||||
IotCardID: bundleCard.ID,
|
IotCardID: bundleCard.ID,
|
||||||
MSISDN: bundleCard.MSISDN,
|
MSISDN: bundleCard.MSISDN,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bundle.BundleCards = append(bundle.BundleCards, model.DeviceBundleCard{
|
bundle.BundleCards = append(bundle.BundleCards, dto.DeviceBundleCard{
|
||||||
ICCID: bundleCard.ICCID,
|
ICCID: bundleCard.ICCID,
|
||||||
IotCardID: bundleCard.ID,
|
IotCardID: bundleCard.ID,
|
||||||
MSISDN: bundleCard.MSISDN,
|
MSISDN: bundleCard.MSISDN,
|
||||||
@@ -158,7 +159,7 @@ func (s *Service) AllocateCardsPreview(ctx context.Context, enterpriseID uint, r
|
|||||||
deviceCardCount += 1 + len(bundle.BundleCards)
|
deviceCardCount += 1 + len(bundle.BundleCards)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.Summary = model.AllocatePreviewSummary{
|
resp.Summary = dto.AllocatePreviewSummary{
|
||||||
StandaloneCardCount: len(resp.StandaloneCards),
|
StandaloneCardCount: len(resp.StandaloneCards),
|
||||||
DeviceCount: len(resp.DeviceBundles),
|
DeviceCount: len(resp.DeviceBundles),
|
||||||
DeviceCardCount: deviceCardCount,
|
DeviceCardCount: deviceCardCount,
|
||||||
@@ -169,7 +170,7 @@ func (s *Service) AllocateCardsPreview(ctx context.Context, enterpriseID uint, r
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) AllocateCards(ctx context.Context, enterpriseID uint, req *model.AllocateCardsReq) (*model.AllocateCardsResp, error) {
|
func (s *Service) AllocateCards(ctx context.Context, enterpriseID uint, req *dto.AllocateCardsReq) (*dto.AllocateCardsResp, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
currentShopID := middleware.GetShopIDFromContext(ctx)
|
currentShopID := middleware.GetShopIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
@@ -181,7 +182,7 @@ func (s *Service) AllocateCards(ctx context.Context, enterpriseID uint, req *mod
|
|||||||
return nil, errors.New(errors.CodeEnterpriseNotFound, "企业不存在")
|
return nil, errors.New(errors.CodeEnterpriseNotFound, "企业不存在")
|
||||||
}
|
}
|
||||||
|
|
||||||
preview, err := s.AllocateCardsPreview(ctx, enterpriseID, &model.AllocateCardsPreviewReq{ICCIDs: req.ICCIDs})
|
preview, err := s.AllocateCardsPreview(ctx, enterpriseID, &dto.AllocateCardsPreviewReq{ICCIDs: req.ICCIDs})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -190,10 +191,10 @@ func (s *Service) AllocateCards(ctx context.Context, enterpriseID uint, req *mod
|
|||||||
return nil, errors.New(errors.CodeInvalidParam, "存在设备包,请确认整体授权设备下所有卡")
|
return nil, errors.New(errors.CodeInvalidParam, "存在设备包,请确认整体授权设备下所有卡")
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &model.AllocateCardsResp{
|
resp := &dto.AllocateCardsResp{
|
||||||
FailedItems: preview.FailedItems,
|
FailedItems: preview.FailedItems,
|
||||||
FailCount: len(preview.FailedItems),
|
FailCount: len(preview.FailedItems),
|
||||||
AllocatedDevices: make([]model.AllocatedDevice, 0),
|
AllocatedDevices: make([]dto.AllocatedDevice, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
cardIDsToAllocate := make([]uint, 0)
|
cardIDsToAllocate := make([]uint, 0)
|
||||||
@@ -209,7 +210,7 @@ func (s *Service) AllocateCards(ctx context.Context, enterpriseID uint, req *mod
|
|||||||
for _, card := range bundle.BundleCards {
|
for _, card := range bundle.BundleCards {
|
||||||
iccids = append(iccids, card.ICCID)
|
iccids = append(iccids, card.ICCID)
|
||||||
}
|
}
|
||||||
resp.AllocatedDevices = append(resp.AllocatedDevices, model.AllocatedDevice{
|
resp.AllocatedDevices = append(resp.AllocatedDevices, dto.AllocatedDevice{
|
||||||
DeviceID: bundle.DeviceID,
|
DeviceID: bundle.DeviceID,
|
||||||
DeviceNo: bundle.DeviceNo,
|
DeviceNo: bundle.DeviceNo,
|
||||||
CardCount: 1 + len(bundle.BundleCards),
|
CardCount: 1 + len(bundle.BundleCards),
|
||||||
@@ -248,7 +249,7 @@ func (s *Service) AllocateCards(ctx context.Context, enterpriseID uint, req *mod
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) RecallCards(ctx context.Context, enterpriseID uint, req *model.RecallCardsReq) (*model.RecallCardsResp, error) {
|
func (s *Service) RecallCards(ctx context.Context, enterpriseID uint, req *dto.RecallCardsReq) (*dto.RecallCardsResp, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -278,23 +279,23 @@ func (s *Service) RecallCards(ctx context.Context, enterpriseID uint, req *model
|
|||||||
return nil, fmt.Errorf("查询已有授权失败: %w", err)
|
return nil, fmt.Errorf("查询已有授权失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &model.RecallCardsResp{
|
resp := &dto.RecallCardsResp{
|
||||||
FailedItems: make([]model.FailedItem, 0),
|
FailedItems: make([]dto.FailedItem, 0),
|
||||||
RecalledDevices: make([]model.RecalledDevice, 0),
|
RecalledDevices: make([]dto.RecalledDevice, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
cardIDsToRecall := make([]uint, 0)
|
cardIDsToRecall := make([]uint, 0)
|
||||||
for _, iccid := range req.ICCIDs {
|
for _, iccid := range req.ICCIDs {
|
||||||
card, exists := cardMap[iccid]
|
card, exists := cardMap[iccid]
|
||||||
if !exists {
|
if !exists {
|
||||||
resp.FailedItems = append(resp.FailedItems, model.FailedItem{
|
resp.FailedItems = append(resp.FailedItems, dto.FailedItem{
|
||||||
ICCID: iccid,
|
ICCID: iccid,
|
||||||
Reason: "卡不存在",
|
Reason: "卡不存在",
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !existingAuths[card.ID] {
|
if !existingAuths[card.ID] {
|
||||||
resp.FailedItems = append(resp.FailedItems, model.FailedItem{
|
resp.FailedItems = append(resp.FailedItems, dto.FailedItem{
|
||||||
ICCID: iccid,
|
ICCID: iccid,
|
||||||
Reason: "该卡未授权给此企业",
|
Reason: "该卡未授权给此企业",
|
||||||
})
|
})
|
||||||
@@ -314,7 +315,7 @@ func (s *Service) RecallCards(ctx context.Context, enterpriseID uint, req *model
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) ListCards(ctx context.Context, enterpriseID uint, req *model.EnterpriseCardListReq) (*model.EnterpriseCardPageResult, error) {
|
func (s *Service) ListCards(ctx context.Context, enterpriseID uint, req *dto.EnterpriseCardListReq) (*dto.EnterpriseCardPageResult, error) {
|
||||||
_, err := s.enterpriseStore.GetByID(ctx, enterpriseID)
|
_, err := s.enterpriseStore.GetByID(ctx, enterpriseID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(errors.CodeEnterpriseNotFound, "企业不存在")
|
return nil, errors.New(errors.CodeEnterpriseNotFound, "企业不存在")
|
||||||
@@ -326,8 +327,8 @@ func (s *Service) ListCards(ctx context.Context, enterpriseID uint, req *model.E
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(cardIDs) == 0 {
|
if len(cardIDs) == 0 {
|
||||||
return &model.EnterpriseCardPageResult{
|
return &dto.EnterpriseCardPageResult{
|
||||||
Items: make([]model.EnterpriseCardItem, 0),
|
Items: make([]dto.EnterpriseCardItem, 0),
|
||||||
Total: 0,
|
Total: 0,
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
Size: req.PageSize,
|
Size: req.PageSize,
|
||||||
@@ -366,9 +367,9 @@ func (s *Service) ListCards(ctx context.Context, enterpriseID uint, req *model.E
|
|||||||
return nil, fmt.Errorf("查询卡列表失败: %w", err)
|
return nil, fmt.Errorf("查询卡列表失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]model.EnterpriseCardItem, 0, len(cards))
|
items := make([]dto.EnterpriseCardItem, 0, len(cards))
|
||||||
for _, card := range cards {
|
for _, card := range cards {
|
||||||
items = append(items, model.EnterpriseCardItem{
|
items = append(items, dto.EnterpriseCardItem{
|
||||||
ID: card.ID,
|
ID: card.ID,
|
||||||
ICCID: card.ICCID,
|
ICCID: card.ICCID,
|
||||||
MSISDN: card.MSISDN,
|
MSISDN: card.MSISDN,
|
||||||
@@ -380,7 +381,7 @@ func (s *Service) ListCards(ctx context.Context, enterpriseID uint, req *model.E
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.EnterpriseCardPageResult{
|
return &dto.EnterpriseCardPageResult{
|
||||||
Items: items,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: page,
|
Page: page,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||||
@@ -46,7 +47,7 @@ func New(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetCommissionSummary 获取我的佣金概览
|
// 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)
|
userType := middleware.GetUserTypeFromContext(ctx)
|
||||||
if userType != constants.UserTypeAgent {
|
if userType != constants.UserTypeAgent {
|
||||||
return nil, errors.New(errors.CodeForbidden, "仅代理商用户可访问")
|
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)
|
wallet, err := s.walletStore.GetShopCommissionWallet(ctx, shopID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// 钱包不存在时返回空数据
|
// 钱包不存在时返回空数据
|
||||||
return &model.MyCommissionSummaryResp{
|
return &dto.MyCommissionSummaryResp{
|
||||||
ShopID: shopID,
|
ShopID: shopID,
|
||||||
ShopName: shop.ShopName,
|
ShopName: shop.ShopName,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -82,7 +83,7 @@ func (s *Service) GetCommissionSummary(ctx context.Context) (*model.MyCommission
|
|||||||
|
|
||||||
totalCommission := wallet.Balance + wallet.FrozenBalance + totalWithdrawn
|
totalCommission := wallet.Balance + wallet.FrozenBalance + totalWithdrawn
|
||||||
|
|
||||||
return &model.MyCommissionSummaryResp{
|
return &dto.MyCommissionSummaryResp{
|
||||||
ShopID: shopID,
|
ShopID: shopID,
|
||||||
ShopName: shop.ShopName,
|
ShopName: shop.ShopName,
|
||||||
TotalCommission: totalCommission,
|
TotalCommission: totalCommission,
|
||||||
@@ -95,7 +96,7 @@ func (s *Service) GetCommissionSummary(ctx context.Context) (*model.MyCommission
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateWithdrawalRequest 发起提现申请
|
// 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)
|
userType := middleware.GetUserTypeFromContext(ctx)
|
||||||
if userType != constants.UserTypeAgent {
|
if userType != constants.UserTypeAgent {
|
||||||
return nil, errors.New(errors.CodeForbidden, "仅代理商用户可访问")
|
return nil, errors.New(errors.CodeForbidden, "仅代理商用户可访问")
|
||||||
@@ -216,7 +217,7 @@ func (s *Service) CreateWithdrawalRequest(ctx context.Context, req *model.Create
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.CreateMyWithdrawalResp{
|
return &dto.CreateMyWithdrawalResp{
|
||||||
ID: withdrawalRequest.ID,
|
ID: withdrawalRequest.ID,
|
||||||
WithdrawalNo: withdrawalRequest.WithdrawalNo,
|
WithdrawalNo: withdrawalRequest.WithdrawalNo,
|
||||||
Amount: withdrawalRequest.Amount,
|
Amount: withdrawalRequest.Amount,
|
||||||
@@ -230,7 +231,7 @@ func (s *Service) CreateWithdrawalRequest(ctx context.Context, req *model.Create
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListMyWithdrawalRequests 查询我的提现记录
|
// 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)
|
userType := middleware.GetUserTypeFromContext(ctx)
|
||||||
if userType != constants.UserTypeAgent {
|
if userType != constants.UserTypeAgent {
|
||||||
return nil, errors.New(errors.CodeForbidden, "仅代理商用户可访问")
|
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)
|
return nil, fmt.Errorf("查询提现记录失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]model.WithdrawalRequestItem, 0, len(requests))
|
items := make([]dto.WithdrawalRequestItem, 0, len(requests))
|
||||||
for _, r := range requests {
|
for _, r := range requests {
|
||||||
// 解析账户信息
|
// 解析账户信息
|
||||||
accountName, accountNumber := parseAccountInfo(r.AccountInfo)
|
accountName, accountNumber := parseAccountInfo(r.AccountInfo)
|
||||||
|
|
||||||
items = append(items, model.WithdrawalRequestItem{
|
items = append(items, dto.WithdrawalRequestItem{
|
||||||
ID: r.ID,
|
ID: r.ID,
|
||||||
WithdrawalNo: r.WithdrawalNo,
|
WithdrawalNo: r.WithdrawalNo,
|
||||||
ShopID: r.ShopID,
|
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,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: page,
|
Page: page,
|
||||||
@@ -305,7 +306,7 @@ func (s *Service) ListMyWithdrawalRequests(ctx context.Context, req *model.MyWit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListMyCommissionRecords 查询我的佣金明细
|
// 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)
|
userType := middleware.GetUserTypeFromContext(ctx)
|
||||||
if userType != constants.UserTypeAgent {
|
if userType != constants.UserTypeAgent {
|
||||||
return nil, errors.New(errors.CodeForbidden, "仅代理商用户可访问")
|
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)
|
return nil, fmt.Errorf("查询佣金记录失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]model.MyCommissionRecordItem, 0, len(records))
|
items := make([]dto.MyCommissionRecordItem, 0, len(records))
|
||||||
for _, r := range records {
|
for _, r := range records {
|
||||||
items = append(items, model.MyCommissionRecordItem{
|
items = append(items, dto.MyCommissionRecordItem{
|
||||||
ID: r.ID,
|
ID: r.ID,
|
||||||
ShopID: r.ShopID,
|
ShopID: r.ShopID,
|
||||||
OrderID: r.OrderID,
|
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,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: page,
|
Page: page,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -46,7 +47,7 @@ func New(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create 创建权限
|
// Create 创建权限
|
||||||
func (s *Service) Create(ctx context.Context, req *model.CreatePermissionRequest) (*model.Permission, error) {
|
func (s *Service) Create(ctx context.Context, req *dto.CreatePermissionRequest) (*model.Permission, error) {
|
||||||
// 获取当前用户 ID
|
// 获取当前用户 ID
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
@@ -109,7 +110,7 @@ func (s *Service) Get(ctx context.Context, id uint) (*model.Permission, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update 更新权限
|
// Update 更新权限
|
||||||
func (s *Service) Update(ctx context.Context, id uint, req *model.UpdatePermissionRequest) (*model.Permission, error) {
|
func (s *Service) Update(ctx context.Context, id uint, req *dto.UpdatePermissionRequest) (*model.Permission, error) {
|
||||||
// 获取当前用户 ID
|
// 获取当前用户 ID
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
@@ -190,7 +191,7 @@ func (s *Service) Delete(ctx context.Context, id uint) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List 查询权限列表
|
// List 查询权限列表
|
||||||
func (s *Service) List(ctx context.Context, req *model.PermissionListRequest) ([]*model.Permission, int64, error) {
|
func (s *Service) List(ctx context.Context, req *dto.PermissionListRequest) ([]*model.Permission, int64, error) {
|
||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
@@ -230,7 +231,7 @@ func (s *Service) List(ctx context.Context, req *model.PermissionListRequest) ([
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetTree 获取权限树
|
// GetTree 获取权限树
|
||||||
func (s *Service) GetTree(ctx context.Context, availableForRoleType *int) ([]*model.PermissionTreeNode, error) {
|
func (s *Service) GetTree(ctx context.Context, availableForRoleType *int) ([]*dto.PermissionTreeNode, error) {
|
||||||
permissions, err := s.permissionStore.GetAll(ctx, availableForRoleType)
|
permissions, err := s.permissionStore.GetAll(ctx, availableForRoleType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("获取权限列表失败: %w", err)
|
return nil, fmt.Errorf("获取权限列表失败: %w", err)
|
||||||
@@ -240,10 +241,10 @@ func (s *Service) GetTree(ctx context.Context, availableForRoleType *int) ([]*mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// buildPermissionTree 构建权限树
|
// buildPermissionTree 构建权限树
|
||||||
func buildPermissionTree(permissions []*model.Permission) []*model.PermissionTreeNode {
|
func buildPermissionTree(permissions []*model.Permission) []*dto.PermissionTreeNode {
|
||||||
nodeMap := make(map[uint]*model.PermissionTreeNode)
|
nodeMap := make(map[uint]*dto.PermissionTreeNode)
|
||||||
for _, p := range permissions {
|
for _, p := range permissions {
|
||||||
nodeMap[p.ID] = &model.PermissionTreeNode{
|
nodeMap[p.ID] = &dto.PermissionTreeNode{
|
||||||
ID: p.ID,
|
ID: p.ID,
|
||||||
PermName: p.PermName,
|
PermName: p.PermName,
|
||||||
PermCode: p.PermCode,
|
PermCode: p.PermCode,
|
||||||
@@ -252,11 +253,11 @@ func buildPermissionTree(permissions []*model.Permission) []*model.PermissionTre
|
|||||||
AvailableForRoleTypes: p.AvailableForRoleTypes,
|
AvailableForRoleTypes: p.AvailableForRoleTypes,
|
||||||
URL: p.URL,
|
URL: p.URL,
|
||||||
Sort: p.Sort,
|
Sort: p.Sort,
|
||||||
Children: make([]*model.PermissionTreeNode, 0),
|
Children: make([]*dto.PermissionTreeNode, 0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var roots []*model.PermissionTreeNode
|
var roots []*dto.PermissionTreeNode
|
||||||
for _, p := range permissions {
|
for _, p := range permissions {
|
||||||
node := nodeMap[p.ID]
|
node := nodeMap[p.ID]
|
||||||
if p.ParentID == nil || *p.ParentID == 0 {
|
if p.ParentID == nil || *p.ParentID == 0 {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -33,7 +34,7 @@ func New(roleStore *postgres.RoleStore, permissionStore *postgres.PermissionStor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create 创建角色
|
// Create 创建角色
|
||||||
func (s *Service) Create(ctx context.Context, req *model.CreateRoleRequest) (*model.Role, error) {
|
func (s *Service) Create(ctx context.Context, req *dto.CreateRoleRequest) (*model.Role, error) {
|
||||||
// 获取当前用户 ID
|
// 获取当前用户 ID
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
@@ -68,7 +69,7 @@ func (s *Service) Get(ctx context.Context, id uint) (*model.Role, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update 更新角色
|
// Update 更新角色
|
||||||
func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateRoleRequest) (*model.Role, error) {
|
func (s *Service) Update(ctx context.Context, id uint, req *dto.UpdateRoleRequest) (*model.Role, error) {
|
||||||
// 获取当前用户 ID
|
// 获取当前用户 ID
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
@@ -123,7 +124,7 @@ func (s *Service) Delete(ctx context.Context, id uint) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List 查询角色列表
|
// List 查询角色列表
|
||||||
func (s *Service) List(ctx context.Context, req *model.RoleListRequest) ([]*model.Role, int64, error) {
|
func (s *Service) List(ctx context.Context, req *dto.RoleListRequest) ([]*model.Role, int64, error) {
|
||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -26,7 +27,7 @@ func New(shopStore *postgres.ShopStore, accountStore *postgres.AccountStore) *Se
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Create(ctx context.Context, req *model.CreateShopRequest) (*model.ShopResponse, error) {
|
func (s *Service) Create(ctx context.Context, req *dto.CreateShopRequest) (*dto.ShopResponse, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -99,7 +100,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreateShopRequest) (*mo
|
|||||||
return nil, fmt.Errorf("创建初始账号失败: %w", err)
|
return nil, fmt.Errorf("创建初始账号失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.ShopResponse{
|
return &dto.ShopResponse{
|
||||||
ID: shop.ID,
|
ID: shop.ID,
|
||||||
ShopName: shop.ShopName,
|
ShopName: shop.ShopName,
|
||||||
ShopCode: shop.ShopCode,
|
ShopCode: shop.ShopCode,
|
||||||
@@ -117,7 +118,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreateShopRequest) (*mo
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateShopRequest) (*model.ShopResponse, error) {
|
func (s *Service) Update(ctx context.Context, id uint, req *dto.UpdateShopRequest) (*dto.ShopResponse, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -142,7 +143,7 @@ func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateShopRequ
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.ShopResponse{
|
return &dto.ShopResponse{
|
||||||
ID: shop.ID,
|
ID: shop.ID,
|
||||||
ShopName: shop.ShopName,
|
ShopName: shop.ShopName,
|
||||||
ShopCode: shop.ShopCode,
|
ShopCode: shop.ShopCode,
|
||||||
@@ -211,7 +212,7 @@ func (s *Service) GetByID(ctx context.Context, id uint) (*model.Shop, error) {
|
|||||||
return shop, nil
|
return shop, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) ListShopResponses(ctx context.Context, req *model.ShopListRequest) ([]*model.ShopResponse, int64, error) {
|
func (s *Service) ListShopResponses(ctx context.Context, req *dto.ShopListRequest) ([]*dto.ShopResponse, int64, error) {
|
||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
@@ -246,9 +247,9 @@ func (s *Service) ListShopResponses(ctx context.Context, req *model.ShopListRequ
|
|||||||
return nil, 0, fmt.Errorf("查询店铺列表失败: %w", err)
|
return nil, 0, fmt.Errorf("查询店铺列表失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
responses := make([]*model.ShopResponse, 0, len(shops))
|
responses := make([]*dto.ShopResponse, 0, len(shops))
|
||||||
for _, shop := range shops {
|
for _, shop := range shops {
|
||||||
responses = append(responses, &model.ShopResponse{
|
responses = append(responses, &dto.ShopResponse{
|
||||||
ID: shop.ID,
|
ID: shop.ID,
|
||||||
ShopName: shop.ShopName,
|
ShopName: shop.ShopName,
|
||||||
ShopCode: shop.ShopCode,
|
ShopCode: shop.ShopCode,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -26,7 +27,7 @@ func New(accountStore *postgres.AccountStore, shopStore *postgres.ShopStore) *Se
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) List(ctx context.Context, req *model.ShopAccountListRequest) ([]*model.ShopAccountResponse, int64, error) {
|
func (s *Service) List(ctx context.Context, req *dto.ShopAccountListRequest) ([]*dto.ShopAccountResponse, int64, error) {
|
||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
@@ -78,9 +79,9 @@ func (s *Service) List(ctx context.Context, req *model.ShopAccountListRequest) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
responses := make([]*model.ShopAccountResponse, 0, len(accounts))
|
responses := make([]*dto.ShopAccountResponse, 0, len(accounts))
|
||||||
for _, account := range accounts {
|
for _, account := range accounts {
|
||||||
resp := &model.ShopAccountResponse{
|
resp := &dto.ShopAccountResponse{
|
||||||
ID: account.ID,
|
ID: account.ID,
|
||||||
Username: account.Username,
|
Username: account.Username,
|
||||||
Phone: account.Phone,
|
Phone: account.Phone,
|
||||||
@@ -101,7 +102,7 @@ func (s *Service) List(ctx context.Context, req *model.ShopAccountListRequest) (
|
|||||||
return responses, total, nil
|
return responses, total, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Create(ctx context.Context, req *model.CreateShopAccountRequest) (*model.ShopAccountResponse, error) {
|
func (s *Service) Create(ctx context.Context, req *dto.CreateShopAccountRequest) (*dto.ShopAccountResponse, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -145,7 +146,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreateShopAccountReques
|
|||||||
return nil, fmt.Errorf("创建代理商账号失败: %w", err)
|
return nil, fmt.Errorf("创建代理商账号失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.ShopAccountResponse{
|
return &dto.ShopAccountResponse{
|
||||||
ID: account.ID,
|
ID: account.ID,
|
||||||
ShopID: *account.ShopID,
|
ShopID: *account.ShopID,
|
||||||
ShopName: shop.ShopName,
|
ShopName: shop.ShopName,
|
||||||
@@ -158,7 +159,7 @@ func (s *Service) Create(ctx context.Context, req *model.CreateShopAccountReques
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateShopAccountRequest) (*model.ShopAccountResponse, error) {
|
func (s *Service) Update(ctx context.Context, id uint, req *dto.UpdateShopAccountRequest) (*dto.ShopAccountResponse, error) {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
return nil, errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -196,7 +197,7 @@ func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateShopAcco
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.ShopAccountResponse{
|
return &dto.ShopAccountResponse{
|
||||||
ID: account.ID,
|
ID: account.ID,
|
||||||
ShopID: *account.ShopID,
|
ShopID: *account.ShopID,
|
||||||
ShopName: shopName,
|
ShopName: shopName,
|
||||||
@@ -209,7 +210,7 @@ func (s *Service) Update(ctx context.Context, id uint, req *model.UpdateShopAcco
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) UpdatePassword(ctx context.Context, id uint, req *model.UpdateShopAccountPasswordRequest) error {
|
func (s *Service) UpdatePassword(ctx context.Context, id uint, req *dto.UpdateShopAccountPasswordRequest) error {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return errors.New(errors.CodeUnauthorized, "未授权访问")
|
return errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
@@ -239,7 +240,7 @@ func (s *Service) UpdatePassword(ctx context.Context, id uint, req *model.Update
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) UpdateStatus(ctx context.Context, id uint, req *model.UpdateShopAccountStatusRequest) error {
|
func (s *Service) UpdateStatus(ctx context.Context, id uint, req *dto.UpdateShopAccountStatusRequest) error {
|
||||||
currentUserID := middleware.GetUserIDFromContext(ctx)
|
currentUserID := middleware.GetUserIDFromContext(ctx)
|
||||||
if currentUserID == 0 {
|
if currentUserID == 0 {
|
||||||
return errors.New(errors.CodeUnauthorized, "未授权访问")
|
return errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"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"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"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{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
@@ -61,8 +62,8 @@ func (s *Service) ListShopCommissionSummary(ctx context.Context, req *model.Shop
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(shops) == 0 {
|
if len(shops) == 0 {
|
||||||
return &model.ShopCommissionSummaryPageResult{
|
return &dto.ShopCommissionSummaryPageResult{
|
||||||
Items: []model.ShopCommissionSummaryItem{},
|
Items: []dto.ShopCommissionSummaryItem{},
|
||||||
Total: 0,
|
Total: 0,
|
||||||
Page: opts.Page,
|
Page: opts.Page,
|
||||||
Size: opts.PageSize,
|
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 {
|
for _, shop := range shops {
|
||||||
if req.Username != "" {
|
if req.Username != "" {
|
||||||
acc := accountMap[shop.ID]
|
acc := accountMap[shop.ID]
|
||||||
@@ -115,7 +116,7 @@ func (s *Service) ListShopCommissionSummary(ctx context.Context, req *model.Shop
|
|||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.ShopCommissionSummaryPageResult{
|
return &dto.ShopCommissionSummaryPageResult{
|
||||||
Items: items,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: opts.Page,
|
Page: opts.Page,
|
||||||
@@ -123,7 +124,7 @@ func (s *Service) ListShopCommissionSummary(ctx context.Context, req *model.Shop
|
|||||||
}, nil
|
}, 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
|
var balance, frozenBalance int64
|
||||||
if walletSummary != nil {
|
if walletSummary != nil {
|
||||||
balance = walletSummary.Balance
|
balance = walletSummary.Balance
|
||||||
@@ -143,7 +144,7 @@ func (s *Service) buildCommissionSummaryItem(shop *model.Shop, walletSummary *po
|
|||||||
phone = account.Phone
|
phone = account.Phone
|
||||||
}
|
}
|
||||||
|
|
||||||
return model.ShopCommissionSummaryItem{
|
return dto.ShopCommissionSummaryItem{
|
||||||
ShopID: shop.ID,
|
ShopID: shop.ID,
|
||||||
ShopName: shop.ShopName,
|
ShopName: shop.ShopName,
|
||||||
ShopCode: shop.ShopCode,
|
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)
|
_, err := s.shopStore.GetByID(ctx, shopID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(errors.CodeShopNotFound, "店铺不存在")
|
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 {
|
for _, r := range requests {
|
||||||
item := s.buildWithdrawalRequestItem(r, shop.ShopName, shopHierarchy, applicantMap, processorMap)
|
item := s.buildWithdrawalRequestItem(r, shop.ShopName, shopHierarchy, applicantMap, processorMap)
|
||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.ShopWithdrawalRequestPageResult{
|
return &dto.ShopWithdrawalRequestPageResult{
|
||||||
Items: items,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: opts.Page,
|
Page: opts.Page,
|
||||||
@@ -244,7 +245,7 @@ func (s *Service) ListShopWithdrawalRequests(ctx context.Context, shopID uint, r
|
|||||||
}, nil
|
}, 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
|
var processorID *uint
|
||||||
if r.ProcessorID > 0 {
|
if r.ProcessorID > 0 {
|
||||||
processorID = &r.ProcessorID
|
processorID = &r.ProcessorID
|
||||||
@@ -274,7 +275,7 @@ func (s *Service) buildWithdrawalRequestItem(r *model.CommissionWithdrawalReques
|
|||||||
paidAt = r.PaidAt.Format("2006-01-02 15:04:05")
|
paidAt = r.PaidAt.Format("2006-01-02 15:04:05")
|
||||||
}
|
}
|
||||||
|
|
||||||
return model.ShopWithdrawalRequestItem{
|
return dto.ShopWithdrawalRequestItem{
|
||||||
ID: r.ID,
|
ID: r.ID,
|
||||||
WithdrawalNo: r.WithdrawalNo,
|
WithdrawalNo: r.WithdrawalNo,
|
||||||
Amount: r.Amount,
|
Amount: r.Amount,
|
||||||
@@ -325,7 +326,7 @@ func (s *Service) buildShopHierarchyPath(ctx context.Context, shop *model.Shop)
|
|||||||
return path
|
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)
|
_, err := s.shopStore.GetByID(ctx, shopID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(errors.CodeShopNotFound, "店铺不存在")
|
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)
|
return nil, fmt.Errorf("查询佣金明细失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]model.ShopCommissionRecordItem, 0, len(records))
|
items := make([]dto.ShopCommissionRecordItem, 0, len(records))
|
||||||
for _, r := range records {
|
for _, r := range records {
|
||||||
item := model.ShopCommissionRecordItem{
|
item := dto.ShopCommissionRecordItem{
|
||||||
ID: r.ID,
|
ID: r.ID,
|
||||||
Amount: r.Amount,
|
Amount: r.Amount,
|
||||||
BalanceAfter: r.BalanceAfter,
|
BalanceAfter: r.BalanceAfter,
|
||||||
@@ -375,7 +376,7 @@ func (s *Service) ListShopCommissionRecords(ctx context.Context, shopID uint, re
|
|||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.ShopCommissionRecordPageResult{
|
return &dto.ShopCommissionRecordPageResult{
|
||||||
Items: items,
|
Items: items,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: opts.Page,
|
Page: opts.Page,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||||
accountService "github.com/break/junhong_cmp_fiber/internal/service/account"
|
accountService "github.com/break/junhong_cmp_fiber/internal/service/account"
|
||||||
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
@@ -183,7 +184,7 @@ func TestAccountAPI_Create(t *testing.T) {
|
|||||||
createTestAccount(t, env.db, rootAccount)
|
createTestAccount(t, env.db, rootAccount)
|
||||||
|
|
||||||
t.Run("成功创建平台账号", func(t *testing.T) {
|
t.Run("成功创建平台账号", func(t *testing.T) {
|
||||||
reqBody := model.CreateAccountRequest{
|
reqBody := dto.CreateAccountRequest{
|
||||||
Username: "platform_user",
|
Username: "platform_user",
|
||||||
Phone: "13800000001",
|
Phone: "13800000001",
|
||||||
Password: "Password123",
|
Password: "Password123",
|
||||||
@@ -221,7 +222,7 @@ func TestAccountAPI_Create(t *testing.T) {
|
|||||||
createTestAccount(t, env.db, existingAccount)
|
createTestAccount(t, env.db, existingAccount)
|
||||||
|
|
||||||
// 尝试创建同名账号
|
// 尝试创建同名账号
|
||||||
reqBody := model.CreateAccountRequest{
|
reqBody := dto.CreateAccountRequest{
|
||||||
Username: "existing_user",
|
Username: "existing_user",
|
||||||
Phone: "13800000003",
|
Phone: "13800000003",
|
||||||
Password: "Password123",
|
Password: "Password123",
|
||||||
@@ -242,7 +243,7 @@ func TestAccountAPI_Create(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("非root用户缺少parent_id时返回错误", func(t *testing.T) {
|
t.Run("非root用户缺少parent_id时返回错误", func(t *testing.T) {
|
||||||
reqBody := model.CreateAccountRequest{
|
reqBody := dto.CreateAccountRequest{
|
||||||
Username: "no_parent_user",
|
Username: "no_parent_user",
|
||||||
Phone: "13800000004",
|
Phone: "13800000004",
|
||||||
Password: "Password123",
|
Password: "Password123",
|
||||||
@@ -347,7 +348,7 @@ func TestAccountAPI_Update(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("成功更新账号", func(t *testing.T) {
|
t.Run("成功更新账号", func(t *testing.T) {
|
||||||
newUsername := "updated_user"
|
newUsername := "updated_user"
|
||||||
reqBody := model.UpdateAccountRequest{
|
reqBody := dto.UpdateAccountRequest{
|
||||||
Username: &newUsername,
|
Username: &newUsername,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,7 +481,7 @@ func TestAccountAPI_AssignRoles(t *testing.T) {
|
|||||||
env.db.Create(testRole)
|
env.db.Create(testRole)
|
||||||
|
|
||||||
t.Run("成功分配角色", func(t *testing.T) {
|
t.Run("成功分配角色", func(t *testing.T) {
|
||||||
reqBody := model.AssignRolesRequest{
|
reqBody := dto.AssignRolesRequest{
|
||||||
RoleIDs: []uint{testRole.ID},
|
RoleIDs: []uint{testRole.ID},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||||
permissionService "github.com/break/junhong_cmp_fiber/internal/service/permission"
|
permissionService "github.com/break/junhong_cmp_fiber/internal/service/permission"
|
||||||
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
@@ -148,7 +149,7 @@ func TestPermissionAPI_Create(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("成功创建权限", func(t *testing.T) {
|
t.Run("成功创建权限", func(t *testing.T) {
|
||||||
reqBody := model.CreatePermissionRequest{
|
reqBody := dto.CreatePermissionRequest{
|
||||||
PermName: "用户管理",
|
PermName: "用户管理",
|
||||||
PermCode: "user:manage",
|
PermCode: "user:manage",
|
||||||
PermType: constants.PermissionTypeMenu,
|
PermType: constants.PermissionTypeMenu,
|
||||||
@@ -185,7 +186,7 @@ func TestPermissionAPI_Create(t *testing.T) {
|
|||||||
env.db.Create(existingPerm)
|
env.db.Create(existingPerm)
|
||||||
|
|
||||||
// 尝试创建相同编码的权限
|
// 尝试创建相同编码的权限
|
||||||
reqBody := model.CreatePermissionRequest{
|
reqBody := dto.CreatePermissionRequest{
|
||||||
PermName: "新权限",
|
PermName: "新权限",
|
||||||
PermCode: "existing:perm",
|
PermCode: "existing:perm",
|
||||||
PermType: constants.PermissionTypeMenu,
|
PermType: constants.PermissionTypeMenu,
|
||||||
@@ -215,7 +216,7 @@ func TestPermissionAPI_Create(t *testing.T) {
|
|||||||
env.db.Create(parentPerm)
|
env.db.Create(parentPerm)
|
||||||
|
|
||||||
// 创建子权限
|
// 创建子权限
|
||||||
reqBody := model.CreatePermissionRequest{
|
reqBody := dto.CreatePermissionRequest{
|
||||||
PermName: "用户列表",
|
PermName: "用户列表",
|
||||||
PermCode: "system:user:list",
|
PermCode: "system:user:list",
|
||||||
PermType: constants.PermissionTypeButton,
|
PermType: constants.PermissionTypeButton,
|
||||||
@@ -308,7 +309,7 @@ func TestPermissionAPI_Update(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("成功更新权限", func(t *testing.T) {
|
t.Run("成功更新权限", func(t *testing.T) {
|
||||||
newName := "更新后权限"
|
newName := "更新后权限"
|
||||||
reqBody := model.UpdatePermissionRequest{
|
reqBody := dto.UpdatePermissionRequest{
|
||||||
PermName: &newName,
|
PermName: &newName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||||
accountService "github.com/break/junhong_cmp_fiber/internal/service/account"
|
accountService "github.com/break/junhong_cmp_fiber/internal/service/account"
|
||||||
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
@@ -147,7 +148,7 @@ func TestPlatformAccountAPI_UpdatePassword(t *testing.T) {
|
|||||||
db.Create(testAccount)
|
db.Create(testAccount)
|
||||||
|
|
||||||
t.Run("成功修改密码", func(t *testing.T) {
|
t.Run("成功修改密码", func(t *testing.T) {
|
||||||
reqBody := model.UpdatePasswordRequest{
|
reqBody := dto.UpdatePasswordRequest{
|
||||||
NewPassword: "NewPassword@123",
|
NewPassword: "NewPassword@123",
|
||||||
}
|
}
|
||||||
jsonBody, _ := json.Marshal(reqBody)
|
jsonBody, _ := json.Marshal(reqBody)
|
||||||
@@ -169,7 +170,7 @@ func TestPlatformAccountAPI_UpdatePassword(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("账号不存在返回错误", func(t *testing.T) {
|
t.Run("账号不存在返回错误", func(t *testing.T) {
|
||||||
reqBody := model.UpdatePasswordRequest{
|
reqBody := dto.UpdatePasswordRequest{
|
||||||
NewPassword: "NewPassword@123",
|
NewPassword: "NewPassword@123",
|
||||||
}
|
}
|
||||||
jsonBody, _ := json.Marshal(reqBody)
|
jsonBody, _ := json.Marshal(reqBody)
|
||||||
@@ -221,7 +222,7 @@ func TestPlatformAccountAPI_UpdateStatus(t *testing.T) {
|
|||||||
db.Create(testAccount)
|
db.Create(testAccount)
|
||||||
|
|
||||||
t.Run("成功禁用账号", func(t *testing.T) {
|
t.Run("成功禁用账号", func(t *testing.T) {
|
||||||
reqBody := model.UpdateStatusRequest{
|
reqBody := dto.UpdateStatusRequest{
|
||||||
Status: constants.StatusDisabled,
|
Status: constants.StatusDisabled,
|
||||||
}
|
}
|
||||||
jsonBody, _ := json.Marshal(reqBody)
|
jsonBody, _ := json.Marshal(reqBody)
|
||||||
@@ -238,7 +239,7 @@ func TestPlatformAccountAPI_UpdateStatus(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("成功启用账号", func(t *testing.T) {
|
t.Run("成功启用账号", func(t *testing.T) {
|
||||||
reqBody := model.UpdateStatusRequest{
|
reqBody := dto.UpdateStatusRequest{
|
||||||
Status: constants.StatusEnabled,
|
Status: constants.StatusEnabled,
|
||||||
}
|
}
|
||||||
jsonBody, _ := json.Marshal(reqBody)
|
jsonBody, _ := json.Marshal(reqBody)
|
||||||
@@ -306,7 +307,7 @@ func TestPlatformAccountAPI_AssignRoles(t *testing.T) {
|
|||||||
db.Create(testRole)
|
db.Create(testRole)
|
||||||
|
|
||||||
t.Run("超级管理员禁止分配角色", func(t *testing.T) {
|
t.Run("超级管理员禁止分配角色", func(t *testing.T) {
|
||||||
reqBody := model.AssignRolesRequest{
|
reqBody := dto.AssignRolesRequest{
|
||||||
RoleIDs: []uint{testRole.ID},
|
RoleIDs: []uint{testRole.ID},
|
||||||
}
|
}
|
||||||
jsonBody, _ := json.Marshal(reqBody)
|
jsonBody, _ := json.Marshal(reqBody)
|
||||||
@@ -324,7 +325,7 @@ func TestPlatformAccountAPI_AssignRoles(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("平台用户成功分配角色", func(t *testing.T) {
|
t.Run("平台用户成功分配角色", func(t *testing.T) {
|
||||||
reqBody := model.AssignRolesRequest{
|
reqBody := dto.AssignRolesRequest{
|
||||||
RoleIDs: []uint{testRole.ID},
|
RoleIDs: []uint{testRole.ID},
|
||||||
}
|
}
|
||||||
jsonBody, _ := json.Marshal(reqBody)
|
jsonBody, _ := json.Marshal(reqBody)
|
||||||
@@ -341,7 +342,7 @@ func TestPlatformAccountAPI_AssignRoles(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("空数组清空所有角色", func(t *testing.T) {
|
t.Run("空数组清空所有角色", func(t *testing.T) {
|
||||||
reqBody := model.AssignRolesRequest{
|
reqBody := dto.AssignRolesRequest{
|
||||||
RoleIDs: []uint{},
|
RoleIDs: []uint{},
|
||||||
}
|
}
|
||||||
jsonBody, _ := json.Marshal(reqBody)
|
jsonBody, _ := json.Marshal(reqBody)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
"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"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||||
roleService "github.com/break/junhong_cmp_fiber/internal/service/role"
|
roleService "github.com/break/junhong_cmp_fiber/internal/service/role"
|
||||||
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
@@ -165,7 +166,7 @@ func TestRoleAPI_Create(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("成功创建角色", func(t *testing.T) {
|
t.Run("成功创建角色", func(t *testing.T) {
|
||||||
reqBody := model.CreateRoleRequest{
|
reqBody := dto.CreateRoleRequest{
|
||||||
RoleName: "测试角色",
|
RoleName: "测试角色",
|
||||||
RoleDesc: "这是一个测试角色",
|
RoleDesc: "这是一个测试角色",
|
||||||
RoleType: constants.RoleTypePlatform,
|
RoleType: constants.RoleTypePlatform,
|
||||||
@@ -277,7 +278,7 @@ func TestRoleAPI_Update(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("成功更新角色", func(t *testing.T) {
|
t.Run("成功更新角色", func(t *testing.T) {
|
||||||
newName := "更新后角色"
|
newName := "更新后角色"
|
||||||
reqBody := model.UpdateRoleRequest{
|
reqBody := dto.UpdateRoleRequest{
|
||||||
RoleName: &newName,
|
RoleName: &newName,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +399,7 @@ func TestRoleAPI_AssignPermissions(t *testing.T) {
|
|||||||
env.db.Create(testPerm)
|
env.db.Create(testPerm)
|
||||||
|
|
||||||
t.Run("成功分配权限", func(t *testing.T) {
|
t.Run("成功分配权限", func(t *testing.T) {
|
||||||
reqBody := model.AssignPermissionsRequest{
|
reqBody := dto.AssignPermissionsRequest{
|
||||||
PermIDs: []uint{testPerm.ID},
|
PermIDs: []uint{testPerm.ID},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,7 +541,7 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
|||||||
env.db.Create(testRole)
|
env.db.Create(testRole)
|
||||||
|
|
||||||
t.Run("成功禁用角色", func(t *testing.T) {
|
t.Run("成功禁用角色", func(t *testing.T) {
|
||||||
reqBody := model.UpdateRoleStatusRequest{
|
reqBody := dto.UpdateRoleStatusRequest{
|
||||||
Status: constants.StatusDisabled,
|
Status: constants.StatusDisabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,7 +565,7 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("成功启用角色", func(t *testing.T) {
|
t.Run("成功启用角色", func(t *testing.T) {
|
||||||
reqBody := model.UpdateRoleStatusRequest{
|
reqBody := dto.UpdateRoleStatusRequest{
|
||||||
Status: constants.StatusEnabled,
|
Status: constants.StatusEnabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,7 +589,7 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("角色不存在返回错误", func(t *testing.T) {
|
t.Run("角色不存在返回错误", func(t *testing.T) {
|
||||||
reqBody := model.UpdateRoleStatusRequest{
|
reqBody := dto.UpdateRoleStatusRequest{
|
||||||
Status: constants.StatusEnabled,
|
Status: constants.StatusEnabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/auth"
|
"github.com/break/junhong_cmp_fiber/pkg/auth"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/config"
|
"github.com/break/junhong_cmp_fiber/pkg/config"
|
||||||
@@ -147,7 +148,7 @@ func TestShopAccount_CreateAccount(t *testing.T) {
|
|||||||
env := setupShopAccountTestEnv(t)
|
env := setupShopAccountTestEnv(t)
|
||||||
defer env.teardown()
|
defer env.teardown()
|
||||||
|
|
||||||
reqBody := model.CreateShopAccountRequest{
|
reqBody := dto.CreateShopAccountRequest{
|
||||||
ShopID: env.testShop.ID,
|
ShopID: env.testShop.ID,
|
||||||
Username: "agent001",
|
Username: "agent001",
|
||||||
Phone: "13800138001",
|
Phone: "13800138001",
|
||||||
@@ -193,7 +194,7 @@ func TestShopAccount_CreateAccount_InvalidShop(t *testing.T) {
|
|||||||
env := setupShopAccountTestEnv(t)
|
env := setupShopAccountTestEnv(t)
|
||||||
defer env.teardown()
|
defer env.teardown()
|
||||||
|
|
||||||
reqBody := model.CreateShopAccountRequest{
|
reqBody := dto.CreateShopAccountRequest{
|
||||||
ShopID: 99999, // 不存在的商户ID
|
ShopID: 99999, // 不存在的商户ID
|
||||||
Username: "agent002",
|
Username: "agent002",
|
||||||
Phone: "13800138002",
|
Phone: "13800138002",
|
||||||
@@ -262,7 +263,7 @@ func TestShopAccount_UpdateAccount(t *testing.T) {
|
|||||||
account := testutil.CreateAgentUser(t, env.db, env.testShop.ID)
|
account := testutil.CreateAgentUser(t, env.db, env.testShop.ID)
|
||||||
|
|
||||||
// 更新账号用户名
|
// 更新账号用户名
|
||||||
reqBody := model.UpdateShopAccountRequest{
|
reqBody := dto.UpdateShopAccountRequest{
|
||||||
Username: "updated_agent",
|
Username: "updated_agent",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +304,7 @@ func TestShopAccount_UpdatePassword(t *testing.T) {
|
|||||||
|
|
||||||
// 重置密码
|
// 重置密码
|
||||||
newPassword := "newpassword456"
|
newPassword := "newpassword456"
|
||||||
reqBody := model.UpdateShopAccountPasswordRequest{
|
reqBody := dto.UpdateShopAccountPasswordRequest{
|
||||||
NewPassword: newPassword,
|
NewPassword: newPassword,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +350,7 @@ func TestShopAccount_UpdateStatus(t *testing.T) {
|
|||||||
require.Equal(t, 1, account.Status)
|
require.Equal(t, 1, account.Status)
|
||||||
|
|
||||||
// 禁用账号
|
// 禁用账号
|
||||||
reqBody := model.UpdateShopAccountStatusRequest{
|
reqBody := dto.UpdateShopAccountStatusRequest{
|
||||||
Status: 2, // 禁用
|
Status: 2, // 禁用
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/auth"
|
"github.com/break/junhong_cmp_fiber/pkg/auth"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/config"
|
"github.com/break/junhong_cmp_fiber/pkg/config"
|
||||||
@@ -141,7 +142,7 @@ func TestShopManagement_CreateShop(t *testing.T) {
|
|||||||
env := setupShopManagementTestEnv(t)
|
env := setupShopManagementTestEnv(t)
|
||||||
defer env.teardown()
|
defer env.teardown()
|
||||||
|
|
||||||
reqBody := model.CreateShopRequest{
|
reqBody := dto.CreateShopRequest{
|
||||||
ShopName: "测试商户",
|
ShopName: "测试商户",
|
||||||
ShopCode: "TEST001",
|
ShopCode: "TEST001",
|
||||||
InitUsername: "testuser",
|
InitUsername: "testuser",
|
||||||
@@ -191,7 +192,7 @@ func TestShopManagement_CreateShop_DuplicateCode(t *testing.T) {
|
|||||||
defer env.teardown()
|
defer env.teardown()
|
||||||
|
|
||||||
// 通过 API 创建第一个商户
|
// 通过 API 创建第一个商户
|
||||||
firstReq := model.CreateShopRequest{
|
firstReq := dto.CreateShopRequest{
|
||||||
ShopName: "商户1",
|
ShopName: "商户1",
|
||||||
ShopCode: "DUP001",
|
ShopCode: "DUP001",
|
||||||
InitUsername: "dupuser1",
|
InitUsername: "dupuser1",
|
||||||
@@ -210,7 +211,7 @@ func TestShopManagement_CreateShop_DuplicateCode(t *testing.T) {
|
|||||||
require.Equal(t, 0, firstResult.Code, "第一个商户应该创建成功")
|
require.Equal(t, 0, firstResult.Code, "第一个商户应该创建成功")
|
||||||
|
|
||||||
// 尝试创建编码重复的商户
|
// 尝试创建编码重复的商户
|
||||||
reqBody := model.CreateShopRequest{
|
reqBody := dto.CreateShopRequest{
|
||||||
ShopName: "商户2",
|
ShopName: "商户2",
|
||||||
ShopCode: "DUP001", // 使用相同编码
|
ShopCode: "DUP001", // 使用相同编码
|
||||||
InitUsername: "dupuser2",
|
InitUsername: "dupuser2",
|
||||||
@@ -281,7 +282,7 @@ func TestShopManagement_UpdateShop(t *testing.T) {
|
|||||||
shop := testutil.CreateTestShop(t, env.db, "原始商户", "ORIG001", 1, nil)
|
shop := testutil.CreateTestShop(t, env.db, "原始商户", "ORIG001", 1, nil)
|
||||||
|
|
||||||
// 更新商户
|
// 更新商户
|
||||||
reqBody := model.UpdateShopRequest{
|
reqBody := dto.UpdateShopRequest{
|
||||||
ShopName: "更新后的商户",
|
ShopName: "更新后的商户",
|
||||||
Status: 1,
|
Status: 1,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal"
|
"github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -36,7 +36,7 @@ func TestCommissionWithdrawalService_ListWithdrawalRequests(t *testing.T) {
|
|||||||
t.Run("查询提现申请列表-空结果", func(t *testing.T) {
|
t.Run("查询提现申请列表-空结果", func(t *testing.T) {
|
||||||
ctx := createWithdrawalTestContext(1)
|
ctx := createWithdrawalTestContext(1)
|
||||||
|
|
||||||
req := &model.WithdrawalRequestListReq{
|
req := &dto.WithdrawalRequestListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ func TestCommissionWithdrawalService_ListWithdrawalRequests(t *testing.T) {
|
|||||||
ctx := createWithdrawalTestContext(1)
|
ctx := createWithdrawalTestContext(1)
|
||||||
|
|
||||||
status := 1
|
status := 1
|
||||||
req := &model.WithdrawalRequestListReq{
|
req := &dto.WithdrawalRequestListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
Status: &status,
|
Status: &status,
|
||||||
@@ -65,7 +65,7 @@ func TestCommissionWithdrawalService_ListWithdrawalRequests(t *testing.T) {
|
|||||||
t.Run("按时间范围筛选提现申请", func(t *testing.T) {
|
t.Run("按时间范围筛选提现申请", func(t *testing.T) {
|
||||||
ctx := createWithdrawalTestContext(1)
|
ctx := createWithdrawalTestContext(1)
|
||||||
|
|
||||||
req := &model.WithdrawalRequestListReq{
|
req := &dto.WithdrawalRequestListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
StartTime: "2025-01-01 00:00:00",
|
StartTime: "2025-01-01 00:00:00",
|
||||||
@@ -93,7 +93,7 @@ func TestCommissionWithdrawalService_Approve(t *testing.T) {
|
|||||||
t.Run("审批不存在的提现申请应失败", func(t *testing.T) {
|
t.Run("审批不存在的提现申请应失败", func(t *testing.T) {
|
||||||
ctx := createWithdrawalTestContext(1)
|
ctx := createWithdrawalTestContext(1)
|
||||||
|
|
||||||
req := &model.ApproveWithdrawalReq{
|
req := &dto.ApproveWithdrawalReq{
|
||||||
PaymentType: "manual",
|
PaymentType: "manual",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ func TestCommissionWithdrawalService_Reject(t *testing.T) {
|
|||||||
t.Run("拒绝不存在的提现申请应失败", func(t *testing.T) {
|
t.Run("拒绝不存在的提现申请应失败", func(t *testing.T) {
|
||||||
ctx := createWithdrawalTestContext(1)
|
ctx := createWithdrawalTestContext(1)
|
||||||
|
|
||||||
req := &model.RejectWithdrawalReq{
|
req := &dto.RejectWithdrawalReq{
|
||||||
Remark: "测试拒绝原因",
|
Remark: "测试拒绝原因",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal_setting"
|
"github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal_setting"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -33,7 +33,7 @@ func TestCommissionWithdrawalSettingService_Create(t *testing.T) {
|
|||||||
t.Run("新增提现配置", func(t *testing.T) {
|
t.Run("新增提现配置", func(t *testing.T) {
|
||||||
ctx := createWithdrawalSettingTestContext(1)
|
ctx := createWithdrawalSettingTestContext(1)
|
||||||
|
|
||||||
req := &model.CreateWithdrawalSettingReq{
|
req := &dto.CreateWithdrawalSettingReq{
|
||||||
DailyWithdrawalLimit: 5,
|
DailyWithdrawalLimit: 5,
|
||||||
MinWithdrawalAmount: 10000,
|
MinWithdrawalAmount: 10000,
|
||||||
FeeRate: 100,
|
FeeRate: 100,
|
||||||
@@ -51,7 +51,7 @@ func TestCommissionWithdrawalSettingService_Create(t *testing.T) {
|
|||||||
t.Run("未授权用户创建配置应失败", func(t *testing.T) {
|
t.Run("未授权用户创建配置应失败", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
req := &model.CreateWithdrawalSettingReq{
|
req := &dto.CreateWithdrawalSettingReq{
|
||||||
DailyWithdrawalLimit: 5,
|
DailyWithdrawalLimit: 5,
|
||||||
MinWithdrawalAmount: 10000,
|
MinWithdrawalAmount: 10000,
|
||||||
FeeRate: 100,
|
FeeRate: 100,
|
||||||
@@ -74,7 +74,7 @@ func TestCommissionWithdrawalSettingService_ConfigSwitch(t *testing.T) {
|
|||||||
t.Run("配置切换-旧配置自动失效", func(t *testing.T) {
|
t.Run("配置切换-旧配置自动失效", func(t *testing.T) {
|
||||||
ctx := createWithdrawalSettingTestContext(1)
|
ctx := createWithdrawalSettingTestContext(1)
|
||||||
|
|
||||||
req1 := &model.CreateWithdrawalSettingReq{
|
req1 := &dto.CreateWithdrawalSettingReq{
|
||||||
DailyWithdrawalLimit: 3,
|
DailyWithdrawalLimit: 3,
|
||||||
MinWithdrawalAmount: 5000,
|
MinWithdrawalAmount: 5000,
|
||||||
FeeRate: 50,
|
FeeRate: 50,
|
||||||
@@ -83,7 +83,7 @@ func TestCommissionWithdrawalSettingService_ConfigSwitch(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.True(t, result1.IsActive)
|
assert.True(t, result1.IsActive)
|
||||||
|
|
||||||
req2 := &model.CreateWithdrawalSettingReq{
|
req2 := &dto.CreateWithdrawalSettingReq{
|
||||||
DailyWithdrawalLimit: 10,
|
DailyWithdrawalLimit: 10,
|
||||||
MinWithdrawalAmount: 20000,
|
MinWithdrawalAmount: 20000,
|
||||||
FeeRate: 200,
|
FeeRate: 200,
|
||||||
@@ -114,7 +114,7 @@ func TestCommissionWithdrawalSettingService_List(t *testing.T) {
|
|||||||
t.Run("查询配置列表-空结果", func(t *testing.T) {
|
t.Run("查询配置列表-空结果", func(t *testing.T) {
|
||||||
ctx := createWithdrawalSettingTestContext(1)
|
ctx := createWithdrawalSettingTestContext(1)
|
||||||
|
|
||||||
req := &model.WithdrawalSettingListReq{
|
req := &dto.WithdrawalSettingListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ func TestCommissionWithdrawalSettingService_List(t *testing.T) {
|
|||||||
ctx := createWithdrawalSettingTestContext(1)
|
ctx := createWithdrawalSettingTestContext(1)
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
req := &model.CreateWithdrawalSettingReq{
|
req := &dto.CreateWithdrawalSettingReq{
|
||||||
DailyWithdrawalLimit: i + 1,
|
DailyWithdrawalLimit: i + 1,
|
||||||
MinWithdrawalAmount: int64((i + 1) * 1000),
|
MinWithdrawalAmount: int64((i + 1) * 1000),
|
||||||
FeeRate: int64((i + 1) * 10),
|
FeeRate: int64((i + 1) * 10),
|
||||||
@@ -138,7 +138,7 @@ func TestCommissionWithdrawalSettingService_List(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
listReq := &model.WithdrawalSettingListReq{
|
listReq := &dto.WithdrawalSettingListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ func TestCommissionWithdrawalSettingService_GetCurrent(t *testing.T) {
|
|||||||
t.Run("获取当前配置-有配置时正常返回", func(t *testing.T) {
|
t.Run("获取当前配置-有配置时正常返回", func(t *testing.T) {
|
||||||
ctx := createWithdrawalSettingTestContext(1)
|
ctx := createWithdrawalSettingTestContext(1)
|
||||||
|
|
||||||
req := &model.CreateWithdrawalSettingReq{
|
req := &dto.CreateWithdrawalSettingReq{
|
||||||
DailyWithdrawalLimit: 5,
|
DailyWithdrawalLimit: 5,
|
||||||
MinWithdrawalAmount: 10000,
|
MinWithdrawalAmount: 10000,
|
||||||
FeeRate: 100,
|
FeeRate: 100,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/customer_account"
|
"github.com/break/junhong_cmp_fiber/internal/service/customer_account"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -34,7 +35,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
|||||||
t.Run("查询账号列表-空结果", func(t *testing.T) {
|
t.Run("查询账号列表-空结果", func(t *testing.T) {
|
||||||
ctx := createCustomerAccountTestContext(1)
|
ctx := createCustomerAccountTestContext(1)
|
||||||
|
|
||||||
req := &model.CustomerAccountListReq{
|
req := &dto.CustomerAccountListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -61,7 +62,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
|||||||
err := db.Create(shop).Error
|
err := db.Create(shop).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
createReq := &model.CreateCustomerAccountReq{
|
createReq := &dto.CreateCustomerAccountReq{
|
||||||
Username: "测试账号用户",
|
Username: "测试账号用户",
|
||||||
Phone: "13900000001",
|
Phone: "13900000001",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
@@ -70,7 +71,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
|||||||
_, err = service.Create(ctx, createReq)
|
_, err = service.Create(ctx, createReq)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.CustomerAccountListReq{
|
req := &dto.CustomerAccountListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
Username: "测试账号",
|
Username: "测试账号",
|
||||||
@@ -98,7 +99,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
|||||||
err := db.Create(shop).Error
|
err := db.Create(shop).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
createReq := &model.CreateCustomerAccountReq{
|
createReq := &dto.CreateCustomerAccountReq{
|
||||||
Username: "店铺筛选账号",
|
Username: "店铺筛选账号",
|
||||||
Phone: "13900000002",
|
Phone: "13900000002",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
@@ -107,7 +108,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
|||||||
_, err = service.Create(ctx, createReq)
|
_, err = service.Create(ctx, createReq)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.CustomerAccountListReq{
|
req := &dto.CustomerAccountListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
ShopID: &shop.ID,
|
ShopID: &shop.ID,
|
||||||
@@ -146,7 +147,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
|||||||
err := db.Create(shop).Error
|
err := db.Create(shop).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.CreateCustomerAccountReq{
|
req := &dto.CreateCustomerAccountReq{
|
||||||
Username: "新代理账号",
|
Username: "新代理账号",
|
||||||
Phone: "13900000010",
|
Phone: "13900000010",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
@@ -178,7 +179,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
|||||||
err := db.Create(shop).Error
|
err := db.Create(shop).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req1 := &model.CreateCustomerAccountReq{
|
req1 := &dto.CreateCustomerAccountReq{
|
||||||
Username: "账号一",
|
Username: "账号一",
|
||||||
Phone: "13900000011",
|
Phone: "13900000011",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
@@ -187,7 +188,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
|||||||
_, err = service.Create(ctx, req1)
|
_, err = service.Create(ctx, req1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req2 := &model.CreateCustomerAccountReq{
|
req2 := &dto.CreateCustomerAccountReq{
|
||||||
Username: "账号二",
|
Username: "账号二",
|
||||||
Phone: "13900000011",
|
Phone: "13900000011",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
@@ -200,7 +201,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
|||||||
t.Run("新增账号-店铺不存在应失败", func(t *testing.T) {
|
t.Run("新增账号-店铺不存在应失败", func(t *testing.T) {
|
||||||
ctx := createCustomerAccountTestContext(1)
|
ctx := createCustomerAccountTestContext(1)
|
||||||
|
|
||||||
req := &model.CreateCustomerAccountReq{
|
req := &dto.CreateCustomerAccountReq{
|
||||||
Username: "无效店铺账号",
|
Username: "无效店铺账号",
|
||||||
Phone: "13900000012",
|
Phone: "13900000012",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
@@ -214,7 +215,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
|||||||
t.Run("新增账号-未授权用户应失败", func(t *testing.T) {
|
t.Run("新增账号-未授权用户应失败", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
req := &model.CreateCustomerAccountReq{
|
req := &dto.CreateCustomerAccountReq{
|
||||||
Username: "未授权账号",
|
Username: "未授权账号",
|
||||||
Phone: "13900000013",
|
Phone: "13900000013",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
@@ -252,7 +253,7 @@ func TestCustomerAccountService_Update(t *testing.T) {
|
|||||||
err := db.Create(shop).Error
|
err := db.Create(shop).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
createReq := &model.CreateCustomerAccountReq{
|
createReq := &dto.CreateCustomerAccountReq{
|
||||||
Username: "待编辑账号",
|
Username: "待编辑账号",
|
||||||
Phone: "13900000020",
|
Phone: "13900000020",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
@@ -262,7 +263,7 @@ func TestCustomerAccountService_Update(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
newName := "编辑后账号"
|
newName := "编辑后账号"
|
||||||
updateReq := &model.UpdateCustomerAccountReq{
|
updateReq := &dto.UpdateCustomerAccountRequest{
|
||||||
Username: &newName,
|
Username: &newName,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +276,7 @@ func TestCustomerAccountService_Update(t *testing.T) {
|
|||||||
ctx := createCustomerAccountTestContext(1)
|
ctx := createCustomerAccountTestContext(1)
|
||||||
|
|
||||||
newName := "不存在账号"
|
newName := "不存在账号"
|
||||||
updateReq := &model.UpdateCustomerAccountReq{
|
updateReq := &dto.UpdateCustomerAccountRequest{
|
||||||
Username: &newName,
|
Username: &newName,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +311,7 @@ func TestCustomerAccountService_UpdatePassword(t *testing.T) {
|
|||||||
err := db.Create(shop).Error
|
err := db.Create(shop).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
createReq := &model.CreateCustomerAccountReq{
|
createReq := &dto.CreateCustomerAccountReq{
|
||||||
Username: "密码测试账号",
|
Username: "密码测试账号",
|
||||||
Phone: "13900000030",
|
Phone: "13900000030",
|
||||||
Password: "OldPass123",
|
Password: "OldPass123",
|
||||||
@@ -363,7 +364,7 @@ func TestCustomerAccountService_UpdateStatus(t *testing.T) {
|
|||||||
err := db.Create(shop).Error
|
err := db.Create(shop).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
createReq := &model.CreateCustomerAccountReq{
|
createReq := &dto.CreateCustomerAccountReq{
|
||||||
Username: "状态测试账号",
|
Username: "状态测试账号",
|
||||||
Phone: "13900000040",
|
Phone: "13900000040",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
@@ -397,7 +398,7 @@ func TestCustomerAccountService_UpdateStatus(t *testing.T) {
|
|||||||
err := db.Create(shop).Error
|
err := db.Create(shop).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
createReq := &model.CreateCustomerAccountReq{
|
createReq := &dto.CreateCustomerAccountReq{
|
||||||
Username: "启用测试账号",
|
Username: "启用测试账号",
|
||||||
Phone: "13900000041",
|
Phone: "13900000041",
|
||||||
Password: "Test123456",
|
Password: "Test123456",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/enterprise_card"
|
"github.com/break/junhong_cmp_fiber/internal/service/enterprise_card"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -34,7 +35,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
|||||||
t.Run("授权预检-企业不存在应失败", func(t *testing.T) {
|
t.Run("授权预检-企业不存在应失败", func(t *testing.T) {
|
||||||
ctx := createEnterpriseCardTestContext(1, 1)
|
ctx := createEnterpriseCardTestContext(1, 1)
|
||||||
|
|
||||||
req := &model.AllocateCardsPreviewReq{
|
req := &dto.AllocateCardsPreviewReq{
|
||||||
ICCIDs: []string{"898600000001"},
|
ICCIDs: []string{"898600000001"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
|||||||
t.Run("授权预检-未授权用户应失败", func(t *testing.T) {
|
t.Run("授权预检-未授权用户应失败", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
req := &model.AllocateCardsPreviewReq{
|
req := &dto.AllocateCardsPreviewReq{
|
||||||
ICCIDs: []string{"898600000001"},
|
ICCIDs: []string{"898600000001"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
|||||||
err := db.Create(ent).Error
|
err := db.Create(ent).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.AllocateCardsPreviewReq{
|
req := &dto.AllocateCardsPreviewReq{
|
||||||
ICCIDs: []string{},
|
ICCIDs: []string{},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +90,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
|||||||
err := db.Create(ent).Error
|
err := db.Create(ent).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.AllocateCardsPreviewReq{
|
req := &dto.AllocateCardsPreviewReq{
|
||||||
ICCIDs: []string{"NON_EXIST_ICCID"},
|
ICCIDs: []string{"NON_EXIST_ICCID"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +125,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
|||||||
err = db.Create(card).Error
|
err = db.Create(card).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.AllocateCardsPreviewReq{
|
req := &dto.AllocateCardsPreviewReq{
|
||||||
ICCIDs: []string{"898600001234567890"},
|
ICCIDs: []string{"898600001234567890"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +149,7 @@ func TestEnterpriseCardService_AllocateCards(t *testing.T) {
|
|||||||
t.Run("授权卡-企业不存在应失败", func(t *testing.T) {
|
t.Run("授权卡-企业不存在应失败", func(t *testing.T) {
|
||||||
ctx := createEnterpriseCardTestContext(1, 1)
|
ctx := createEnterpriseCardTestContext(1, 1)
|
||||||
|
|
||||||
req := &model.AllocateCardsReq{
|
req := &dto.AllocateCardsReq{
|
||||||
ICCIDs: []string{"898600000001"},
|
ICCIDs: []string{"898600000001"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +180,7 @@ func TestEnterpriseCardService_AllocateCards(t *testing.T) {
|
|||||||
err = db.Create(card).Error
|
err = db.Create(card).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.AllocateCardsReq{
|
req := &dto.AllocateCardsReq{
|
||||||
ICCIDs: []string{"898600002345678901"},
|
ICCIDs: []string{"898600002345678901"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +213,7 @@ func TestEnterpriseCardService_AllocateCards(t *testing.T) {
|
|||||||
err = db.Create(card).Error
|
err = db.Create(card).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.AllocateCardsReq{
|
req := &dto.AllocateCardsReq{
|
||||||
ICCIDs: []string{"898600003456789012"},
|
ICCIDs: []string{"898600003456789012"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +243,7 @@ func TestEnterpriseCardService_RecallCards(t *testing.T) {
|
|||||||
t.Run("回收授权-企业不存在应失败", func(t *testing.T) {
|
t.Run("回收授权-企业不存在应失败", func(t *testing.T) {
|
||||||
ctx := createEnterpriseCardTestContext(1, 1)
|
ctx := createEnterpriseCardTestContext(1, 1)
|
||||||
|
|
||||||
req := &model.RecallCardsReq{
|
req := &dto.RecallCardsReq{
|
||||||
ICCIDs: []string{"898600000001"},
|
ICCIDs: []string{"898600000001"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +274,7 @@ func TestEnterpriseCardService_RecallCards(t *testing.T) {
|
|||||||
err = db.Create(card).Error
|
err = db.Create(card).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.RecallCardsReq{
|
req := &dto.RecallCardsReq{
|
||||||
ICCIDs: []string{"898600004567890123"},
|
ICCIDs: []string{"898600004567890123"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,13 +307,13 @@ func TestEnterpriseCardService_RecallCards(t *testing.T) {
|
|||||||
err = db.Create(card).Error
|
err = db.Create(card).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
allocReq := &model.AllocateCardsReq{
|
allocReq := &dto.AllocateCardsReq{
|
||||||
ICCIDs: []string{"898600005678901234"},
|
ICCIDs: []string{"898600005678901234"},
|
||||||
}
|
}
|
||||||
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
recallReq := &model.RecallCardsReq{
|
recallReq := &dto.RecallCardsReq{
|
||||||
ICCIDs: []string{"898600005678901234"},
|
ICCIDs: []string{"898600005678901234"},
|
||||||
}
|
}
|
||||||
result, err := service.RecallCards(ctx, ent.ID, recallReq)
|
result, err := service.RecallCards(ctx, ent.ID, recallReq)
|
||||||
@@ -334,7 +335,7 @@ func TestEnterpriseCardService_ListCards(t *testing.T) {
|
|||||||
t.Run("查询企业卡列表-企业不存在应失败", func(t *testing.T) {
|
t.Run("查询企业卡列表-企业不存在应失败", func(t *testing.T) {
|
||||||
ctx := createEnterpriseCardTestContext(1, 1)
|
ctx := createEnterpriseCardTestContext(1, 1)
|
||||||
|
|
||||||
req := &model.EnterpriseCardListReq{
|
req := &dto.EnterpriseCardListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -356,7 +357,7 @@ func TestEnterpriseCardService_ListCards(t *testing.T) {
|
|||||||
err := db.Create(ent).Error
|
err := db.Create(ent).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.EnterpriseCardListReq{
|
req := &dto.EnterpriseCardListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -390,13 +391,13 @@ func TestEnterpriseCardService_ListCards(t *testing.T) {
|
|||||||
err = db.Create(card).Error
|
err = db.Create(card).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
allocReq := &model.AllocateCardsReq{
|
allocReq := &dto.AllocateCardsReq{
|
||||||
ICCIDs: []string{"898600006789012345"},
|
ICCIDs: []string{"898600006789012345"},
|
||||||
}
|
}
|
||||||
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.EnterpriseCardListReq{
|
req := &dto.EnterpriseCardListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -432,13 +433,13 @@ func TestEnterpriseCardService_ListCards(t *testing.T) {
|
|||||||
err = db.Create(card).Error
|
err = db.Create(card).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
allocReq := &model.AllocateCardsReq{
|
allocReq := &dto.AllocateCardsReq{
|
||||||
ICCIDs: []string{"898600007890123456"},
|
ICCIDs: []string{"898600007890123456"},
|
||||||
}
|
}
|
||||||
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.EnterpriseCardListReq{
|
req := &dto.EnterpriseCardListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
ICCID: "78901",
|
ICCID: "78901",
|
||||||
@@ -511,7 +512,7 @@ func TestEnterpriseCardService_SuspendAndResumeCard(t *testing.T) {
|
|||||||
err = db.Create(card).Error
|
err = db.Create(card).Error
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
allocReq := &model.AllocateCardsReq{
|
allocReq := &dto.AllocateCardsReq{
|
||||||
ICCIDs: []string{"898600009012345678"},
|
ICCIDs: []string{"898600009012345678"},
|
||||||
}
|
}
|
||||||
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/enterprise"
|
"github.com/break/junhong_cmp_fiber/internal/service/enterprise"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -34,7 +35,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
|||||||
t.Run("创建企业-含账号创建", func(t *testing.T) {
|
t.Run("创建企业-含账号创建", func(t *testing.T) {
|
||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
req := &model.CreateEnterpriseReq{
|
req := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "测试企业",
|
EnterpriseName: "测试企业",
|
||||||
EnterpriseCode: "ENT_TEST_001",
|
EnterpriseCode: "ENT_TEST_001",
|
||||||
ContactName: "测试联系人",
|
ContactName: "测试联系人",
|
||||||
@@ -55,7 +56,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
|||||||
t.Run("创建企业-企业编号已存在应失败", func(t *testing.T) {
|
t.Run("创建企业-企业编号已存在应失败", func(t *testing.T) {
|
||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
req1 := &model.CreateEnterpriseReq{
|
req1 := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "企业一",
|
EnterpriseName: "企业一",
|
||||||
EnterpriseCode: "ENT_DUP_001",
|
EnterpriseCode: "ENT_DUP_001",
|
||||||
ContactName: "联系人一",
|
ContactName: "联系人一",
|
||||||
@@ -66,7 +67,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
|||||||
_, err := service.Create(ctx, req1)
|
_, err := service.Create(ctx, req1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req2 := &model.CreateEnterpriseReq{
|
req2 := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "企业二",
|
EnterpriseName: "企业二",
|
||||||
EnterpriseCode: "ENT_DUP_001",
|
EnterpriseCode: "ENT_DUP_001",
|
||||||
ContactName: "联系人二",
|
ContactName: "联系人二",
|
||||||
@@ -81,7 +82,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
|||||||
t.Run("创建企业-手机号已存在应失败", func(t *testing.T) {
|
t.Run("创建企业-手机号已存在应失败", func(t *testing.T) {
|
||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
req1 := &model.CreateEnterpriseReq{
|
req1 := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "企业三",
|
EnterpriseName: "企业三",
|
||||||
EnterpriseCode: "ENT_PHONE_001",
|
EnterpriseCode: "ENT_PHONE_001",
|
||||||
ContactName: "联系人三",
|
ContactName: "联系人三",
|
||||||
@@ -92,7 +93,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
|||||||
_, err := service.Create(ctx, req1)
|
_, err := service.Create(ctx, req1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req2 := &model.CreateEnterpriseReq{
|
req2 := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "企业四",
|
EnterpriseName: "企业四",
|
||||||
EnterpriseCode: "ENT_PHONE_002",
|
EnterpriseCode: "ENT_PHONE_002",
|
||||||
ContactName: "联系人四",
|
ContactName: "联系人四",
|
||||||
@@ -107,7 +108,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
|||||||
t.Run("创建企业-未授权用户应失败", func(t *testing.T) {
|
t.Run("创建企业-未授权用户应失败", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
req := &model.CreateEnterpriseReq{
|
req := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "未授权企业",
|
EnterpriseName: "未授权企业",
|
||||||
EnterpriseCode: "ENT_UNAUTH_001",
|
EnterpriseCode: "ENT_UNAUTH_001",
|
||||||
ContactName: "联系人",
|
ContactName: "联系人",
|
||||||
@@ -134,7 +135,7 @@ func TestEnterpriseService_Update(t *testing.T) {
|
|||||||
t.Run("编辑企业", func(t *testing.T) {
|
t.Run("编辑企业", func(t *testing.T) {
|
||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
createReq := &model.CreateEnterpriseReq{
|
createReq := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "待编辑企业",
|
EnterpriseName: "待编辑企业",
|
||||||
EnterpriseCode: "ENT_EDIT_001",
|
EnterpriseCode: "ENT_EDIT_001",
|
||||||
ContactName: "原联系人",
|
ContactName: "原联系人",
|
||||||
@@ -147,7 +148,7 @@ func TestEnterpriseService_Update(t *testing.T) {
|
|||||||
|
|
||||||
newName := "编辑后企业"
|
newName := "编辑后企业"
|
||||||
newContact := "新联系人"
|
newContact := "新联系人"
|
||||||
updateReq := &model.UpdateEnterpriseRequest{
|
updateReq := &dto.UpdateEnterpriseRequest{
|
||||||
EnterpriseName: &newName,
|
EnterpriseName: &newName,
|
||||||
ContactName: &newContact,
|
ContactName: &newContact,
|
||||||
}
|
}
|
||||||
@@ -162,7 +163,7 @@ func TestEnterpriseService_Update(t *testing.T) {
|
|||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
newName := "不存在企业"
|
newName := "不存在企业"
|
||||||
updateReq := &model.UpdateEnterpriseRequest{
|
updateReq := &dto.UpdateEnterpriseRequest{
|
||||||
EnterpriseName: &newName,
|
EnterpriseName: &newName,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +185,7 @@ func TestEnterpriseService_UpdateStatus(t *testing.T) {
|
|||||||
t.Run("禁用企业-账号同步禁用", func(t *testing.T) {
|
t.Run("禁用企业-账号同步禁用", func(t *testing.T) {
|
||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
createReq := &model.CreateEnterpriseReq{
|
createReq := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "待禁用企业",
|
EnterpriseName: "待禁用企业",
|
||||||
EnterpriseCode: "ENT_STATUS_001",
|
EnterpriseCode: "ENT_STATUS_001",
|
||||||
ContactName: "联系人",
|
ContactName: "联系人",
|
||||||
@@ -211,7 +212,7 @@ func TestEnterpriseService_UpdateStatus(t *testing.T) {
|
|||||||
t.Run("启用企业-账号同步启用", func(t *testing.T) {
|
t.Run("启用企业-账号同步启用", func(t *testing.T) {
|
||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
createReq := &model.CreateEnterpriseReq{
|
createReq := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "待启用企业",
|
EnterpriseName: "待启用企业",
|
||||||
EnterpriseCode: "ENT_STATUS_002",
|
EnterpriseCode: "ENT_STATUS_002",
|
||||||
ContactName: "联系人",
|
ContactName: "联系人",
|
||||||
@@ -259,7 +260,7 @@ func TestEnterpriseService_UpdatePassword(t *testing.T) {
|
|||||||
t.Run("修改企业账号密码", func(t *testing.T) {
|
t.Run("修改企业账号密码", func(t *testing.T) {
|
||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
createReq := &model.CreateEnterpriseReq{
|
createReq := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "密码测试企业",
|
EnterpriseName: "密码测试企业",
|
||||||
EnterpriseCode: "ENT_PWD_001",
|
EnterpriseCode: "ENT_PWD_001",
|
||||||
ContactName: "联系人",
|
ContactName: "联系人",
|
||||||
@@ -301,7 +302,7 @@ func TestEnterpriseService_List(t *testing.T) {
|
|||||||
t.Run("查询企业列表-空结果", func(t *testing.T) {
|
t.Run("查询企业列表-空结果", func(t *testing.T) {
|
||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
req := &model.EnterpriseListReq{
|
req := &dto.EnterpriseListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -316,7 +317,7 @@ func TestEnterpriseService_List(t *testing.T) {
|
|||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
createReq := &model.CreateEnterpriseReq{
|
createReq := &dto.CreateEnterpriseReq{
|
||||||
EnterpriseName: "列表测试企业",
|
EnterpriseName: "列表测试企业",
|
||||||
EnterpriseCode: "ENT_LIST_" + string(rune('A'+i)),
|
EnterpriseCode: "ENT_LIST_" + string(rune('A'+i)),
|
||||||
ContactName: "联系人",
|
ContactName: "联系人",
|
||||||
@@ -328,7 +329,7 @@ func TestEnterpriseService_List(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &model.EnterpriseListReq{
|
req := &dto.EnterpriseListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
EnterpriseName: "列表测试",
|
EnterpriseName: "列表测试",
|
||||||
@@ -344,7 +345,7 @@ func TestEnterpriseService_List(t *testing.T) {
|
|||||||
ctx := createEnterpriseTestContext(1)
|
ctx := createEnterpriseTestContext(1)
|
||||||
|
|
||||||
status := constants.StatusEnabled
|
status := constants.StatusEnabled
|
||||||
req := &model.EnterpriseListReq{
|
req := &dto.EnterpriseListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
Status: &status,
|
Status: &status,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/my_commission"
|
"github.com/break/junhong_cmp_fiber/internal/service/my_commission"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -110,7 +111,7 @@ func TestMyCommissionService_CreateWithdrawalRequest(t *testing.T) {
|
|||||||
|
|
||||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||||
|
|
||||||
req := &model.CreateMyWithdrawalReq{
|
req := &dto.CreateMyWithdrawalReq{
|
||||||
Amount: 10000,
|
Amount: 10000,
|
||||||
WithdrawalMethod: "alipay",
|
WithdrawalMethod: "alipay",
|
||||||
AccountName: "测试用户",
|
AccountName: "测试用户",
|
||||||
@@ -148,7 +149,7 @@ func TestMyCommissionService_CreateWithdrawalRequest(t *testing.T) {
|
|||||||
|
|
||||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||||
|
|
||||||
req := &model.CreateMyWithdrawalReq{
|
req := &dto.CreateMyWithdrawalReq{
|
||||||
Amount: 5000,
|
Amount: 5000,
|
||||||
WithdrawalMethod: "alipay",
|
WithdrawalMethod: "alipay",
|
||||||
AccountName: "测试用户",
|
AccountName: "测试用户",
|
||||||
@@ -184,7 +185,7 @@ func TestMyCommissionService_CreateWithdrawalRequest(t *testing.T) {
|
|||||||
|
|
||||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||||
|
|
||||||
req := &model.CreateMyWithdrawalReq{
|
req := &dto.CreateMyWithdrawalReq{
|
||||||
Amount: 50000,
|
Amount: 50000,
|
||||||
WithdrawalMethod: "alipay",
|
WithdrawalMethod: "alipay",
|
||||||
AccountName: "测试用户",
|
AccountName: "测试用户",
|
||||||
@@ -198,7 +199,7 @@ func TestMyCommissionService_CreateWithdrawalRequest(t *testing.T) {
|
|||||||
t.Run("发起提现-非代理商用户应失败", func(t *testing.T) {
|
t.Run("发起提现-非代理商用户应失败", func(t *testing.T) {
|
||||||
ctx := createMyCommissionTestContext(1, 1, constants.UserTypePlatform)
|
ctx := createMyCommissionTestContext(1, 1, constants.UserTypePlatform)
|
||||||
|
|
||||||
req := &model.CreateMyWithdrawalReq{
|
req := &dto.CreateMyWithdrawalReq{
|
||||||
Amount: 10000,
|
Amount: 10000,
|
||||||
WithdrawalMethod: "alipay",
|
WithdrawalMethod: "alipay",
|
||||||
AccountName: "测试用户",
|
AccountName: "测试用户",
|
||||||
@@ -243,7 +244,7 @@ func TestMyCommissionService_ListMyWithdrawalRequests(t *testing.T) {
|
|||||||
|
|
||||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||||
|
|
||||||
req := &model.MyWithdrawalListReq{
|
req := &dto.MyWithdrawalListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -271,7 +272,7 @@ func TestMyCommissionService_ListMyWithdrawalRequests(t *testing.T) {
|
|||||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||||
|
|
||||||
status := 1
|
status := 1
|
||||||
req := &model.MyWithdrawalListReq{
|
req := &dto.MyWithdrawalListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
Status: &status,
|
Status: &status,
|
||||||
@@ -285,7 +286,7 @@ func TestMyCommissionService_ListMyWithdrawalRequests(t *testing.T) {
|
|||||||
t.Run("查询提现记录-非代理商用户应失败", func(t *testing.T) {
|
t.Run("查询提现记录-非代理商用户应失败", func(t *testing.T) {
|
||||||
ctx := createMyCommissionTestContext(1, 1, constants.UserTypePlatform)
|
ctx := createMyCommissionTestContext(1, 1, constants.UserTypePlatform)
|
||||||
|
|
||||||
req := &model.MyWithdrawalListReq{
|
req := &dto.MyWithdrawalListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -328,7 +329,7 @@ func TestMyCommissionService_ListMyCommissionRecords(t *testing.T) {
|
|||||||
|
|
||||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||||
|
|
||||||
req := &model.MyCommissionRecordListReq{
|
req := &dto.MyCommissionRecordListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -356,7 +357,7 @@ func TestMyCommissionService_ListMyCommissionRecords(t *testing.T) {
|
|||||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||||
|
|
||||||
commissionType := "one_time"
|
commissionType := "one_time"
|
||||||
req := &model.MyCommissionRecordListReq{
|
req := &dto.MyCommissionRecordListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
CommissionType: &commissionType,
|
CommissionType: &commissionType,
|
||||||
@@ -370,7 +371,7 @@ func TestMyCommissionService_ListMyCommissionRecords(t *testing.T) {
|
|||||||
t.Run("查询佣金明细-非代理商用户应失败", func(t *testing.T) {
|
t.Run("查询佣金明细-非代理商用户应失败", func(t *testing.T) {
|
||||||
ctx := createMyCommissionTestContext(1, 1, constants.UserTypePlatform)
|
ctx := createMyCommissionTestContext(1, 1, constants.UserTypePlatform)
|
||||||
|
|
||||||
req := &model.MyCommissionRecordListReq{
|
req := &dto.MyCommissionRecordListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/permission"
|
"github.com/break/junhong_cmp_fiber/internal/service/permission"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -42,7 +43,7 @@ func TestPermissionPlatformFilter_List(t *testing.T) {
|
|||||||
|
|
||||||
// 测试查询全部权限(不过滤)
|
// 测试查询全部权限(不过滤)
|
||||||
t.Run("查询全部权限", func(t *testing.T) {
|
t.Run("查询全部权限", func(t *testing.T) {
|
||||||
req := &model.PermissionListRequest{
|
req := &dto.PermissionListRequest{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 10,
|
PageSize: 10,
|
||||||
}
|
}
|
||||||
@@ -54,7 +55,7 @@ func TestPermissionPlatformFilter_List(t *testing.T) {
|
|||||||
|
|
||||||
// 测试只查询 all 权限
|
// 测试只查询 all 权限
|
||||||
t.Run("只查询all端口权限", func(t *testing.T) {
|
t.Run("只查询all端口权限", func(t *testing.T) {
|
||||||
req := &model.PermissionListRequest{
|
req := &dto.PermissionListRequest{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 10,
|
PageSize: 10,
|
||||||
Platform: constants.PlatformAll,
|
Platform: constants.PlatformAll,
|
||||||
@@ -68,7 +69,7 @@ func TestPermissionPlatformFilter_List(t *testing.T) {
|
|||||||
|
|
||||||
// 测试只查询 web 权限
|
// 测试只查询 web 权限
|
||||||
t.Run("只查询web端口权限", func(t *testing.T) {
|
t.Run("只查询web端口权限", func(t *testing.T) {
|
||||||
req := &model.PermissionListRequest{
|
req := &dto.PermissionListRequest{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 10,
|
PageSize: 10,
|
||||||
Platform: constants.PlatformWeb,
|
Platform: constants.PlatformWeb,
|
||||||
@@ -85,7 +86,7 @@ func TestPermissionPlatformFilter_List(t *testing.T) {
|
|||||||
|
|
||||||
// 测试只查询 h5 权限
|
// 测试只查询 h5 权限
|
||||||
t.Run("只查询h5端口权限", func(t *testing.T) {
|
t.Run("只查询h5端口权限", func(t *testing.T) {
|
||||||
req := &model.PermissionListRequest{
|
req := &dto.PermissionListRequest{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 10,
|
PageSize: 10,
|
||||||
Platform: constants.PlatformH5,
|
Platform: constants.PlatformH5,
|
||||||
@@ -115,7 +116,7 @@ func TestPermissionPlatformFilter_CreateWithDefaultPlatform(t *testing.T) {
|
|||||||
ctx = middleware.SetUserContext(ctx, middleware.NewSimpleUserContext(1, constants.UserTypeSuperAdmin, 0))
|
ctx = middleware.SetUserContext(ctx, middleware.NewSimpleUserContext(1, constants.UserTypeSuperAdmin, 0))
|
||||||
|
|
||||||
// 创建权限时不指定 platform
|
// 创建权限时不指定 platform
|
||||||
req := &model.CreatePermissionRequest{
|
req := &dto.CreatePermissionRequest{
|
||||||
PermName: "测试权限",
|
PermName: "测试权限",
|
||||||
PermCode: "test:permission",
|
PermCode: "test:permission",
|
||||||
PermType: constants.PermissionTypeMenu,
|
PermType: constants.PermissionTypeMenu,
|
||||||
@@ -152,7 +153,7 @@ func TestPermissionPlatformFilter_CreateWithSpecificPlatform(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
req := &model.CreatePermissionRequest{
|
req := &dto.CreatePermissionRequest{
|
||||||
PermName: "测试权限_" + tt.platform,
|
PermName: "测试权限_" + tt.platform,
|
||||||
PermCode: "test:" + tt.platform,
|
PermCode: "test:" + tt.platform,
|
||||||
PermType: constants.PermissionTypeMenu,
|
PermType: constants.PermissionTypeMenu,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/shop_account"
|
"github.com/break/junhong_cmp_fiber/internal/service/shop_account"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -40,7 +41,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
|||||||
err := shopStore.Create(ctx, shop)
|
err := shopStore.Create(ctx, shop)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.CreateShopAccountRequest{
|
req := &dto.CreateShopAccountRequest{
|
||||||
ShopID: shop.ID,
|
ShopID: shop.ID,
|
||||||
Username: testutils.GenerateUsername("account", 1),
|
Username: testutils.GenerateUsername("account", 1),
|
||||||
Phone: testutils.GeneratePhone("139", 1),
|
Phone: testutils.GeneratePhone("139", 1),
|
||||||
@@ -58,7 +59,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
|||||||
t.Run("创建商户账号-商户不存在应失败", func(t *testing.T) {
|
t.Run("创建商户账号-商户不存在应失败", func(t *testing.T) {
|
||||||
ctx := createContextWithUserID(1)
|
ctx := createContextWithUserID(1)
|
||||||
|
|
||||||
req := &model.CreateShopAccountRequest{
|
req := &dto.CreateShopAccountRequest{
|
||||||
ShopID: 99999,
|
ShopID: 99999,
|
||||||
Username: testutils.GenerateUsername("account", 2),
|
Username: testutils.GenerateUsername("account", 2),
|
||||||
Phone: testutils.GeneratePhone("139", 2),
|
Phone: testutils.GeneratePhone("139", 2),
|
||||||
@@ -91,7 +92,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
username := testutils.GenerateUsername("duplicate", 1)
|
username := testutils.GenerateUsername("duplicate", 1)
|
||||||
req1 := &model.CreateShopAccountRequest{
|
req1 := &dto.CreateShopAccountRequest{
|
||||||
ShopID: shop.ID,
|
ShopID: shop.ID,
|
||||||
Username: username,
|
Username: username,
|
||||||
Phone: testutils.GeneratePhone("138", 1),
|
Phone: testutils.GeneratePhone("138", 1),
|
||||||
@@ -100,7 +101,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
|||||||
_, err = service.Create(ctx, req1)
|
_, err = service.Create(ctx, req1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req2 := &model.CreateShopAccountRequest{
|
req2 := &dto.CreateShopAccountRequest{
|
||||||
ShopID: shop.ID,
|
ShopID: shop.ID,
|
||||||
Username: username,
|
Username: username,
|
||||||
Phone: testutils.GeneratePhone("138", 2),
|
Phone: testutils.GeneratePhone("138", 2),
|
||||||
@@ -114,7 +115,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
|||||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
req := &model.CreateShopAccountRequest{
|
req := &dto.CreateShopAccountRequest{
|
||||||
ShopID: 1,
|
ShopID: 1,
|
||||||
Username: "test",
|
Username: "test",
|
||||||
Phone: "13800000000",
|
Phone: "13800000000",
|
||||||
@@ -167,7 +168,7 @@ func TestShopAccountService_Update(t *testing.T) {
|
|||||||
err = accountStore.Create(ctx, account)
|
err = accountStore.Create(ctx, account)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.UpdateShopAccountRequest{
|
req := &dto.UpdateShopAccountRequest{
|
||||||
Username: testutils.GenerateUsername("newuser", 1),
|
Username: testutils.GenerateUsername("newuser", 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +180,7 @@ func TestShopAccountService_Update(t *testing.T) {
|
|||||||
t.Run("更新不存在的账号应失败", func(t *testing.T) {
|
t.Run("更新不存在的账号应失败", func(t *testing.T) {
|
||||||
ctx := createContextWithUserID(1)
|
ctx := createContextWithUserID(1)
|
||||||
|
|
||||||
req := &model.UpdateShopAccountRequest{
|
req := &dto.UpdateShopAccountRequest{
|
||||||
Username: "newuser",
|
Username: "newuser",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +192,7 @@ func TestShopAccountService_Update(t *testing.T) {
|
|||||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
req := &model.UpdateShopAccountRequest{
|
req := &dto.UpdateShopAccountRequest{
|
||||||
Username: "newuser",
|
Username: "newuser",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +242,7 @@ func TestShopAccountService_UpdatePassword(t *testing.T) {
|
|||||||
err = accountStore.Create(ctx, account)
|
err = accountStore.Create(ctx, account)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.UpdateShopAccountPasswordRequest{
|
req := &dto.UpdateShopAccountPasswordRequest{
|
||||||
NewPassword: "newpassword123",
|
NewPassword: "newpassword123",
|
||||||
}
|
}
|
||||||
err = service.UpdatePassword(ctx, account.ID, req)
|
err = service.UpdatePassword(ctx, account.ID, req)
|
||||||
@@ -255,7 +256,7 @@ func TestShopAccountService_UpdatePassword(t *testing.T) {
|
|||||||
t.Run("更新不存在的账号密码应失败", func(t *testing.T) {
|
t.Run("更新不存在的账号密码应失败", func(t *testing.T) {
|
||||||
ctx := createContextWithUserID(1)
|
ctx := createContextWithUserID(1)
|
||||||
|
|
||||||
req := &model.UpdateShopAccountPasswordRequest{
|
req := &dto.UpdateShopAccountPasswordRequest{
|
||||||
NewPassword: "newpassword",
|
NewPassword: "newpassword",
|
||||||
}
|
}
|
||||||
err := service.UpdatePassword(ctx, 99999, req)
|
err := service.UpdatePassword(ctx, 99999, req)
|
||||||
@@ -265,7 +266,7 @@ func TestShopAccountService_UpdatePassword(t *testing.T) {
|
|||||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
req := &model.UpdateShopAccountPasswordRequest{
|
req := &dto.UpdateShopAccountPasswordRequest{
|
||||||
NewPassword: "newpassword",
|
NewPassword: "newpassword",
|
||||||
}
|
}
|
||||||
err := service.UpdatePassword(ctx, 1, req)
|
err := service.UpdatePassword(ctx, 1, req)
|
||||||
@@ -313,7 +314,7 @@ func TestShopAccountService_UpdateStatus(t *testing.T) {
|
|||||||
err = accountStore.Create(ctx, account)
|
err = accountStore.Create(ctx, account)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.UpdateShopAccountStatusRequest{
|
req := &dto.UpdateShopAccountStatusRequest{
|
||||||
Status: constants.StatusDisabled,
|
Status: constants.StatusDisabled,
|
||||||
}
|
}
|
||||||
err = service.UpdateStatus(ctx, account.ID, req)
|
err = service.UpdateStatus(ctx, account.ID, req)
|
||||||
@@ -327,7 +328,7 @@ func TestShopAccountService_UpdateStatus(t *testing.T) {
|
|||||||
t.Run("更新不存在的账号状态应失败", func(t *testing.T) {
|
t.Run("更新不存在的账号状态应失败", func(t *testing.T) {
|
||||||
ctx := createContextWithUserID(1)
|
ctx := createContextWithUserID(1)
|
||||||
|
|
||||||
req := &model.UpdateShopAccountStatusRequest{
|
req := &dto.UpdateShopAccountStatusRequest{
|
||||||
Status: constants.StatusDisabled,
|
Status: constants.StatusDisabled,
|
||||||
}
|
}
|
||||||
err := service.UpdateStatus(ctx, 99999, req)
|
err := service.UpdateStatus(ctx, 99999, req)
|
||||||
@@ -337,7 +338,7 @@ func TestShopAccountService_UpdateStatus(t *testing.T) {
|
|||||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
req := &model.UpdateShopAccountStatusRequest{
|
req := &dto.UpdateShopAccountStatusRequest{
|
||||||
Status: constants.StatusDisabled,
|
Status: constants.StatusDisabled,
|
||||||
}
|
}
|
||||||
err := service.UpdateStatus(ctx, 1, req)
|
err := service.UpdateStatus(ctx, 1, req)
|
||||||
@@ -387,7 +388,7 @@ func TestShopAccountService_List(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &model.ShopAccountListRequest{
|
req := &dto.ShopAccountListRequest{
|
||||||
ShopID: &shop.ID,
|
ShopID: &shop.ID,
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/shop_commission"
|
"github.com/break/junhong_cmp_fiber/internal/service/shop_commission"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -51,7 +52,7 @@ func TestShopCommissionService_ListShopCommissionSummary(t *testing.T) {
|
|||||||
err := shopStore.Create(ctx, shop)
|
err := shopStore.Create(ctx, shop)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.ShopCommissionSummaryListReq{
|
req := &dto.ShopCommissionSummaryListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -80,7 +81,7 @@ func TestShopCommissionService_ListShopCommissionSummary(t *testing.T) {
|
|||||||
err := shopStore.Create(ctx, shop)
|
err := shopStore.Create(ctx, shop)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.ShopCommissionSummaryListReq{
|
req := &dto.ShopCommissionSummaryListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
ShopName: "筛选测试",
|
ShopName: "筛选测试",
|
||||||
@@ -122,7 +123,7 @@ func TestShopCommissionService_ListShopWithdrawalRequests(t *testing.T) {
|
|||||||
err := shopStore.Create(ctx, shop)
|
err := shopStore.Create(ctx, shop)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.ShopWithdrawalRequestListReq{
|
req := &dto.ShopWithdrawalRequestListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -136,7 +137,7 @@ func TestShopCommissionService_ListShopWithdrawalRequests(t *testing.T) {
|
|||||||
t.Run("查询不存在的店铺提现记录应失败", func(t *testing.T) {
|
t.Run("查询不存在的店铺提现记录应失败", func(t *testing.T) {
|
||||||
ctx := createCommissionTestContext(1)
|
ctx := createCommissionTestContext(1)
|
||||||
|
|
||||||
req := &model.ShopWithdrawalRequestListReq{
|
req := &dto.ShopWithdrawalRequestListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -176,7 +177,7 @@ func TestShopCommissionService_ListShopCommissionRecords(t *testing.T) {
|
|||||||
err := shopStore.Create(ctx, shop)
|
err := shopStore.Create(ctx, shop)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req := &model.ShopCommissionRecordListReq{
|
req := &dto.ShopCommissionRecordListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
@@ -190,7 +191,7 @@ func TestShopCommissionService_ListShopCommissionRecords(t *testing.T) {
|
|||||||
t.Run("查询不存在的店铺佣金明细应失败", func(t *testing.T) {
|
t.Run("查询不存在的店铺佣金明细应失败", func(t *testing.T) {
|
||||||
ctx := createCommissionTestContext(1)
|
ctx := createCommissionTestContext(1)
|
||||||
|
|
||||||
req := &model.ShopCommissionRecordListReq{
|
req := &dto.ShopCommissionRecordListReq{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
PageSize: 20,
|
PageSize: 20,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||||
|
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/service/shop"
|
"github.com/break/junhong_cmp_fiber/internal/service/shop"
|
||||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||||
@@ -26,7 +27,7 @@ func TestShopService_Create(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("创建一级店铺成功", func(t *testing.T) {
|
t.Run("创建一级店铺成功", func(t *testing.T) {
|
||||||
ctx := createContextWithUserID(1)
|
ctx := createContextWithUserID(1)
|
||||||
req := &model.CreateShopRequest{
|
req := &dto.CreateShopRequest{
|
||||||
ShopName: "测试一级店铺",
|
ShopName: "测试一级店铺",
|
||||||
ShopCode: "SHOP_L1_001",
|
ShopCode: "SHOP_L1_001",
|
||||||
ParentID: nil,
|
ParentID: nil,
|
||||||
@@ -71,7 +72,7 @@ func TestShopService_Create(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// 创建二级店铺
|
// 创建二级店铺
|
||||||
req := &model.CreateShopRequest{
|
req := &dto.CreateShopRequest{
|
||||||
ShopName: "测试二级店铺",
|
ShopName: "测试二级店铺",
|
||||||
ShopCode: "SHOP_L2_001",
|
ShopCode: "SHOP_L2_001",
|
||||||
ParentID: &parent.ID,
|
ParentID: &parent.ID,
|
||||||
@@ -123,7 +124,7 @@ func TestShopService_Create(t *testing.T) {
|
|||||||
assert.Equal(t, 7, shops[6].Level)
|
assert.Equal(t, 7, shops[6].Level)
|
||||||
|
|
||||||
// 尝试创建第 8 级店铺(应该失败)
|
// 尝试创建第 8 级店铺(应该失败)
|
||||||
req := &model.CreateShopRequest{
|
req := &dto.CreateShopRequest{
|
||||||
ShopName: "第8级店铺",
|
ShopName: "第8级店铺",
|
||||||
ShopCode: "SHOP_L8_001",
|
ShopCode: "SHOP_L8_001",
|
||||||
ParentID: &shops[6].ID, // 第7级店铺的ID
|
ParentID: &shops[6].ID, // 第7级店铺的ID
|
||||||
@@ -149,7 +150,7 @@ func TestShopService_Create(t *testing.T) {
|
|||||||
ctx := createContextWithUserID(1)
|
ctx := createContextWithUserID(1)
|
||||||
|
|
||||||
// 创建第一个店铺
|
// 创建第一个店铺
|
||||||
req1 := &model.CreateShopRequest{
|
req1 := &dto.CreateShopRequest{
|
||||||
ShopName: "店铺A",
|
ShopName: "店铺A",
|
||||||
ShopCode: "UNIQUE_CODE_001",
|
ShopCode: "UNIQUE_CODE_001",
|
||||||
ContactName: "张三",
|
ContactName: "张三",
|
||||||
@@ -162,7 +163,7 @@ func TestShopService_Create(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// 尝试创建相同编号的店铺(应该失败)
|
// 尝试创建相同编号的店铺(应该失败)
|
||||||
req2 := &model.CreateShopRequest{
|
req2 := &dto.CreateShopRequest{
|
||||||
ShopName: "店铺B",
|
ShopName: "店铺B",
|
||||||
ShopCode: "UNIQUE_CODE_001", // 重复编号
|
ShopCode: "UNIQUE_CODE_001", // 重复编号
|
||||||
ContactName: "李四",
|
ContactName: "李四",
|
||||||
@@ -186,7 +187,7 @@ func TestShopService_Create(t *testing.T) {
|
|||||||
ctx := createContextWithUserID(1)
|
ctx := createContextWithUserID(1)
|
||||||
|
|
||||||
nonExistentID := uint(99999)
|
nonExistentID := uint(99999)
|
||||||
req := &model.CreateShopRequest{
|
req := &dto.CreateShopRequest{
|
||||||
ShopName: "测试店铺",
|
ShopName: "测试店铺",
|
||||||
ShopCode: "SHOP_INVALID_PARENT",
|
ShopCode: "SHOP_INVALID_PARENT",
|
||||||
ParentID: &nonExistentID, // 不存在的上级店铺 ID
|
ParentID: &nonExistentID, // 不存在的上级店铺 ID
|
||||||
@@ -211,7 +212,7 @@ func TestShopService_Create(t *testing.T) {
|
|||||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||||
ctx := context.Background() // 没有用户 ID 的 context
|
ctx := context.Background() // 没有用户 ID 的 context
|
||||||
|
|
||||||
req := &model.CreateShopRequest{
|
req := &dto.CreateShopRequest{
|
||||||
ShopName: "测试店铺",
|
ShopName: "测试店铺",
|
||||||
ShopCode: "SHOP_UNAUTHORIZED",
|
ShopCode: "SHOP_UNAUTHORIZED",
|
||||||
ContactName: "测试",
|
ContactName: "测试",
|
||||||
@@ -262,7 +263,7 @@ func TestShopService_Update(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// 更新店铺
|
// 更新店铺
|
||||||
req := &model.UpdateShopRequest{
|
req := &dto.UpdateShopRequest{
|
||||||
ShopName: "更新后的店铺名称",
|
ShopName: "更新后的店铺名称",
|
||||||
ContactName: "新联系人",
|
ContactName: "新联系人",
|
||||||
ContactPhone: "13900000001",
|
ContactPhone: "13900000001",
|
||||||
@@ -316,7 +317,7 @@ func TestShopService_Update(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// 尝试更新 shop2 的名称为已存在的名称(应该成功,因为名称不需要唯一性)
|
// 尝试更新 shop2 的名称为已存在的名称(应该成功,因为名称不需要唯一性)
|
||||||
req := &model.UpdateShopRequest{
|
req := &dto.UpdateShopRequest{
|
||||||
ShopName: "店铺1",
|
ShopName: "店铺1",
|
||||||
Status: constants.StatusEnabled,
|
Status: constants.StatusEnabled,
|
||||||
}
|
}
|
||||||
@@ -330,7 +331,7 @@ func TestShopService_Update(t *testing.T) {
|
|||||||
t.Run("更新不存在的店铺应失败", func(t *testing.T) {
|
t.Run("更新不存在的店铺应失败", func(t *testing.T) {
|
||||||
ctx := createContextWithUserID(1)
|
ctx := createContextWithUserID(1)
|
||||||
|
|
||||||
req := &model.UpdateShopRequest{
|
req := &dto.UpdateShopRequest{
|
||||||
ShopName: "新名称",
|
ShopName: "新名称",
|
||||||
Status: constants.StatusEnabled,
|
Status: constants.StatusEnabled,
|
||||||
}
|
}
|
||||||
@@ -347,7 +348,7 @@ func TestShopService_Update(t *testing.T) {
|
|||||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
req := &model.UpdateShopRequest{
|
req := &dto.UpdateShopRequest{
|
||||||
ShopName: "新名称",
|
ShopName: "新名称",
|
||||||
Status: constants.StatusEnabled,
|
Status: constants.StatusEnabled,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user